I would like to include a code block in a presentation I am preparing with Restructured Text. But the font used in the code block is huge and it can not fit inside resulting code box:
How can I reduce the font size used in code blocks?
I would like to include a code block in a presentation I am preparing with Restructured Text. But the font used in the code block is huge and it can not fit inside resulting code box:
How can I reduce the font size used in code blocks?
On
Set the fontSize property of the code style in your style file.
e.g.
code:
parent: literal
fontSize: 10
On
Some of the builtin themes (alabaster) accept usage of custom.css.
Create _static/custom.css and add the following to adjust the code-block font-size:
_static/custom.css:
.highlight { background: #f8f8f8; font-size: x-small;}
On
First, create a file called style_code_font_size.yaml in your docs root with this content:
styles:
code:
parent: literal
fontSize: 8
If you are using Sphinx, prepend this new style to pdf_stylesheets in conf.py:
pdf_stylesheets = ["twocolumn", "sphinx"]
pdf_stylesheets = ["style_code_font_size", "twocolumn", "sphinx"]
You need a layout.html in a dir
mysources/_templatesand in yourmysources/conf.pyyou need a declarationtemplates_path = ['_templates'].In layout.html add a declaration
This works for me because I use the html_theme sphinxdoc. Maybe in other themes the declarations differ. If so you must find out the declaration by a html debugger like Inspektor in Firefox or Developer Tools in Chrome or DOM Explorer in IE.