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

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_style = '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 the regular text in the generated html.


Solution 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.