5

I want to use a specific font for a specific formula in XeLaTeX. Usually, the math font can be set up using mathspec package.

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

I can also use a specific font for a part of the text using \newfontfamily command:

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

How can I use a specific font for a single equation:

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

1 Answer 1

3

If it was only for a single equation, I would be tempted to compile the equation in the standalone class, and then include it as a PDF graphic in the other [primary] document. Here's how. First, compile the file ComicEq.tex:

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

enter image description here

Then, the primary document includes it as a graphic:

\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}

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .