我想在使用重组文本准备的演示文稿中包含一个代码块。但是代码块中使用的字体很大,无法放入生成的代码框内:
如何减小代码块中使用的字体大小?
一些内置主题(雪花石膏)接受custom.css
.
创建_static/custom.css
并添加以下内容以调整code-block
字体大小:
_static/custom.css:
.highlight { background: #f8f8f8; font-size: x-small;}
在样式文件中设置样式的fontSize
属性。code
例如
code:
parent: literal
fontSize: 10
你需要一个 layout.html 在一个目录mysources/_templates
中,mysources/conf.py
你需要一个声明templates_path = ['_templates']
。
在 layout.html 添加声明
div.highlight {
font-size : 0.8em; /* or another value you prefer */
}
这对我有用,因为我使用 html_theme sphinxdoc。也许在其他主题中,声明有所不同。如果是这样,您必须通过 html 调试器(如Firefox 中的Inspektor或 Chrome 中的开发者工具或 IE 中的 DOM Explorer)找到声明。