0

I am unable to redefine uppercase math symbols when using the fontspec package. Here is a minimal working example:

\documentclass[ngerman]{standalone}
\usepackage{fontspec}

\let\psi\alpha        %works
\let\Psi\alpha        %does not work

\begin{document}
$\psi \Psi$
\end{document}

using \let just ignores the redefinition. using \renewcommand yields an error saying that \Psi is already defined.

how can I avoid this behavior?

this seems to be related to fontspec breaks capital greek letters in DeclareMathOperator

1
  • 4
    please don't put answers in the question post, it messes up the site format, leaving this question flagged unanswered, you can post the question as a question and separately post the answer as an answer Feb 15 at 20:14

2 Answers 2

2

With legacy TeX, the capital upright Greek letters are taken from the OT1 encoded version of the main text font, but when fontspec is loaded, the main text font doesn't have the characters in the expected places.

The standard definition of \Psi is equivalent to

\mathchardef\Psi="7009

and if fontspec didn't anything about the issue, no Psi would appear in the output, because the second hexadecimal digit specifies the main text font (family 0). However it must delay the new settings at begin document, when it's certain what fonts have been set up for the document.

In fontspec-xetex.sty and fontspec-luatex.sty we find

 \DeclareSymbolFont{legacymaths}{OT1}{cmr}{m}{n}
[...]
     \DeclareMathSymbol{\Psi}{\mathalpha}{legacymaths}{9}

and this code is executed at begin document for the reasons mentioned above.

Thus a redefinition of \Psi in the preamble will be superseded at begin document.

Hence, if such a redefinition is desired, it must be passed to the begin document hook

\AtBeginDocument{\let\Psi\alpha}

By the way, \let should not be used, but \RenewCommandCopy.

Nothing is necessary for the lowercase math Greek letters, because they're taken from family 1, which is not touched by fontspec. But, of course, it is when unicode-math is loaded.

0

Answered by prompting GPT-4:

To redefine uppercase Greek letters when using the fontspec package, you can use the \AtBeginDocument command to delay the redefinition until after the font settings have been applied. Try the following:

\usepackage{fontspec}

\let\psi\alpha        % works

\AtBeginDocument{
  \let\Psi\alpha       % delayed redefinition
}

\begin{document}
$\psi \Psi$
\end{document}

This approach ensures that the redefinition of \Psi happens after all package initializations, including fontspec, have been completed, thus avoiding the issue you encountered.

1
  • 1
    This is correct (apart from the unprotected endlines), but I've seen ChatGPT generate answers that are simply ridiculous.
    – egreg
    Feb 15 at 21:26

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .