3

I was using the \DeclareMathOperator* in amsmath to define some \mathop. The Following Example worked without ctex package.

\documentclass{article}
\usepackage{amsmath}
\DeclareMathOperator*{\hugeX}{X}
\DeclareMathOperator*{\hugepi}{\pi}
\DeclareMathOperator*{\hugeLambda}{\Lambda}
\begin{document}
    \[  
        \hugeX_{n=1}^\infty + \hugepi_{n=1}^{\infty} + \hugeLambda_{n=1}^{\infty} + X + \lambda + \Lambda 
    \] 
\end{document}

However, if the ctex package is loaded, the math alphabet \Lambda is missing! And it yields the below:

with ctex package

Inspiring by the brilliant solution here, I can change the \operator@font, and it worked:

\documentclass{article}
\usepackage{ctex}
\usepackage{amsmath}
\DeclareMathOperator*{\hugeX}{X}
\DeclareMathOperator*{\hugepi}{\pi}
\DeclareMathOperator*{\hugeLambda}{\Lambda}
\DeclareFontShape{OMX}{cmex}{m}{n}{%
  <-7.5>cmex7%
  <7.5-8.5>cmex8%
  <8.5-9.5>cmex9%
  <9.5->cmex10%
}{}
\DeclareSymbolFont{MyOperatorFont}{OT1}{cmr}{m}{n}
\makeatletter
\def\operator@font{\mathgroup\symMyOperatorFont}
\makeatother
\begin{document}
    \[  
        \hugeX_{n=1}^\infty + \hugepi_{n=1}^{\infty} + \hugeLambda_{n=1}^{\infty} + X + \lambda + \Lambda 
    \] 
\end{document}

However, I noticed that unicode-math has the usage of defining a new \mathfontface, but I don't know how to assign the cmm as the default, the \mathrm seemed to be failed as below but \mathscr is not the default roman style:

\documentclass{article}
\usepackage{ctex}
\usepackage{amsmath}
\DeclareMathOperator*{\hugeX}{X}
\DeclareMathOperator*{\hugepi}{\pi}
\DeclareMathOperator*{\hugeLambda}{\Lambda}
\usepackage{unicode-math}
\setoperatorfont\mathcal % I don't know how to set is to be default cmr here...
\begin{document}
    \[  
        \hugeX_{n=1}^\infty + \hugepi_{n=1}^{\infty} + \hugeLambda_{n=1}^{\infty} + X + \lambda + \Lambda 
    \] 
\end{document}

In a word, My Question is that:

  • What ctex package's behavior to change the \operator@font?
  • Why in the above MWE, the \pi keep the same, but the \Lambda missing?
  • Is there easier method to fixed the ctex's side-effect via unicode-math?

1 Answer 1

4

Just use \mathnormal for the Greek letters.

\documentclass{article}
\usepackage[fontset=fandol]{ctex}
\usepackage{amsmath}
\usepackage{unicode-math}

\DeclareMathOperator*{\hugeX}{X}
\DeclareMathOperator*{\hugepi}{\mathnormal{\pi}}
\DeclareMathOperator*{\hugeLambda}{\mathnormal{\Lambda}}

\begin{document}

\[  
  \hugeX_{n=1}^\infty +
  \hugepi_{n=1}^{\infty} +
  \hugeLambda_{n=1}^{\infty} +
  X + \lambda + \Lambda 
\] 

\end{document}

(I had to add fontset=fandol, because CTeX refuses to work otherwise.)

output

2
  • Could you please also tell me the reason of that, why the \mathnormal happened to fix the case? Or it think I need some introcudtion about the mathfonts. Commented Jan 18, 2025 at 12:18
  • 2
    @Explorer ctex has no role here. The text font, used by \operator@font doesn't support math characters, so with \mathnormal we switch to the math font. That's all. Commented Jan 18, 2025 at 13:01

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.