Hi all,
A while back, I asked about getting maths fonts to match the text fonts
specified by fontspec when using XeLaTeX, so at least for simple
mathematics where the symbols are all available there would be a perfect
match between text and inline equations.
Will Robertson helpfully replied with this suggestion:
> \documentclass[12pt]{article}
> \makeatletter
> \usepackage[no-math]{fontspec}
> \setmainfont{Adobe Garamond Pro}
> \DeclareSymbolFont{MRM}{EU1}{\zf@family}{m}{n}
> \DeclareSymbolFont{MIT}{EU1}{\zf@family}{m}{it}
> \DeclareMathSymbol{A}{\mathalpha}{MIT}{`\A}
> \DeclareMathSymbol{B}{\mathalpha}{MIT}{`\B}
> \DeclareMathSymbol{C}{\mathalpha}{MIT}{`\C}
> \DeclareMathSymbol{1}{\mathord}{MRM}{`\1}
> \DeclareMathSymbol{+}{\mathbin}{MRM}{`\+}
> \DeclareMathSymbol{=}{\mathrel}{MRM}{`\=}
> \begin{document}
> \noindent text: \textit{A+B}+1=\textit{C}\\
> math: $A+B+1=C$
> \end{document}
> Note that it looks like the spaces between symbols needs to be reduced
> for this font. Also, this technique only works for glyphs in the first
> 256 slots of the font, so you need to ask me for more code if you want
> to get this working for Greek symbols as well :)
If Will or anyone else reading this could elaborate on that last comment,
I'd be grateful, as a few key symbols such as the minus sign are indeed
past 255 in the font I'm using. It seems that adding
\DeclareMathSymbol{-}{\mathbin}{MRM}{"2212}
or any likely variation doesn't work in the latest versions of all the
software I'm using. Does this come from the general limitation in XeTeX
that \char can take 16-bit characters, but \mathchar only 8-bit?
If it's not currently possible to get this to work directly, is it at least
possible to define a \minussign macro or similar that can do the same
thing, perhaps by escaping to text mode where it does seem to be possible
to use 16-bit characters? This is a rare enough problem with my current
documents that such a workaround would be viable, though obviously I'd
prefer to just type '-' if there is a way it can be made to work.
Thanks,
Chris