制作pdf时如何强制狮身人面像结束一章?

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

我正在使用狮身人面像(托管在https://readthedocs.org上)生成HTML和PDF格式的文档。 HTML可以正常工作。 PDF也可以成功构建,但是存在嵌套问题:我希望从目录中链接的每个顶级.rst文档都作为顶级“章节”包含在PDF中。但是,它们实际上是作为小节包含的,从属于首页index.rst的内容。这是我的index.rst中的内容:

====
Blah
====

Welcome to the Blah project. It does various things.


Quickstart
==========

To download and install the Python package:
-------------------------------------------

* `python -m pip install Blah`


To run the demo:
----------------

* `python -m Blah --demo`


.. NEED SOME DIRECTIVE HERE
   to tell sphinx/latex that Installation, BasicUsage
   and friends are NOT subsections of "To run the demo"
   but rather chapters at the same level as "Quickstart".


.. toctree::
   :caption: Table of Contents
   :maxdepth: 2

   Installation
   BasicUsage
   AdvancedUsage
   License


Indices and Tables
==================

* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`

...此屏幕截图显示了我从PDF中获得的内容:

pdf screenshot showing overly nested nesting

...我想将“如何安装Blah”作为第2章,将“基本用法”作为第3章,依此类推。 (HTML看起来井井有条:将登录页面分为三个部分,分别为Quickstart,<< Contents>,<< Indices and Tables>。)]]我的search-foo未能使我在创建PDF的过程中告诉狮身人面像的任何方法,“在这里上升了两个层次”或“在这里结束了本章”(请参见上面的index.rst列表)。这实际上可行吗? 章节文件之一Installation.rst的内容如下:

How to Install Blah =================== It's on pypi.org so just use `pip`.

其他文件BasicUsage.rstAdvancedUsage.rstLicense.rst既可以出于示例目的而从目录中删除,也可以采用相同的方式构造:带有=下划线标题的单线(下划线与上面的“快速入门”相同)。

我正在使用托管在https://readthedocs.org上的sphinx,以生成HTML和PDF格式的文档。 HTML可以正常工作。 PDF也可以成功构建,但是存在嵌套问题:I ...

一个答案,或更确切地说,一种解决方法,似乎是完全避免在目录之前使用任何标题(顶级主标题“ Blah”除外)。然后,toc条目将作为章节包括在内。在乳胶版本中,“快速入门”可以变成自己的一章,包括在目录中。 (要使html版本和乳胶版本彼此不同,如@StevePiercy在注释中所建议,请在latex_documentsconf.py参数中为乳胶模式配置一个不同的索引文件。)
python-sphinx restructuredtext pdflatex read-the-docs latexmk
1个回答
0
投票
© www.soinside.com 2019 - 2024. All rights reserved.