![如何更改文档部分内容的数学和文本字体?](https://linux22.com/image/353802/%E5%A6%82%E4%BD%95%E6%9B%B4%E6%94%B9%E6%96%87%E6%A1%A3%E9%83%A8%E5%88%86%E5%86%85%E5%AE%B9%E7%9A%84%E6%95%B0%E5%AD%A6%E5%92%8C%E6%96%87%E6%9C%AC%E5%AD%97%E4%BD%93%EF%BC%9F.png)
如何更改数学和文本您的文档的某个部分?
使用默认包(LaTeX)还是系统字体(XeLaTex)?
答案1
如果您可以使用 XeLaTeX 或 LuaLaTeX,则可以使用\begingroup
和\endgroup
语句来限制指令的范围\setmainfont
。为了使数学字体的更改“本地化”到 (TeX) 组,请不要\setmathfont
直接使用。相反,请在序言中设置所有数学版本,并\mathversion
在文档正文中使用指令。
MWE(最小工作示例),可使用 XeLaTeX 或 LuaLaTeX 进行编译。
\documentclass{article}
\usepackage{unicode-math} % load 'fontspec' automatically
\setmathfont{Latin Modern Math}[version=LM]
\setmathfont{XITS Math}[version=XITS]
\newcommand\qbf{The quick brown fox jumps over the lazy dog.\quad $E=mc^2$.\par}
\begin{document}
\setmainfont{Latin Modern Roman}
\mathversion{LM}
\qbf
\begingroup
\setmainfont{XITS} % Times Roman clone
\mathversion{XITS}
\qbf
\endgroup
\qbf % back to Latin Modern font family for both text and math
\end{document}