如何增加 Sphinx/reStructured Text 中的固定宽度字体大小? [英] How do I increase the fixed width font size in Sphinx / reStructured Text?

查看:27
本文介绍了如何增加 Sphinx/reStructured Text 中的固定宽度字体大小?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Sphinx 生成使用重构文本作为标记的文档.但是,当我使用一些内联格式使文本以固定宽度的字体 --no-cache 显示时,呈现的 HTML 以较小的字体显示文本.

I'm using Sphinx to generate documentation which uses reStructured Text as it's markup. However, when I use some inline formatting to make text show up in a fixed width font --no-cache the rendered HTML shows the text in a smaller font.

如何增加 Sphinx/reStructured Text 中的固定宽度字体大小,使其与普通文本字体大小匹配?

How do I increase the fixed-width font size in Sphinx / reStructured Text so it matches the normal text font-size?

回答

在 Chris 的帮助下,我能够覆盖 CSS 中的默认字体样式以增加固定宽度的字体大小:

With Chris's help I was able to override the default font style in the CSS to increase the fixed-width font size:

1) 编辑 conf.py 指定 html 主题和 css 文件:

1) Edit conf.py to specify html theme and css file:

html_theme = 'default'
html_sytle = 'overrides.css'

2) 接下来,我创建了一个新的 css 文件 static/overrides.css,内容如下:

2) Next, I created a new css file static/overrides.css with the following contents:

@import url("default.css");

tt {
    font-size: 130%;
}

我选择使用 130% 因为 default.css 定义了这个:

I selected to use 130% because default.css defines this:

div.body p, div.body dd, div.body li {
    text-align: justify;
    line-height: 130%;
}

现在我在生成的 html 中得到与常规文本匹配的固定宽度文本.

And now I get fixed width text matching regular text in the generated html.

推荐答案

您可以为正在使用的任何主题编辑 CSS 样式表.例如,对于默认主题,您可以编辑 default.css_t 文件.具体来说,您可以在 font-size(例如,使用 font-size: 1.1em 或类似值).org/birkenfeld/sphinx/src/0e789eafb3bb89c0740321dd9271ca6fcaa5abee/sphinx/themes/default/static/default.css_t?at=default#cl-274" rel="noreferrer">pre 274 行规则一>.

You can edit the CSS stylesheet for whichever theme you are using. For example, for the default theme, you can edit the default.css_t file. Specifically you can specify an increased font-size (for example, use font-size: 1.1em or similar) in the pre rule on line 274.

这篇关于如何增加 Sphinx/reStructured Text 中的固定宽度字体大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