Skip to content
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

Set cm-unicode font for latex if available (fixes #1673) #1688

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

cgevans
Copy link
Contributor

@cgevans cgevans commented Dec 7, 2021

This includes PR #1687 and depends on it, but makes potentially more problematic changes.

For LuaLaTeX and XeLaTeX, the default fonts usually don't support
Greek text, causing problems when Greek letters are used outside of
math mode (eg, as text or as symbols in code). This change to the
base template uses the cm-unicode fonts, if they are available.
Fonts are left unchanged if cm-unicode is not available, in which
case Greek letters in math will still work, but text will be missing.

Loading is done here using cm-unicode's filenames, rather than the
fonts' symbolic names, because XeLaTeX cannot search for symbolic
names of fonts that are not available to the system (but may be
available to LaTeX). LuaLaTeX does not have this limitation, but can
also load using filenames.

cgevans and others added 3 commits December 7, 2021 18:37
The current latex base template uses the ucs package with mathletters,
but as it does not also set utf8x on inputenc, the ucs package does
not work as intended, and Greek letters do not appear in math.

As utf8x and ucs are somewhat outdated and problematic, this PR uses
a few conditions to try to enable Greek letters in both math and text.

For pdflatex, if the alphabeta package (part of greek-inputenc, and
not necessarily installed) is present, this is used, as it better
supports Greek math and text, including diacritics.  It it is not,
ucs with mathletters is used, which will allow math, and some text,
though diacritics will cause an error.

For xelatex and lualatex, this instead uses unicode-math, which
handles math well but does not support pdflatex.  While this
arrangement does support text, note that by default, the fonts used
are unlikely to include support for Greek text, and the glyphs will be
omitted (both for text and for monospace text), particularly since
Latin Modern does not support Greek text.  I have an additional change
which uses Computer Modern Unicode if available, but I'd like to keep
these separate, as it's unclear to me that setting the font in this
template would be a good idea.

Mathpazo for pdflatex is removed for consistency with xelatex/lualatex
output, and the position of the conditional is moved to avoid an order
conflict with the ams packages; this more closely matches the position
of unicode-math in pandoc's template.
For LuaLaTeX and XeLaTeX, the default fonts usually don't support
Greek text, causing problems when Greek letters are used outside of
math mode (eg, as text or as symbols in code).  This change to the
base template uses the cm-unicode fonts, if they are available.
Fonts are left unchanged if cm-unicode is not available, in which
case Greek letters in math will still work, but text will be missing.

Loading is done here using cm-unicode's filenames, rather than the
fonts' symbolic names, because XeLaTeX cannot search for symbolic
names of fonts that are not available to the system (but may be
available to LaTeX).  LuaLaTeX does not have this limitation, but can
also load using filenames.
@SylvainCorlay
Copy link
Member

cc @ivanov since you reviewed other related changes lately.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants