Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 53d4170

Browse files
jfbuQuLogic
authored andcommitted
LaTeX: use XITS and XITS Math for wide enough Unicode coverage
XITS has all the Unicode mathematical symbols glyphs needed for the section of the documentation related to Mathtext. (DejaVu Serif was missing 134 of them, and GNU FreeFont 19 of them) XITS Math (and unicode-math) is needed for \mathbb supporting letters b, c, d, there is one \mathbb{blackboard} once in the documentation. It also gives better calligraphy font. The Ubuntu package texlive-fonts-extra provides these latex dependencies.
1 parent 2b212a0 commit 53d4170

1 file changed

Lines changed: 37 additions & 2 deletions

File tree

doc/conf.py

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -352,8 +352,43 @@ def _check_dependencies():
352352
latex_elements['babel'] = r'\usepackage{babel}'
353353

354354
# Font configuration
355-
# Sphinx default since 2.x is GNU FreeFont
356-
latex_elements['fontpkg'] = r'\setmainfont{DejaVu Serif}'
355+
# Sphinx 2.0 adopts GNU FreeFont by default, but it does not have all
356+
# the Unicode codepoints needed for the section about Mathtext
357+
# "Writing mathematical expressions"
358+
latex_elements['fontpkg'] = r"""
359+
\setmainfont{XITS}[
360+
Extension = .otf,
361+
UprightFont = *-Regular,
362+
ItalicFont = *-Italic,
363+
BoldFont = *-Bold,
364+
BoldItalicFont = *-BoldItalic,
365+
]
366+
\setsansfont{FreeSans}[
367+
Extension = .otf,
368+
UprightFont = *,
369+
ItalicFont = *Oblique,
370+
BoldFont = *Bold,
371+
BoldItalicFont = *BoldOblique,
372+
]
373+
\setmonofont{FreeMono}[
374+
Extension = .otf,
375+
UprightFont = *,
376+
ItalicFont = *Oblique,
377+
BoldFont = *Bold,
378+
BoldItalicFont = *BoldOblique,
379+
]
380+
% needed for \mathbb (blackboard alphabet) to actually work
381+
\usepackage{unicode-math}
382+
\setmathfont{XITS Math}
383+
"""
384+
# Sphinx <1.8.0 or >=2.0.0 does this by default, but the 1.8.x series
385+
# did not for latex_engine = 'xelatex' (as it used Latin Modern font).
386+
# We need this for code-blocks as FreeMono has wide glyphs.
387+
latex_elements['fvset'] = r'\fvset{fontsize=\small}'
388+
# Fix fancyhdr complaining about \headheight being too small
389+
latex_elements['passoptionstopackages'] = r"""
390+
\PassOptionsToPackage{headheight=14pt}{geometry}
391+
"""
357392

358393
# Additional stuff for the LaTeX preamble.
359394
latex_elements['preamble'] = r"""

0 commit comments

Comments
 (0)