From c7c05d35d9dcbce0c45a5c75db4f85784d687628 Mon Sep 17 00:00:00 2001 From: jfbu Date: Thu, 5 Dec 2019 10:00:27 +0100 Subject: [PATCH 1/3] Closes #15796: latex_elements defined twice in doc/conf.py This commit reactivates original latex_elements['preamble'] key which was shadowed by the bug about latex_elements being defined twice in the conf.py. It removes from this latex preamble the loading of amsmath, amssymb, amsfonts as this is already added by Sphinx, and of txfonts because this is not compatible with fontspec and the already executed command \setmainfont{DejaVu Serif}. Memo: expdlist package breaks PDF build if a description list ends up in a table cell, as happens actually with Matplotlib.tex file. But, by luck, the enumitem LaTeX package modifications of LaTeX description lists masks the expdlist potential breakage. --- doc/conf.py | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/doc/conf.py b/doc/conf.py index 00eca945f82d..768dbd75700e 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -320,7 +320,19 @@ def _check_dependencies(): # the title page. latex_logo = None +# Use Unicode aware LaTeX engine +latex_engine = 'xelatex' # or 'lualatex' + latex_elements = {} + +# Keep babel usage also with xelatex (Sphinx default is polyglossia) +# If this key is removed or changed, latex build directory must be cleaned +latex_elements['babel'] = r'\usepackage{babel}' + +# Font configuration +# Sphinx default since 2.x is GNU FreeFont +latex_elements['fontpkg'] = r'\setmainfont{DejaVu Serif}' + # Additional stuff for the LaTeX preamble. latex_elements['preamble'] = r""" % One line per author on title page @@ -333,11 +345,6 @@ def _check_dependencies(): \let\latexdescription=\description \def\description{\latexdescription{}{} \breaklabel} - \usepackage{amsmath} - \usepackage{amsfonts} - \usepackage{amssymb} - \usepackage{txfonts} - % The enumitem package provides unlimited nesting of lists and % enums. Sphinx may use this in the future, in which case this can % be removed. See @@ -371,13 +378,6 @@ def _check_dependencies(): numpydoc_show_class_members = False -latex_engine = 'xelatex' # or 'lualatex' - -latex_elements = { - 'babel': r'\usepackage{babel}', - 'fontpkg': r'\setmainfont{DejaVu Serif}', -} - html4_writer = True inheritance_node_attrs = dict(fontsize=16) From 25ce38c53a8b14c003d51de20b661b748ad2d99e Mon Sep 17 00:00:00 2001 From: jfbu Date: Thu, 5 Dec 2019 10:19:06 +0100 Subject: [PATCH 2/3] LaTeX: resolve "Too deeply nested" error without enumitem package But removing enumitem package reveals a bug in expdlist. Import the fix from the SciPy and NumPy projects. https://github.com/numpy/numpy/pull/15028 https://github.com/scipy/scipy/commit/c881fdea7a7ef7c518b7898cfd53b2880af06778 --- doc/conf.py | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/doc/conf.py b/doc/conf.py index 768dbd75700e..174c8935761b 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -338,20 +338,31 @@ def _check_dependencies(): % One line per author on title page \DeclareRobustCommand{\and}% {\end{tabular}\kern-\tabcolsep\\\begin{tabular}[t]{c}}% - % In the parameters section, place a newline after the Parameters - % header. (This is stolen directly from Numpy's conf.py, since it - % affects Numpy-style docstrings). \usepackage{expdlist} \let\latexdescription=\description \def\description{\latexdescription{}{} \breaklabel} - - % The enumitem package provides unlimited nesting of lists and - % enums. Sphinx may use this in the future, in which case this can - % be removed. See - % https://bitbucket.org/birkenfeld/sphinx/issue/777/latex-output-too-deeply-nested - \usepackage{enumitem} - \setlistdepth{2048} + % 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}}% + }% + } + \makeatother """ +# Sphinx 1.5 provides this to avoid "too deeply nested" LaTeX error +# and usage of "enumitem" LaTeX package is unneeded. +# Value can be increased but do not set it to something such as 2048 +# which needlessly would trigger creation of thousands of TeX macros +latex_elements['maxlistdepth'] = '10' latex_elements['pointsize'] = '11pt' # Documents to append as an appendix to all manuals. From 8d5a575337a7752343de175f1f53cc6c7e53d69d Mon Sep 17 00:00:00 2001 From: Elliott Sales de Andrade Date: Fri, 13 Nov 2020 00:35:56 -0500 Subject: [PATCH 3/3] Add missing dimension in genfrac LaTeX example. This appears unnecessary in mathtext, but LaTeX requires the dimension. --- tutorials/text/mathtext.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tutorials/text/mathtext.py b/tutorials/text/mathtext.py index 709f1df4956b..655ceec6bbf1 100644 --- a/tutorials/text/mathtext.py +++ b/tutorials/text/mathtext.py @@ -97,7 +97,7 @@ .. math:: - \frac{3}{4} \binom{3}{4} \genfrac{}{}{0}{}{3}{4} + \frac{3}{4} \binom{3}{4} \genfrac{}{}{0pt}{}{3}{4} Fractions can be arbitrarily nested::