[XeTeX] fontspec & math(s)

Bruno Voisin bvoisin at mac.com
Thu Nov 18 09:46:50 CET 2004

Le 18 nov. 04, à 05:54, Will Robertson a écrit :

> If you put:
> \makeatletter
> \AtBeginDocument
>   {\DeclareSymbolFont{operators}\zf at enc\rmdefault\mddefault\updefault
>    \SetSymbolFont{operators}{bold}\zf at enc\rmdefault\bfdefault\updefault
>    \DeclareMathAlphabet\mathbf\zf at enc\rmdefault\bfdefault\updefault
>    \DeclareMathAlphabet\mathsf\zf at enc\sfdefault\mddefault\updefault
>    \DeclareMathAlphabet\mathit\zf at enc\rmdefault\mddefault\itdefault
>    \DeclareMathAlphabet\mathtt\zf at enc\ttdefault\mddefault\updefault
>    \SetMathAlphabet\mathsf{bold}\zf at enc\sfdefault\bfdefault\updefault
>    \SetMathAlphabet\mathit{bold}\zf at enc\rmdefault\bfdefault\itdefault}
> \makeatother
> in your preamble (AFTER you \usepackage{euler}, if you do), that's the  
> extent of my efforts. This requires you \setromanfont{} etc., in the  
> preamble, also.
> However, I get the wrong symbols when using \{ \}, so I must be  
> messing something up somewhere, and I haven't had time to work out  
> what's going wrong. Any suggestions?
> (Bruno's old posts on this subject were rather helpful, perhaps he can  
> comment further?)

Hi Will,

Presently I'm too busy to be able to undertake any TeX-related thing  
seriously. Thus I'm trying to refrain posting as much as possible,  
knowing that, after bringing up a question rapidly, I will have to call  
it quit before the question is solved or even formulated completely.  
(Looking at the OS X TeX list, you may guess that I've not really  
managed to adhere to these resolutions.)

About your question:

- I'm not sure \AtBeginDocument is required here, but it may cause no  
harm anyway.

- I think you could replace

	\DeclareSymbolFont{operators}\zf at enc\rmdefault\mddefault\updefault


	\SetSymbolFont{operators}{normal}\zf at enc\rmdefault\mddefault\updefault

But again the present line causes no harm, I think. Similarly the  
\DeclareMathAlphabet could be replaced by \SetMathAlphabet.

- You've forgotten \mathrm, for which you could add

	\DeclareMathAlphabet\mathrm\zf at enc\rmdefault\mddefault\updefault
	\SetMathAlphabet\mathrm{bold}\zf at enc\rmdefault\bfdefault\updefault

I think your problem is an encoding issue: the math fonts in TeX are  
assumed to have special encodings OML, OMS, OMX and even OT1. From  

	\DeclareSymbolFont{operators}   {OT1}{cmr} {m}{n}
	\DeclareSymbolFont{letters}     {OML}{cmm} {m}{it}
	\DeclareSymbolFont{symbols}     {OMS}{cmsy}{m}{n}
	\SetSymbolFont{operators}{bold}{OT1}{cmr} {bx}{n}
	\SetSymbolFont{letters}  {bold}{OML}{cmm} {b}{it}
	\SetSymbolFont{symbols}  {bold}{OMS}{cmsy}{b}{n}
	\DeclareSymbolFontAlphabet{\mathrm}    {operators}
	\DeclareSymbolFontAlphabet{\mathcal}   {symbols}
	\DeclareMathAlphabet      {\mathbf}{OT1}{cmr}{bx}{n}
	\DeclareMathAlphabet      {\mathsf}{OT1}{cmss}{m}{n}
	\DeclareMathAlphabet      {\mathit}{OT1}{cmr}{m}{it}
	\DeclareMathAlphabet      {\mathtt}{OT1}{cmtt}{m}{n}

whereas in your code (and in mine too) the math fonts are assumed to  
have U encoding. This may mess up some character declarations,  
regarding in particular \{ and \}, equivalent to \lbrace and \rbrace in  
math mode, and \textbraceleft and \textbraceright in text mode.

