将段落中心与RestructuredText对齐的最佳方法是什么?

psi*_*sic 5 restructuredtext alignment

使用restructuredText for pdf(rst2pdf)在页面中心对齐段落的最佳方法是什么?

Rob*_*ina 6

您可以使用以下内容:

.. class:: center

This paragraph will be centered.
Run Code Online (Sandbox Code Playgroud)


Ahm*_*fan 5

如果您想在 rst2html.py (Docutils 0.12) 上使用 center 标记(如上所述),您应该创建一个 css 文件,即 mystyle.css,添加以下行:

.center {text-align: center;}
Run Code Online (Sandbox Code Playgroud)

要将您的 rst 文件,即 myrst.rst 转换为 html 文件,请使用以下命令

rst2html myrst.rst myrst.html --stylesheet=mystyle.css,html4css1.css
Run Code Online (Sandbox Code Playgroud)

通过使用这种方法,下面的代码运行良好。

.. class:: center

This paragraph will be centered.
Run Code Online (Sandbox Code Playgroud)