如何在 reStructuredText 中创建 PDF?
文档 uncertainties Python 包 是用 reStructuredText 编写的,用于 Sphinx 文档系统。 HTML 看起来不错。我想创建一个 PDF 版本。目标是每个网页都有一个“章节”。
然而,发生的情况是 ReST 文件 生成的 PDF 转换了 (HTML )将 index.html
的部分分成单独的章节(我不希望这样:PDF也应该将它们作为部分)。另一个问题是,主页之后的所有 HTML 页面都作为 toctree
指令出现的部分(即主页的致谢部分)的子部分出现在 PDF 中。
那么,应该如何构建 ReST 文件,以便 (1) Web 文档看起来与现在相同,(2)每个网页对应一个PDF章节。任何帮助将不胜感激!
The documentation for the uncertainties Python package is written in reStructuredText, for the Sphinx documentation system. The HTML looks fine. I would like to create a PDF version. The goal is to have a "chapter" for each of the web page.
However, what happens is that the PDF generated by the ReST files transforms the (HTML) sections of index.html
into individual chapters (which I don't want: the PDF should have them as sections too). Another problem is that all HTML pages after the main page appear in the PDF as subsections of the section where the toctree
directive appears (i.e., in the Acknowledgment section of the main page).
So, how should the ReST file be structured so that (1) the web documents look the same as they are now, and (2) each web page corresponds to a PDF chapter. Any help would be much appreciated!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
有一个解决方案。如果我没记错的话,关键点是:
index_TOC.rst
而不是默认的index.rst
):conf.py
master_doc = 'index_TOC'
latex_documents = [('index_TOC', 'uncertaintiesPythonpackage.tex',…]
新的目录文件
index_TOC.rst
包含一个目录,例如<前><代码>目录
===
.. 目录树::
:隐:
:最大深度:1
指数
用户指南
numpy_指南
技术指南
,因此,网络版本仍然会打开主要的
index.rst
文本, PDF (LaTeX) 版本的每个 ReST 文件都位于单独的章节中。There is a solution. If I remember correctly, the key points were:
index_TOC.rst
instead of the defaultindex.rst
): inconf.py
master_doc = 'index_TOC'
latex_documents = [('index_TOC', 'uncertaintiesPythonpackage.tex',…]
The new Table of Contents file
index_TOC.rst
contains a ToC likeThus, the web version still opens onto the main
index.rst
text, and the PDF (LaTeX) version has each ReST file in a separate chapter.