In typical LaTeX straightforwardness ;~\, you find in  


Then, regarding math mode, in  
/usr/local/teTeX/share/texmf.tetex/tex/latex/base/fontmath.ltx you  


For text mode, if you're using the default, you find in  


and then in  

	\DeclareTextSymbol{\textbraceleft}{OMS}{102}        % "66
	\DeclareTextSymbol{\textbraceright}{OMS}{103}       % "67

If you're using T1 encoding (through \usepackage[T1]{fontenc}), you  
find in /usr/local/teTeX/share/texmf.tetex/tex/latex/base/t1enc.def:


What `\{ means I must confess I don't know. And if you're using LY1  
encoding (through \usepackage[LY1]{fontenc}), you find in  

	\DeclareTextSymbol{\textbraceleft}{LY1}     {123}
	\DeclareTextSymbol{\textbraceright}{LY1}    {125}

This means in any case that you may have to redefine some math  
characters. For example, in my case, using a combination of Hoefler  
Text and Lucida in maths, I've had to write:


to get the slanted >= character right in Lucida NewMath.

Here the code I've used (I haven't yet, due to time constraints,  
started to experiment with fontspec.sty):

	  {<-> "Hoefler\space Text:mapping=tex-text;
	          Number\space Case=Upper\space Case\space Numbers
	  {<-> "Hoefler\space Text\space Italic:mapping=tex-text;
	          Smart\space Swashes=!Line\space Final\space Swashes,
	                              !Line\space Initial\space Swashes;
	          Number\space Case=Uppercase\space Numbers
	  {<-> "Hoefler\space Text\space Black:mapping=tex-text;
	          Number\space Case=Diphthong\space Ligatures
		  {<-> "Hoefler\space Text\space Black\space Italic:mapping=tex-text;
	          Smart\space Swashes=!Line\space Final\space Swashes,
	                              !Line\space Initial\space Swashes;
	          Number\space Case=Normal\space Vertical\space Position
	  {<-> ssub * hoefmat/b/n}{}
	  {<-> ssub * hoefmat/b/it}{}

	\SetSymbolFont{operators}{bold}  {\encodingdefault}{\mtdefault}{b}{n}
	\SetMathAlphabet{\mathrm}{bold}  {\encodingdefault}{\mtdefault}{b}{n}
	\SetMathAlphabet{\mathit}{bold}  {\encodingdefault}{\mtdefault}{b}{it}


I've used a different font \mtdefault in maths, compared with  
\rmdefault in text, so that I could later, should the fancy take me,  
use Hoefler with oldstyle digits in text and modern digits in maths.

I feel a bit discouraged regarding the proper use of OS X fonts with  
maths in (La)TeX, there are so many things relying on the idiosyncrases  
of the CM/AMS fonts that I doubt anything automated could be devised  
for Xe(La)TeX. You only have to look at the number of manual work that  
had to be done in the packages mathtime.sty and lucidabr.sty to make it  
possible to use the MathTime and Lucida fonts, respectively, in maths  
instead of CM/AMS; the same applies to plain TeX, with the files  
mtmacs.tex and lcdplain.tex compared with plain.tex.

I am now inclined to think that nothing can really be done until a  
future (La)TeX based on Unicode from the ground up is finally released  
(LaTeX 3?), making it possible to use Unicode fonts having math symbols  
at the proper Unicode slots, to replace the current 7-bit-inspired  
mess. That supposes, of course, that these Unicode math fonts exist.  
Possibly the Mathematica fonts  
<http://www.mathmlcentral.com/characters/> and  
latestfonts.html> (can't say more, I still haven't upgraded my  
Mathematica 4 licence to version 5, and I have the impression the  
Mathematica 4 fonts were free but not the Mathematica 5 ones), or the  
STIX fonts <http://www.stixfonts.org/project.html> when they are  
finally released?

Sorry I can't help more,


More information about the XeTeX mailing list