如何在 reStructuredText 中的定义列表中使用强制换行符呈现 LaTeX/PDF
How to render LaTeX/PDF with a forced line break on a definition list in reStructuredText
我想在带有适当换行符的 reStructuredText 中呈现 pdf 文件,这样:
Keyword
Definition
使用阅读文档模板可以正确呈现,但在使用默认设置和 make latexpdf
时不会产生换行符。对于这个问题,我可以将一个简单的函数应用于 conf.py
中的 LaTeX 输出选项吗?
注意:我已经在 TeX 上提交了这个问题,并被告知尝试 Stack Overflow。上面的代码片段应该是重现我的用例所需的最短代码。正如我所说,据我所知,这些是默认设置。我没有做任何重大改变。在 定义列表 上缺少换行符似乎是 LaTeX pdf 文件的预期输出。
这是我所知的部分答案。我希望它能让你走得更远。
默认情况下,转换会对术语应用粗体样式,并且术语的定义与术语内联,并在后续行中换行并缩进。请参阅下面的屏幕截图,了解 Pyramid 文档的 PDF 输出示例。
当您执行 make latexpdf
时,您会连续调用两个处理器,将 reST 文件转换为 LaTeX 文件,然后 运行 这些文件通过 pdflatex
生成 PDF。
第一步 pyramid.tex
中的第一个词汇表条目显示如下:
\item[{ACE\index{ACE|textbf}}] \leavevmode\phantomsection\label{\detokenize{glossary:term-ace}}
An \sphinxstyleemphasis{access control entry}. An access control entry is one element
in an {\hyperref[\detokenize{glossary:term-acl}]{\sphinxtermref{ACL}}}. An access control entry is a three-tuple that
describes three things: an \sphinxstyleemphasis{action} (one of either \sphinxcode{Allow} or
\sphinxcode{Deny}), a {\hyperref[\detokenize{glossary:term-principal}]{\sphinxtermref{principal}}} (a string describing a user or
group), and a {\hyperref[\detokenize{glossary:term-permission}]{\sphinxtermref{permission}}}. For example the ACE, \sphinxcode{(Allow,
'bob', 'read')} is a member of an ACL that indicates that the
principal \sphinxcode{bob} is allowed the permission \sphinxcode{read} against the
resource the ACL is attached to.
现在的问题归结为如何更改该输出,以便可以根据需要设置样式。为此,您需要解析 LaTeX customization 上的 Sphinx 文档。我不知道该怎么做。
使用 rinohtype PDF builder for Sphinx allows for fine control of style aspects such as these. The default style sheet actually inserts line breaks between a keyword and its definition in definition lists. Otherwise the style of the produced PDF is very similar to the output of the LaTeX builder. You can create your own style sheet and template configuration 根据您的需要自定义 PDF 的外观。
(全面披露:我是 rinohtype 的作者)
您可以通过替换注入原始 LaTeX 代码来实现。
Keyword
|br| Definition
Keyword2
|br| Long definition long definition long definition long definition long
definition long definition long definition long definition long definition
long definition long definition long definition long definition long
definition long definition long definition long definition long definition
long definition long definition long definition long definition long
definition long definition long definition
.. |br| raw:: latex
\mbox{}\newline
生成 PDF 格式:
请注意,原始 LaTeX 代码不会注入其他目标,只会注入 latexpdf 目标。
我想在带有适当换行符的 reStructuredText 中呈现 pdf 文件,这样:
Keyword
Definition
使用阅读文档模板可以正确呈现,但在使用默认设置和 make latexpdf
时不会产生换行符。对于这个问题,我可以将一个简单的函数应用于 conf.py
中的 LaTeX 输出选项吗?
注意:我已经在 TeX 上提交了这个问题,并被告知尝试 Stack Overflow。上面的代码片段应该是重现我的用例所需的最短代码。正如我所说,据我所知,这些是默认设置。我没有做任何重大改变。在 定义列表 上缺少换行符似乎是 LaTeX pdf 文件的预期输出。
这是我所知的部分答案。我希望它能让你走得更远。
默认情况下,转换会对术语应用粗体样式,并且术语的定义与术语内联,并在后续行中换行并缩进。请参阅下面的屏幕截图,了解 Pyramid 文档的 PDF 输出示例。
当您执行 make latexpdf
时,您会连续调用两个处理器,将 reST 文件转换为 LaTeX 文件,然后 运行 这些文件通过 pdflatex
生成 PDF。
第一步 pyramid.tex
中的第一个词汇表条目显示如下:
\item[{ACE\index{ACE|textbf}}] \leavevmode\phantomsection\label{\detokenize{glossary:term-ace}}
An \sphinxstyleemphasis{access control entry}. An access control entry is one element
in an {\hyperref[\detokenize{glossary:term-acl}]{\sphinxtermref{ACL}}}. An access control entry is a three-tuple that
describes three things: an \sphinxstyleemphasis{action} (one of either \sphinxcode{Allow} or
\sphinxcode{Deny}), a {\hyperref[\detokenize{glossary:term-principal}]{\sphinxtermref{principal}}} (a string describing a user or
group), and a {\hyperref[\detokenize{glossary:term-permission}]{\sphinxtermref{permission}}}. For example the ACE, \sphinxcode{(Allow,
'bob', 'read')} is a member of an ACL that indicates that the
principal \sphinxcode{bob} is allowed the permission \sphinxcode{read} against the
resource the ACL is attached to.
现在的问题归结为如何更改该输出,以便可以根据需要设置样式。为此,您需要解析 LaTeX customization 上的 Sphinx 文档。我不知道该怎么做。
使用 rinohtype PDF builder for Sphinx allows for fine control of style aspects such as these. The default style sheet actually inserts line breaks between a keyword and its definition in definition lists. Otherwise the style of the produced PDF is very similar to the output of the LaTeX builder. You can create your own style sheet and template configuration 根据您的需要自定义 PDF 的外观。
(全面披露:我是 rinohtype 的作者)
您可以通过替换注入原始 LaTeX 代码来实现。
Keyword
|br| Definition
Keyword2
|br| Long definition long definition long definition long definition long
definition long definition long definition long definition long definition
long definition long definition long definition long definition long
definition long definition long definition long definition long definition
long definition long definition long definition long definition long
definition long definition long definition
.. |br| raw:: latex
\mbox{}\newline
生成 PDF 格式:
请注意,原始 LaTeX 代码不会注入其他目标,只会注入 latexpdf 目标。