1

When I use \usepackage[UTF8]{ctex} and input the formula like this:

\begin{equation}
 y = \frac{\gamma}{\sqrt{Var[x] + \varepsilon } } \cdot x + (\beta - \frac{\gamma E[x]}{\sqrt{Var[x] + \varepsilon } }) \equiv BN_{\gamma ,\beta }(x)   
  % \widehat{x}^{(k)}=\frac{x^{(k)} - E[x^{(k)}]}{\sqrt{Var[x^{(k)}]} }  
  \label{BN}
\end{equation}

The correct formula I want should be

enter image description here

but instead I get it like this

enter image description here

As you can see, the math symbol - became `*. Why does this happen?

However, when I am not using \usepackage[UTF8]{ctex}, the equation is displayed correctly.

Here is some information about ctex.

package:     ctex
category:    Package
shortdesc:   LaTeX classes and packages for Chinese typesetting
longdesc:    ctex is a collection of macro packages and document classes for LaTeX Chinese typesetting.
installed:   Yes
revision:    61285
sizes:       src: 481k, doc: 1137k, run: 1753k
relocatable: No
cat-version: 2.5.8
cat-license: lppl1.3c
cat-topics:  chinese book-pub class
cat-contact-repository: https://github.com/CTeX-org/ctex-kit
cat-contact-support: https://github.com/CTeX-org/ctex-kit/issues
cat-contact-home: http://www.ctex.org/HomePage
cat-contact-bugs: https://github.com/CTeX-org/ctex-kit/issues
collection:  collection-langchinese
XeTeX 3.141592653-2.6-0.999994 (TeX Live 2022)
kpathsea version 6.3.4
Copyright 2022 SIL International, Jonathan Kew and Khaled Hosny.
There is NO warranty.  Redistribution of this software is
covered by the terms of both the XeTeX copyright and
the Lesser GNU General Public License.
For more information about these matters, see the file
named COPYING and the XeTeX source.
Primary author of XeTeX: Jonathan Kew.
Compiled with ICU version 70.1; using 70.1
Compiled with zlib version 1.2.11; using 1.2.11
Compiled with FreeType2 version 2.11.1; using 2.11.1
Compiled with Graphite2 version 1.3.14; using 1.3.14
Compiled with HarfBuzz version 3.4.0; using 3.4.0
Compiled with libpng version 1.6.37; using 1.6.37
Compiled with pplib version v2.05 less toxic i hope
Compiled with fontconfig version 2.13.0; using 2.13.1

enter image description here enter image description here enter image description here


Here I'll provide an mwe:

% xelatex
% xelatex
\documentclass{article}
\usepackage{fontspec}
% \usepackage[scheme=plain]{ctex}
\usepackage{stix} 
\begin{document}
  $ \beta - a $ 
\end{document}

enter image description here

Mico
  • 506,678
  • Welcome to TeX.SE! – Mensch May 25 '22 at 07:58
  • 1
    Can't reproduce the problem. Can you extend it to a short but complete example, and provide version info of your distribution and ctex package? – muzimuzhi Z May 25 '22 at 08:17
  • 如果你有overleaf的账户,你可以提供你的注册邮箱,我分享我的文档给你,这可以帮助你定位错误 – ARC wang May 25 '22 at 08:42
  • 1
    If you are certain that you shall always use XeLaTeX, and if you only need the support for entering Chinese characters, then try to use the package xeCJK (internally used by ctex) instead of the whole bundle ctex. This should reduce possible conflicts between packages. And even if the problem remains, you shall have at least narrowed down the problem to xeCJK. – Jinwen May 25 '22 at 12:58
  • @muzimuzhiZ this problem can be reproduced by stix and fontspec package. After xelatex, $-$ turns to * – Syvshc May 25 '22 at 18:15
  • 1
    @Syvshc thx for the info, while a complete example is still missing. – muzimuzhi Z May 25 '22 at 18:28
  • @muzimuzhiZ I edited the question and provided an mwe – Syvshc May 25 '22 at 19:02
  • 1
    \usepackage[no-math]{fontspec}. – muzimuzhi Z May 25 '22 at 19:15
  • Which TeX distribution do you employ, and when was it last updated? The reason I ask is that I use MacTeX2022 (with all updates applied) and am unable to reproduce the faulty behavior you've encounterd. – Mico May 25 '22 at 19:23

2 Answers2

1

Since you are using XeLaTeX or LuaLaTeX anyway, you can load Unicode text, math and CJK fonts, and cut the Gordian knot of legacy 8-bit font encodings completely.

For example, this uses the OpenType version of the STIX 1 fonts, XITS Math.

\documentclass{article}
\usepackage{unicode-math}
\defaultfontfeatures{ Scale=MatchLowercase, Ligatures=TeX }

\setmainfont{XITS}[Scale=1.0] \setmathfont{XITS Math}

\usepackage[UTF8, scheme=plain, fontset=ubuntu ]{ctex}

\begin{document} $ \beta - a $ \end{document}

XITS Math sample

Davislor
  • 44,045
0

I found the answer after submitting an issue on Github. I guess the (mathematical) font coding. Considering that the macro bags and STIX2 use the custom LS1 and LS2 font encoding both.

Add \PassOptionsToPackage{no-math}{fontspec} before \documentclass[a4paper,fleqn]{cas-dc}, it will display normally.