@@ -308,29 +308,83 @@ def _check_dependencies():
308
308
latex_logo = None
309
309
310
310
latex_elements = {}
311
+
312
+ latex_engine = 'xelatex' # many Unicode glyphs in our docs...
313
+ # By default Sphinx with latex_engine = 'xelatex' uses polyglossia
314
+ # If this key is changed, clean the build/latex directory before next build
315
+ latex_elements ['babel' ] = r'\usepackage{babel}'
316
+
311
317
# Additional stuff for the LaTeX preamble.
312
- latex_elements ['preamble' ] = r"""
313
- % In the parameters section, place a newline after the Parameters
314
- % header. (This is stolen directly from Numpy's conf.py, since it
315
- % affects Numpy-style docstrings).
316
- \usepackage{expdlist}
317
- \let\latexdescription=\description
318
- \def\description{\latexdescription{}{} \breaklabel}
319
-
320
- \usepackage{amsmath}
321
- \usepackage{amsfonts}
322
- \usepackage{amssymb}
323
- \usepackage{txfonts}
324
-
325
- % The enumitem package provides unlimited nesting of lists and
326
- % enums. Sphinx may use this in the future, in which case this can
327
- % be removed. See
328
- % https://bitbucket.org/birkenfeld/sphinx/issue/777/latex-output-too-deeply-nested
329
- \usepackage{enumitem}
330
- \setlistdepth{2048}
331
- """
318
+
319
+ # Usage of expdlist package (as originally copied over from Numpy's confpy)
320
+ # is removed because it breaks the PDF build with recent LaTeX:
321
+ # ! Extra }, or forgotten \endgroup.
322
+ # \@endpbox ...\@arstrutbox \color@endgroup \egroup
323
+ # The https://github.com/scipy/scipy/pull/8657 code would actually fix this
324
+ #
325
+ # latex_elements['preamble'] = r"""
326
+ # % In the parameters section, place a newline after the Parameters
327
+ # % header. (This is stolen directly from Numpy's conf.py, since it
328
+ # % affects Numpy-style docstrings).
329
+ # \usepackage{expdlist}
330
+ # \let\latexdescription=\description
331
+ # \def\description{\latexdescription{}{} \breaklabel}
332
+ # """
333
+
332
334
latex_elements ['pointsize' ] = '11pt'
333
335
336
+ # Fix fancyhdr complaining about \headheight too small
337
+ latex_elements ['passoptionstopackages' ] = r"""
338
+ \PassOptionsToPackage{headheight=14pt}{geometry}
339
+ """
340
+
341
+ # Sphinx 1.5 provides this to avoid "too deeply nested" LaTeX error
342
+ # and usage of "enumitem" LaTeX package is unneeded.
343
+ # Value can be increased but do not set it to something such as 2048
344
+ # which needlessly would trigger creation of thousands of TeX macros
345
+ latex_elements ['maxlistdepth' ] = '10'
346
+
347
+ # Use OpenType font with wide-enough glyph coverage
348
+ # Sphinx 2.0 adopts GNU FreeFont by default, but it does not have all
349
+ # the Unicode codepoints needed for the section about Mathtext
350
+ # "Writing mathematical expressions"
351
+ latex_elements ['fontpkg' ] = r"""
352
+ \setmainfont{XITS}[
353
+ Extension = .otf,
354
+ UprightFont = *-Regular,
355
+ ItalicFont = *-Italic,
356
+ BoldFont = *-Bold,
357
+ BoldItalicFont = *-BoldItalic,
358
+ ]
359
+ \setsansfont{FreeSans}[
360
+ Extension = .otf,
361
+ UprightFont = *,
362
+ ItalicFont = *Oblique,
363
+ BoldFont = *Bold,
364
+ BoldItalicFont = *BoldOblique,
365
+ ]
366
+ \setmonofont{FreeMono}[
367
+ Extension = .otf,
368
+ UprightFont = *,
369
+ ItalicFont = *Oblique,
370
+ BoldFont = *Bold,
371
+ BoldItalicFont = *BoldOblique,
372
+ ]
373
+ % \usepackage{unicode-math}
374
+ % \setmathfont{XITS Math}
375
+ """
376
+ # Last two lines commented out because only there to fix missing glyphs from
377
+ # one \mathbb{blackboard}, and anyhow the whole section about Mathtext Fonts
378
+ # is broken as it would need extra LaTeX raw directives to actually switch
379
+ # math fonts from main one and illustrate the "five global font sets". For
380
+ # this one must define math versions in the LaTeX preamble and it is all quite
381
+ # cumbersome.
382
+
383
+ # Sphinx <1.8.0 or >=2.0.0 does this by default, but the 1.8.x series
384
+ # did not for latex_engine = 'xelatex' (used Latin Modern font).
385
+ # We need it as FreeMono has wide character glyphs.
386
+ latex_elements ['fvset' ] = r'\fvset{fontsize=\small}'
387
+
334
388
# Documents to append as an appendix to all manuals.
335
389
latex_appendices = []
336
390
@@ -358,13 +412,6 @@ def _check_dependencies():
358
412
359
413
numpydoc_show_class_members = False
360
414
361
- latex_engine = 'xelatex' # or 'lualatex'
362
-
363
- latex_elements = {
364
- 'babel' : r'\usepackage{babel}' ,
365
- 'fontpkg' : r'\setmainfont{DejaVu Serif}' ,
366
- }
367
-
368
415
html4_writer = True
369
416
370
417
inheritance_node_attrs = dict (fontsize = 16 )
0 commit comments