当我使用\usepackage[UTF8]{ctex}
并输入如下公式时:
\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}
我想要的正确公式应该是
但我却得到这样的结果
可以看到,数学符号-
变成了“*”。为什么会这样呢?
但是,当我不使用时\usepackage[UTF8]{ctex}
,等式会正确显示。
这里是有关 的一些信息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
这里我将提供一个mwe:
% xelatex
% xelatex
\documentclass{article}
\usepackage{fontspec}
% \usepackage[scheme=plain]{ctex}
\usepackage{stix}
\begin{document}
$ \beta - a $
\end{document}
答案1
既然你正在使用 XeLaTeX 或 LuaLaTeX,你可以加载 Unicode 文本,数学和 CJK 字体,彻底解决了传统 8 位字体编码的难题。
例如,这使用了 STIX 1 字体的 OpenType 版本 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}
答案2
我在 Github 上提交问题后找到了答案。我猜是(数学)字体编码。考虑到宏包和 STIX2 都使用自定义 LS1 和 LS2 字体编码。
\PassOptionsToPackage{no-math}{fontspec}
在 之前 添加\documentclass[a4paper,fleqn]{cas-dc}
,即可正常显示。