Skip to content

Commit

Permalink
DOC: remove old LaTeX hack if Sphinx is at 5.0.0 or later (fix #22941) (
Browse files Browse the repository at this point in the history
#22952)

This removes an old LaTeX hack if Sphinx is at 5.0.0+. The hack served to insert a newline after each parameter name before its description and is unneeded as Sphinx 5+ does it (otherwise) and it now causes extra vertical whitespace.

If one day in future NumPy pins Sphinx to be at least 5.0.0, the whole thing will become removable.

Closes #22941

EDIT: this also removes \usepackage{xcolor}. Sphinx for many many years uses xcolor if it is available.
  • Loading branch information
jfbu committed Jan 6, 2023
1 parent bdead0e commit 890920e
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions doc/source/conf.py
Expand Up @@ -253,26 +253,31 @@ def setup(app):
# Additional stuff for the LaTeX preamble.
latex_elements['preamble'] = r'''
% In the parameters section, place a newline after the Parameters
% header
\usepackage{xcolor}
% header. This is default with Sphinx 5.0.0+, so no need for
% the old hack then.
% Unfortunately sphinx.sty 5.0.0 did not bump its version date
% so we check rather sphinxpackagefootnote.sty (which exists
% since Sphinx 4.0.0).
\makeatletter
\@ifpackagelater{sphinxpackagefootnote}{2022/02/12}
{}% Sphinx >= 5.0.0, nothing to do
{%
\usepackage{expdlist}
\let\latexdescription=\description
\def\description{\latexdescription{}{} \breaklabel}
% but expdlist old LaTeX package requires fixes:
% 1) remove extra space
\usepackage{etoolbox}
\makeatletter
\patchcmd\@item{{\@breaklabel} }{{\@breaklabel}}{}{}
\makeatother
% 2) fix bug in expdlist's way of breaking the line after long item label
\makeatletter
\def\breaklabel{%
\def\@breaklabel{%
\leavevmode\par
% now a hack because Sphinx inserts \leavevmode after term node
\def\leavevmode{\def\leavevmode{\unhbox\voidb@x}}%
}%
}
}% Sphinx < 5.0.0 (and assumed >= 4.0.0)
\makeatother
% Make Examples/etc section headers smaller and more compact
Expand Down

0 comments on commit 890920e

Please sign in to comment.