Enlarge 4 deep fontsize side bar with sphinx_rtd_theme

35 views
Skip to first unread message

Ruud van der Ham

unread,
Apr 3, 2023, 4:51:47 AM4/3/23
to sphinx-users
I have a sphinx HTML (www.salabim.org/manual) that has a 4-level deep reference section.
Unfortunately, the font of the text in the sidebar is very small. Is it possible to customise the font size? How?

Here's a demonstration of the 'problem':
2023-04-03 10_42_00-Reference — salabim 23.1.3 documentation.png

Steevie

unread,
Apr 3, 2023, 8:54:23 AM4/3/23
to sphinx...@googlegroups.com
On Mon, 3 Apr 2023 01:51:46 -0700 (PDT), Ruud van der Ham wrote:

> I have a sphinx HTML (www.salabim.org/manual) that has a 4-level deep
> reference section.
> Unfortunately, the font of the text in the sidebar is very small. Is it
> possible to customise the font size? How?
You can use the Web developers tools integrated in the browser to check
which is the CSS selector associated with the fourth level, then override
it with one saved in a custom file. You should add this file to the
html_css_files [1] variable in conf.py.

HTH,
Stefano

[1] https://www.sphinx-doc.org/en/master/usage/configuration.html#confval-
html_css_files


Ruud van der Ham

unread,
Apr 3, 2023, 11:29:12 AM4/3/23
to sphinx-users
@Stefano David
Thanks for the link to the configuration items.
Unfortunately, I can't work out from there how to change the font of the fourth level in the sidebar. Maybe it's just my lack of understanding.
Could you (or someone else) provide instructions on how to make the fourth level in the sode bar bigger?
That would be most helpful.

Ruud van der Ham

unread,
Apr 6, 2023, 2:19:25 PM4/6/23
to sphinx-users
With the help of Christopher Trudeau (Real Python], I have found that when I patch css/themes.css 
    .toctree-l4{font-size:0.9em} 
to
    .toctree-l4{font-size:1.0em}
I have much better readable level 4 side bar.

Steevie

unread,
Apr 12, 2023, 2:11:10 AM4/12/23
to sphinx...@googlegroups.com
Hello Ruud,
sorry for getting back to you so late,

On Thu, 6 Apr 2023 11:19:24 -0700 (PDT), Ruud van der Ham wrote:

> With the help of Christopher Trudeau (Real Python], I have found that
> when I patch css/themes.css
> .toctree-l4{font-size:0.9em}
> to
> .toctree-l4{font-size:1.0em}
> I have much better readable level 4 side bar.
I'm glad you find a solution, but please note that when you will upgrade
the sphinx_rtd_theme extension, your patch will be lost. I suggest to save
all your CSS customisations in a file under your source tree and then add
the file path to your conf.py's variable html_css_files. In this way, your
customisation will remain even after you update, because CSS in your file
will always override the theme's CSS.

You can check [1] for directions on how to set this up.

https://docs.readthedocs.io/en/stable/guides/adding-custom-css.html

HTH,
Stefano


Reply all
Reply to author
Forward
0 new messages