5

I have a sphinx documentation project that I use to generate an HTML (make html) and a PDF (make latexpdf) version of the documentation. I use subdirectories to organize some of the pages. My directory structure is something like this:

source/
    index.rst
    page1.rst
    subsection1/
        index.rst
        subpage1.rst

I have a toctree specified in both index.rst files:

# index.rst
.. toctree::

    page1
    subsection1/index

# subsection1/index.rst
.. toctree::

    subpage1

When I generate the HTML the subsection1/index page has the TOC list with links to the appropriate pages. When I generate the latex PDF it ignores the sub-toctrees and doesn't print anything, but I would like it to be the same as the HTML.

I don't have a lot of experience with latex and I'm having trouble finding anything online about this so I feel like I'm missing something obvious. I've looked in to .. contents:: and .. include:: but of course this doesn't produce what I want with HTML and I was hoping I wouldn't have to have a ton of .. only:: parts.

bad_coder
  • 11,289
  • 20
  • 44
  • 72
djhoese
  • 3,567
  • 1
  • 27
  • 45
  • 18 months later this is still impossible. Conditional `.. only:: latex` `.. include:: Subsubsection.rst` and `.. only:: not latex` `.. toctree::` `Subsubsection` will leave you with an unusable `:ref:` directive as Sphinx is not smart enough to figure out that `.. _Subsubsection:` is effectively contained only once. – Max May 18 '18 at 19:47

0 Answers0