Skip to content

[LaTeX] Legitimate math input such as \mathbf{\Lambda} is ok with pdflatex and uplatex, not with xelatex or lualatex #12714

Open
@jfbu

Description

@jfbu

Describe the bug

PDF is wrong if sources contain usage of \mathbf with the uppercase Greek control sequences in math mode, and latex_engine is set to 'xelatex' or 'lualatex'. It is ok with default ('pdflatex') or Japanese documents.

Rendering is ok with HTML+MathJaX or also with HTML+math-as-images (html_math_renderer='imgmath').

How to Reproduce

.. math:: \mathbf{\Lambda\Gamma\Delta\alpha\gamma\delta}

and latex_engine='xelatex'.

Latexmk: Summary of warnings from last run of *latex:
  =====Latex reported missing or unavailable character(s).
=====See log file for details.
Latexmk: ====Undefined refs and citations with line #s in .tex file:
  Missing character: There is no ^^C (U+0003) in font [FreeSerifBold.otf]/OT:scri
  Missing character: There is no ^^C (U+0003) in font [FreeSerifBold.otf]/OT:script=latn;language=dflt;!
  Missing character: There is no ^^C (U+0003) in font [FreeSerifBold.otf]/OT:scri
  Missing character: There is no ^^C (U+0003) in font [FreeSerifBold.otf]/OT:script=latn;language=dflt;!
  Missing character: There is no ^^C (U+0003) in font [FreeSerifBold.otf]/OT:scri
  Missing character: There is no ^^C (U+0003) in font [FreeSerifBold.otf]/OT:script=latn;language=dflt;!
  Missing character: There is no ^^@ (U+0000) in font [FreeSerifBold.otf]/OT:scri
 And 9 more --- see log file 'foo.log'
Latexmk: All targets (foo.pdf) are up-to-date

Capture d’écran 2024-07-30 à 15 17 25

Expected output is

Capture d’écran 2024-07-30 à 15 15 44

Environment Information

Python version:        3.12.3 (v3.12.3:f6650f9ad7, Apr  9 2024, 08:18:48) [Clang 13.0.0 (clang-1300.0.29.30)])
Python implementation: CPython
Sphinx version:        8.0.2
Docutils version:      0.20.1
Jinja2 version:        3.1.4
Pygments version:      2.18.0

Sphinx extensions

No response

Additional context

As explained in sympy/sympy#26877 (comment) the cause of the problem is our \usepackage{fontspec}. Arguably it should be \usepackage[no-math]{fontspec}. The no-math prevents fontspec from redefining \mathrm, \mathbf etc... to use the body text fonts. Only the legacy Old TeX font config can allow the latter commands to work on \Lambda et al (they do nothing on lowercase Greek letters, it is only the matter of the eleven uppercase Greek letters defined by TeX with associated control sequences).

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions