在 XeLaTex 中使用特定字体表示公式

在 XeLaTex 中使用特定字体表示公式

我想在 XeLaTeX 中为特定公式使用特定字体。通常,可以使用包设置数学字体mathspec

\usepackage{mathspec}
\setmathsfont(Digits,Latin,Greek)[Numbers={Lining,Proportional}]{Humor Sans}

我还可以使用命令对部分文本使用特定字体\newfontfamily

\newfontfamily\humor{Humor Sans}
{\humor text }

如何对单个方程式使用特定字体:

%Want Humor Sans only here!!
 \begin{equation}
   C = A + B
\end{equation}

答案1

如果只是针对一个方程式,我会倾向于在课堂上编译该方程式standalone,然后将其作为 PDF 图形包含在另一个 [主要] 文档中。方法如下。首先,编译文件ComicEq.tex

\documentclass{standalone}
\usepackage{mathspec}
\setmathsfont(Digits,Latin,Greek)[Numbers={Lining,Proportional}]{Comic Sans MS}
\begin{document}
$C = A + B$
\end{document}

在此处输入图片描述

然后,主要文档将其作为图形包含:

\documentclass{article}
\usepackage{graphicx,lipsum}
\begin{document}
\lipsum[1]
\begin{equation}
  \includegraphics{ComicEq}
\end{equation}
\lipsum[1]
\begin{equation}
  E = mc^2
\end{equation}
\end{document}

在此处输入图片描述

相关内容