sphinx-doc / sphinx-doc/sphinx

Traditional vanilla LaTeX style

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

Nobody has claimed this yet.

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

Description

I would like to convert my Sphinx documentation into traditional LaTeX book. This is really painful because Sphinx redefines almost everything and does it by small hacks everywhere.

For example if I simply want to use \fancyhdr with a \frontmatter section. I have to redefine \sphinxtableofcontents to remove the small hacks that change the page numbering:

\makeatletter
\renewcommand{\sphinxtableofcontents}{%
  %\pagenumbering{roman}% <-- Not wanted
  \begingroup
    \parskip \z@skip
    \sphinxtableofcontentshook
    \tableofcontents
  \endgroup
  % before resetting page counter, let's do the right thing.
  \if@openright\cleardoublepage\else\clearpage\fi
  %\pagenumbering{arabic}% <-- Not wanted
}
\makeatother

To get normal sections styles I have to copy sphinx.sty locally in my _templates and remove the following to get rid of the (ugly) \Large that shouldn't be there, or at list be configurable otherwise :

% Augment the sectioning commands used to get our own font family in place,
% and reset some internal data items (\titleformat from titlesec package)
\titleformat{\section}{\Large\py@HeaderFamily}%
            {\py@TitleColor\thesection}{0.5em}{\py@TitleColor}{\py@NormalColor}
\titleformat{\subsection}{\large\py@HeaderFamily}%
            {\py@TitleColor\thesubsection}{0.5em}{\py@TitleColor}{\py@NormalColor}
\titleformat{\subsubsection}{\py@HeaderFamily}%
            {\py@TitleColor\thesubsubsection}{0.5em}{\py@TitleColor}{\py@NormalColor}
% By default paragraphs (and subsubsections) will not be numbered because
% sphinxmanual.cls and sphinxhowto.cls set secnumdepth to 2
\titleformat{\paragraph}{\py@HeaderFamily}%
            {\py@TitleColor\theparagraph}{0.5em}{\py@TitleColor}{\py@NormalColor}
\titleformat{\subparagraph}{\py@HeaderFamily}%
            {\py@TitleColor\thesubparagraph}{0.5em}{\py@TitleColor}{\py@NormalColor}

The headers and footers have also to be redefined to remove the unwanted \py@HeaderFamily\nouppercase.

IMHO generating LaTeX is to get beautful LaTeX documents otherwise it doesn't worth it.

Instead of spending a lot of time reverting what Sphinx does on LaTeX I suggest a feature/option/command to use vanilla LaTeX templates which can be either : article or book.

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

Start by tracing the LaTeX builder and the generated sphinx.sty, including the sphinxmanual.cls and sphinxhowto.cls paths referenced in the issue. Compare the current sectioning, page numbering, headers, and footers with the proposed article or book templates. Done means users can select a vanilla LaTeX template without locally copying and overriding Sphinx style definitions.

Written by the indexing model from the issue text.

Assessment

Tech stack
latex
Domain
documentation
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.