Appearance
如何修改数学公式的字体?
BIThesis
请编辑main.tex,用\BITSetup设置style/mathFont选项,例如:
latex
\BITSetup{
…,
style = {
mathFont = termes,
},
}这里terms指 TeX Gyre Termes Math 字体,它相当接近 Times New Roman。更多选择请参考bithesis手册。
一般 LaTeX 文档
可以在导言区引入unicode-math宏包,并使用 \setmathfont{…} 修改数学环境下字体,例如:
latex
\usepackage{unicode-math}
\unimathsetup{
math-style = ISO,
bold-style = ISO,
}
\setmathfont{XITSMath-Regular.otf}(部分环境需手动安装字体)
更多字体与使用方法请参考unicode-math手册。
可能存在的问题
粗体:\boldsymbol → \symbf
unicode宏包与上世纪的字体管理方式不兼容。使用unicode宏包后,加粗无法使用amsbsy宏包的\boldsymbol、bm宏包的\bm、physics宏包的\vb等。
建议使用\symbf加粗,\symup、\symit、\symcal等同理。
也可以考虑兼容手段,例如使用physics2宏包的bm-um.legacy,或者自己\renewcommand*:
latex
% Overwrite some commands from physics to be compatible with unicode-math
\RenewCommandCopy\vb\symbf
\renewcommand*{\vdot}{\symbf{\cdot}}
\renewcommand*{\grad}{\symbf{\nabla}}
\renewcommand*{\divergence}{\symbf{\nabla} \vdot}参考:LaTeX 排版国标样式的数学符号 - LaTeX工作室。
如需兼容mathtools宏包
mathtools宏包提供了gather环境、\coloneqq符号(:=)等命令,但个别命令与unicode-math宏包冲突。如需使用,可在导入时关闭警告:
latex
% 注意导入顺序
\usepackage{amsmath}
\usepackage{mathtools}
\usepackage[
warnings-off={mathtools-colon, mathtools-overbracket},
]{unicode-math}
\unimathsetup{…}字体字面较大
如果使用 TeX Gyre Pagella Math 等字面较大的字体,略微增加数学行距可能更美观:
latex
\setmathfont{texgyrepagella-math.otf}
\SetMathEnvironmentSinglespace{1.05}请参考zhlineskip手册。
混用字体
下例中,主要使用 Latin Modern Math,双线体(如 ℕℤℚℝℂ)使用 TeX Gyre Pagella Math,空集符号 ∅ 使用 Asana Math。
latex
\setmathfont{latinmodern-math.otf}
\setmathfont[range=\mathbb]{texgyrepagella-math.otf}
\setmathfont[range=\varnothing]{Asana-Math.otf}详情请参考unicode-math手册。