-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
LaTeX: new 'fontpkgmath' key of latex_elements, use unicode-math #12753
Open
jfbu
wants to merge
5
commits into
sphinx-doc:master
Choose a base branch
from
jfbu:latex_xelatex_math
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
d5ba3ba
LaTeX: use ``unicode-math`` with ``xelatex`` and ``lualatex``
jfbu 43e2e48
Update CHANGES.rst
jfbu 998177b
Update CHANGES.rst
jfbu 21a4c93
Do not announce a Sphinx 9 change
jfbu d12e60d
Add support for \mathit{\Gamma} etc... in PDF output
jfbu 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 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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 |
---|---|---|
|
@@ -10,6 +10,10 @@ | |
\renewcommand{\ttdefault}{txtt} | ||
''' | ||
|
||
PDFLATEX_DEFAULT_FONTPKGMATH = r''' | ||
\usepackage{amssymb}% may become stix2 at some future version | ||
''' | ||
|
||
PDFLATEX_DEFAULT_FONTSUBSTITUTION = r''' | ||
\expandafter\ifx\csname T@LGR\endcsname\relax | ||
\else | ||
|
@@ -58,12 +62,54 @@ | |
] | ||
''' | ||
|
||
XELATEX_DEFAULT_FONTPKGMATH = r''' | ||
\usepackage{unicode-math} | ||
\setmathfont{XITSMath-Regular.otf}[ | ||
StylisticSet=1,% choice of shape for "\mathcal" | ||
BoldFont=XITSMath-Bold.otf, | ||
ItalicFont=XITS-Italic.otf,% text only (\mathit) | ||
BoldItalicFont=XITS-BoldItalic.otf,% text only | ||
NFSSFamily=XITS, | ||
] | ||
\makeatletter | ||
\AtBeginDocument{% | ||
% work around unicode-math problems with \mathbf{\Gamma} et al. | ||
\SetMathAlphabet{\mathrm}{normal}{TU}{XITS}{m}{n} | ||
\SetMathAlphabet{\mathit}{normal}{TU}{XITS}{m}{it} | ||
\SetMathAlphabet{\mathbf}{normal}{TU}{XITS}{b}{n} | ||
\SetMathAlphabet{\mathrm}{bold}{TU}{XITS}{b}{n} | ||
\SetMathAlphabet{\mathit}{bold}{TU}{XITS}{b}{it} | ||
\SetMathAlphabet{\mathbf}{bold}{TU}{XITS}{b}{n} | ||
\def\Gamma{Γ} | ||
\def\Delta{Δ} | ||
\def\Theta{Θ} | ||
\def\Lambda{Λ} | ||
\def\Xi{Ξ} | ||
\def\Pi{Π} | ||
\def\Sigma{Σ} | ||
\def\Upsilon{Υ} | ||
\def\Phi{Φ} | ||
\def\Psi{Ψ} | ||
\def\Omega{Ω} | ||
% Make subscripts a bit larger for legibility | ||
\def\defaultscriptratio{.8} | ||
\def\defaultscriptscriptratio{.6} | ||
\DeclareMathSizes{9}{9}{7}{5} | ||
\DeclareMathSizes{\@xpt}{\@xpt}{8}{6} | ||
\DeclareMathSizes{\@xipt}{\@xipt}{8.76}{6.57} | ||
\DeclareMathSizes{\@xiipt}{\@xiipt}{9.6}{7.2} | ||
\DeclareMathSizes{\@xivpt}{\@xivpt}{11.52}{8.64} | ||
Comment on lines
+94
to
+101
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. This brings legibility benefits. When time will come at Sphinx 9 for using |
||
} | ||
\makeatother | ||
''' | ||
|
||
XELATEX_GREEK_DEFAULT_FONTPKG = (XELATEX_DEFAULT_FONTPKG + | ||
'\n\\newfontfamily\\greekfont{FreeSerif}' + | ||
'\n\\newfontfamily\\greekfontsf{FreeSans}' + | ||
'\n\\newfontfamily\\greekfonttt{FreeMono}') | ||
|
||
LUALATEX_DEFAULT_FONTPKG = XELATEX_DEFAULT_FONTPKG | ||
LUALATEX_DEFAULT_FONTPKGMATH = XELATEX_DEFAULT_FONTPKGMATH | ||
|
||
DEFAULT_SETTINGS: dict[str, Any] = { | ||
'latex_engine': 'pdflatex', | ||
|
@@ -82,11 +128,12 @@ | |
'utf8extra': '', | ||
'cmappkg': '\\usepackage{cmap}', | ||
'fontenc': '\\usepackage[T1]{fontenc}', | ||
'amsmath': '\\usepackage{amsmath,amssymb,amstext}', | ||
'amsmath': '\\usepackage{amsmath,amstext}', | ||
jfbu marked this conversation as resolved.
Show resolved
Hide resolved
|
||
'multilingual': '', | ||
'babel': '\\usepackage{babel}', | ||
'polyglossia': '', | ||
'fontpkg': PDFLATEX_DEFAULT_FONTPKG, | ||
'fontpkgmath': PDFLATEX_DEFAULT_FONTPKGMATH, | ||
'fontsubstitution': PDFLATEX_DEFAULT_FONTSUBSTITUTION, | ||
'substitutefont': '', | ||
'textcyrillic': '', | ||
|
@@ -142,6 +189,7 @@ | |
'fontenc': ('\\usepackage{fontspec}\n' | ||
'\\defaultfontfeatures[\\rmfamily,\\sffamily,\\ttfamily]{}'), | ||
'fontpkg': XELATEX_DEFAULT_FONTPKG, | ||
'fontpkgmath': XELATEX_DEFAULT_FONTPKGMATH, | ||
'fvset': '\\fvset{fontsize=\\small}', | ||
'fontsubstitution': '', | ||
'textgreek': '', | ||
|
@@ -155,6 +203,7 @@ | |
'fontenc': ('\\usepackage{fontspec}\n' | ||
'\\defaultfontfeatures[\\rmfamily,\\sffamily,\\ttfamily]{}'), | ||
'fontpkg': LUALATEX_DEFAULT_FONTPKG, | ||
'fontpkgmath': LUALATEX_DEFAULT_FONTPKGMATH, | ||
'fvset': '\\fvset{fontsize=\\small}', | ||
'fontsubstitution': '', | ||
'textgreek': '', | ||
|
@@ -166,6 +215,7 @@ | |
'babel': '', | ||
'classoptions': ',dvipdfmx', | ||
'fontpkg': PDFLATEX_DEFAULT_FONTPKG, | ||
'fontpkgmath': PDFLATEX_DEFAULT_FONTPKGMATH, | ||
'fontsubstitution': '', | ||
'textgreek': '', | ||
'fncychap': '', | ||
|
@@ -176,6 +226,7 @@ | |
'babel': '', | ||
'classoptions': ',dvipdfmx', | ||
'fontpkg': PDFLATEX_DEFAULT_FONTPKG, | ||
'fontpkgmath': PDFLATEX_DEFAULT_FONTPKGMATH, | ||
'fontsubstitution': '', | ||
'textgreek': '', | ||
'fncychap': '', | ||
|
This file contains 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
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.
Actually, it seems all are "subpackages" of
texlive
which we require earlier in this bindep.txt for Fedora, see also here, so I am not sure we really need this and/or any of the other lines.As per Ubuntu, unicode-math is part of texlive-latex-recommended, and XITS Math of texlive-fonts-extras which we both require already.