RST:如何减小代码块中的字体大小?

问题描述 投票:0回答:4

我想在我正在使用重构文本准备的演示文稿中包含一个代码块。但是代码块中使用的字体很大,无法放入生成的代码框中:

如何减小代码块中使用的字体大小?

python python-3.x restructuredtext rst2pdf
4个回答
1
投票

在样式文件中设置

fontSize
样式的
code
属性。

例如

code:
    parent: literal
    fontSize: 10

1
投票

一些内置主题 (alabaster) 接受使用

custom.css

创建

_static/custom.css
并添加以下内容来调整
code-block
字体大小:

_static/custom.css

.highlight { background: #f8f8f8; font-size: x-small;}

0
投票

您需要在目录

mysources/_templates
中放置一个layout.html,并且在您的
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)找出声明。


0
投票

首先,在文档根目录中创建一个名为

style_code_font_size.yaml
的文件,其中包含以下内容:

styles:
    code:
        parent: literal
        fontSize: 8

如果您使用的是 Sphinx,请将此新样式添加到

pdf_stylesheets
中的
conf.py

pdf_stylesheets = ["twocolumn", "sphinx"]
pdf_stylesheets = ["style_code_font_size", "twocolumn", "sphinx"]
© www.soinside.com 2019 - 2024. All rights reserved.