sphinx-doc / sphinx-doc/sphinx

The LaTeX builder doesn't handle multiple toctrees with captions well

Open
#4,977 8 comments 7 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

builder:latex internals:toctree type:proposal
Dominant language
Python
Stars
8k
Forks
2.6k
PR merge metrics
No merged PRs in 30d

Description

Problem

The HTML builder has good support for multiple separate toctrees with captions, like this:

.. toctree::
   :caption: AAA

   A1
   A2

.. toctree::
   :caption: BBB

   B1
   B2

In Alabaster it's rendered like this:

AAA

  A1
  A2

BBB
  
  B1
  B2

And in the RTD theme A1 and A2 are grouped in the table of contents:

toctrees

The LaTeX builder, on the other hand, gets confused when presented with the same input:

toctrees-latex

Procedure to reproduce the problem
mkdir /tmp/sphinx-repro
cd /tmp/sphinx-repro
sphinx-quickstart --quiet --author x --project y
for i in {A,B}{1,2}; do printf "$i\n==" > "$i.rst"; done
cat > index.rst <<< '.. toctree::
   :caption: AAA

   A1
   A2

.. toctree::
   :caption: BBB

   B1
   B2
'
make latexpdf
Expected results

The table of contents should be split into two parts in LaTeX like in HTML

Environment info
  • OS: GNU/Linux
  • Python version: 3.5.2
  • Sphinx version: 1.7.1

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the problem with the provided sphinx-quickstart and make latexpdf commands, then trace the LaTeX builder's handling of multiple captioned toctrees. Compare its output with the expected HTML-style split and add coverage for the two toctrees so completion can be verified.

Written by the indexing model from the issue text.

Assessment

Tech stack
latex, python
Domain
build-system, documentation
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.