How do I increase the fixed width font size in Sphinx / reStructured Text?

拟墨画扇 提交于 2019-12-22 06:21:12

问题


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.

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

Answer

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

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

html_theme = 'default'
html_sytle = '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%;
}

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%;
}

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


回答1:


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.



来源:https://stackoverflow.com/questions/24335079/how-do-i-increase-the-fixed-width-font-size-in-sphinx-restructured-text

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!