-
-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Closes #15796 (building PDF docs of matplotlib via LaTeX) #15797
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -304,33 +304,92 @@ 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 | ||||||||||
| # Fix fontspec converting " into right curly quotes in PDF | ||||||||||
| # cf https://github.com/sphinx-doc/sphinx/pull/6888/ | ||||||||||
| latex_elements['fontenc'] = r''' | ||||||||||
| \usepackage{fontspec} | ||||||||||
| \defaultfontfeatures[\rmfamily,\sffamily,\ttfamily]{} | ||||||||||
| ''' | ||||||||||
| # Sphinx 2.0 adopts GNU FreeFont by default, but it does not have all | ||||||||||
| # the Unicode codepoints needed for the section about Mathtext | ||||||||||
| # "Writing mathematical expressions" | ||||||||||
| latex_elements['fontpkg'] = r""" | ||||||||||
| \setmainfont{XITS}[ | ||||||||||
| UprightFont = *-Regular, | ||||||||||
| ItalicFont = *-Italic, | ||||||||||
| BoldFont = *-Bold, | ||||||||||
| BoldItalicFont = *-BoldItalic, | ||||||||||
| ] | ||||||||||
| \setsansfont{FreeSans}[ | ||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
| UprightFont = *, | ||||||||||
| ItalicFont = *Oblique, | ||||||||||
| BoldFont = *Bold, | ||||||||||
| BoldItalicFont = *BoldOblique, | ||||||||||
| ] | ||||||||||
| \setmonofont{FreeMono}[ | ||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
| UprightFont = *, | ||||||||||
| ItalicFont = *Oblique, | ||||||||||
| BoldFont = *Bold, | ||||||||||
| BoldItalicFont = *BoldOblique, | ||||||||||
| ] | ||||||||||
| % needed for \mathbb (blackboard alphabet) to actually work | ||||||||||
| \usepackage{unicode-math} | ||||||||||
| \setmathfont{XITS Math} | ||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
| """ | ||||||||||
| # Sphinx <1.8.0 or >=2.0.0 does this by default, but the 1.8.x series | ||||||||||
| # did not for latex_engine = 'xelatex' (as it used Latin Modern font). | ||||||||||
| # We need this for code-blocks as FreeMono has wide glyphs. | ||||||||||
| latex_elements['fvset'] = r'\fvset{fontsize=\small}' | ||||||||||
| # Fix fancyhdr complaining about \headheight being too small | ||||||||||
| latex_elements['passoptionstopackages'] = r""" | ||||||||||
| \PassOptionsToPackage{headheight=14pt}{geometry} | ||||||||||
| """ | ||||||||||
|
|
||||||||||
| # Additional stuff for the LaTeX preamble. | ||||||||||
| latex_elements['preamble'] = r""" | ||||||||||
| % 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} | ||||||||||
|
|
||||||||||
| \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 | ||||||||||
| % 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' | ||||||||||
|
|
||||||||||
| # Better looking general index in PDF | ||||||||||
| latex_elements['printindex'] = r'\footnotesize\raggedright\printindex' | ||||||||||
|
|
||||||||||
| # Documents to append as an appendix to all manuals. | ||||||||||
| latex_appendices = [] | ||||||||||
|
|
||||||||||
|
|
@@ -358,13 +417,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) | ||||||||||
|
|
||||||||||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.