[XeTeX] Using math font packages with fontspec

Jonathan Kew jonathan_kew at sil.org
Wed May 23 21:18:40 CEST 2007


On 23 May 2007, at 6:05 pm, Hendrik Fuß wrote:

> Hi everyone,
>
> I need some advice regarding fontspec. I want to use a math font that
> better matches the main text font in my document. The manual gives an
> example for using the euler package. However, the example doesn't work
> with my setup (TeXlive 2007 on Mac OS X). Instead, xelatex uses the
> latin modern fonts. Here's my test document:
>
> \documentclass{article}
> \usepackage[mathcal]{euler}
> \usepackage{fontspec,xunicode}
> \setmainfont{Optima Regular}
> \begin{document}
> 	Main font $ f(x) = a \cdot b \cdot c $
> \end{document}
>
> Upon looking in the .log file I can see that first the euler package
> redefines the math fonts, and after that fontspec loads the lmodern
> package, thus reversing the effect of euler.
>
> Exchanging the order of \usepackage commands doesn't work either --
> fontspec insists that euler must be loaded first.

Ha! This sounds like one for Will.

Two observations, though:

(1) if you reverse the order of the \usepackage commands, and then  
continue past the error message from fontspec, you do seem to get the  
desired result, at least in this simple case. I don't know whether  
there would be further problems lurking to be discovered, or if the  
error is actually obsolete. This isn't really a solution, though, as  
the error message every time you run the document is a nuisance (to  
say the least).

(2) More usefully, I have a workaround that seems to avoid the issue:

\documentclass{article}
\usepackage[mathcal]{euler}
\usepackage[cm-default]{fontspec}
\usepackage{xunicode}
\setmainfont{Optima Regular}
\begin{document}
	Main font $ f(x) = a \cdot b \cdot c $
\end{document}

Loading fontspec with the [cm-default] option causes it to leave the  
original Computer Modern fonts as the default, rather than replacing  
everything with LM. (If you're going to load a new font yourself with  
\setmainfont anyway, this shouldn't matter.) When loaded like this,  
fontspec doesn't override the math fonts from the euler package, and  
so you get the result you're looking for.

JK



More information about the XeTeX mailing list