[XeTeX] XeLaTeX and Mathematics

Andrew Moschou andmos at gmail.com
Thu Apr 17 18:03:30 CEST 2008


Hello,

 I have here something that tries to combine XeLaTeX and mathematics
 without resulting in the mathematics typeset in Computer Modern which
 rarely blends with the surrounding text, source below, PDF attached. I
 have put Latin covered by Bembo MT, Greek by GFS Didot Classic and
 other symbols proved by MnSymbol (I'm having doubts on the combination
 of Bembo and Didot Classic.). There are some issues that I want to
 discuss here.

 When using e.g. \XeTeXmathcode`#1=0 6`#1, the font is chosen by using
 "6" here. Is there a better way to select the font, perhaps using "Gm"
 as suggested by \DeclareSymbolFont earlier in the preamble? If things
 get shifted around then 6 might no longer represent GFS Didot Classic.
 If I decide not to use MnSymbol or another mathematics package and if
 unicode-math won't work, I would have to define the other symbols case
 by case and whatever numbers corresponds to the particular mathematics
 fonts (I did try this but gave up, settling on MnSymbol), here a lot
 of trouble would come from keeping track of the fonts including
 fraktur, blackboard bold, script.

 The letters in mathematics are typeset according to their metrics as
 if they are in text. You can see this with the alphabets in maths
 mode, how the letters are next to each other as if they are kerned.
 This creates all sorts of alignment and spacing issues e.g. in $S_i^2$
 the 2 is too close to the S, and f will collide with its neighbours
 too often. It just happens that we can replace f with ƒ but that's far
 from being ideal. Is there a way to include "italic corrections" in
 maths mode? I tried interchartokens but they work only in text mode,
 and making the characters active and defining space around them is
 asking for trouble.

 Andrew

 \documentclass[12pt,a4paper]{article}

 \usepackage[no-math]{fontspec}
 \usepackage{xltxtra}

 \makeatletter
 \zf at package@euler at loadedtrue\zf at math@lucidatrue % FOOL FONTSPEC. DON'T
 REMEMBER WHY I DO THIS.
 % SOMETHING WAS HAPPENING WITH THE CODE ON p. 67 OF fontspec DOCUMENTATION.
 % BUT IT DOESN'T SEEM TO HAPPEN ANY MORE. DON'T KNOW WHAT CHANGED.

 \setmainfont[Mapping=fi-fl]{Bembo MT} % A SOLARIS SYSTEM FONT,
 ARTIFICIAL LIGATURES ARE NEEDED

 \newfontfamily\Latin[Mapping=fi-fl]{Bembo MT}
 \DeclareSymbolFont{Lmn}{EU1}{\zf at family}{m}{n}
 \DeclareSymbolFont{Lmit}{EU1}{\zf at family}{m}{it}

 \newfontfamily\Greek{GFS Didot Classic} % ONE OF THE BEST GREEKS I'VE
 SEEN (BUT NO DIGAMMA!)
 \DeclareSymbolFont{Gm}{EU1}{\zf at family}{m}{n}

 \usepackage{amsmath}
 \usepackage{MnSymbol}

 \catcode`¡=13 % A CHARACTER I WOULD NEVER USE, MAKES SIMPLER CODE BELOW
 %%%% FIGURES
 \newcommand¡[1]{\DeclareMathSymbol{#1}{\mathord}{Lmn}{`#1}}
        ¡0¡1¡2¡3¡4¡5¡6¡7¡8¡9
 %%%%% LATIN
 \newcommand¡[1]{\DeclareMathSymbol{#1}{\mathalpha}{Lmit}{`#1}} %
 \renewcommand DOESN'T WORK, XELATEX INSISTS ¡ IS UNDEFINED!
        ¡a¡b¡c¡d¡e¡f¡g¡h¡i¡j¡k¡l¡m¡n¡o¡p¡q¡r¡s¡t¡u¡v¡w¡x¡y¡z %
 \XeTeXmathcode`f=0 5`ƒ % SPECIAL CASE F DOESN'T CRASH INTO NEIGHBOURS
 EG $f^2$
        ¡A¡B¡C¡D¡E¡F¡G¡H¡I¡J¡K¡L¡M¡N¡O¡P¡Q¡R¡S¡T¡U¡V¡W¡X¡Y¡Z
 %%%% GREEK
 \newcommand¡[2]{\XeTeXmathcode`#1=0 6`#1\let#2=#1}
        ¡α\alpha¡β\beta¡γ\gamma¡δ\delta¡ε\epsilon¡ζ\zeta¡η\eta¡θ\theta¡ι\iota¡κ\kappa¡λ\lambda
        ¡μ\mu¡ν\nu¡ξ\xi¡ο\omicron¡π\pi¡ρ\rho¡σ\sigma¡τ\tau¡υ\upsilon¡φ\phi¡χ\chi¡ψ\psi¡ω\omega
        ¡ς\varsigma¡ϐ\varbeta¡ϑ\vartheta¡Ϛ\stigma¡Ϡ\sampi % SOME FONTS WON'T
 DISPLAY THESE CHARACTERS
 \newcommand¡[2]{\XeTeXmathcode`#1=7 6`#1\let#2=#1}
        ¡Α\Alpha¡Β\Beta¡Γ\Gamma¡Δ\Delta¡Ε\Epsilon¡Ζ\Zeta¡Η\Eta¡Θ\Theta¡Ι\Iota¡Κ\Kappa¡Λ\Lambda
        ¡Μ\Mu¡Ν\Nu¡Ξ\Xi¡Ο\Omicron¡Π\Pi¡Ρ\Rho¡Σ\Sigma¡Τ\Tau¡Υ\Upsilon¡Φ\Phi¡Χ\Chi¡Ψ\Psi¡Ω\Omega

 \title{\XeLaTeX: fontspec, MnSymbol, Mathematics}
 \date{}

 \begin{document}
 \maketitle

 \section*{Text}

 Brown \emph{Foxes} Jump. {\Greek Κολοσσός της Ρόδου.}

 0123456789

 \section*{Mathematics}

 \[ ABCDEFGHIJKLMNOPQRSTUVWXYZ \]
 \[ \alpha\beta\gamma\delta\epsilon\zeta\eta\theta\iota\kappa\lambda\mu%
 \nu\xi\omicron\pi\rho\sigma\varsigma\tau\upsilon\phi\chi\psi\omega\quad\varbeta\vartheta\stigma\sampi
 \]
 \[ \Alpha\Beta\Gamma\Delta\Epsilon\Zeta\Eta\Theta\Iota\Kappa\Lambda\Mu%
 \Nu\Xi\Omicron\Pi\Rho\Sigma\Tau\Upsilon\Phi\Chi\Psi\Omega \]
 \[ αβγδεζηθικλμνξοπρσςτυφχψω\quad ϐϑϚϠ \] % I CAN TYPE GREEK DIRECTLY
 INTO MATHS !!
 \[ ΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩ \]
 \[ 0123456789 \]

 \newcommand{\pp}[1]{\left(#1\right)}
 \[ abcdefghijklmnopqrstuvwxyz \]
 \[ \sum_{n=0}^{\infty}{\frac{f^{\pp{n}}\pp{a}}{n!}\pp{x-a}^n} \]

 \XeTeXmathcode`f=0 5`ƒ % COMPARE RESULT OF DIFFERENT f
 \[ abcdefghijklmnopqrstuvwxyz \]
 \[ \sum_{n=0}^{\infty}{\frac{f^{\pp{n}}\pp{a}}{n!}\pp{x-a}^n} \]

 \[ S_i^2 \]

 \end{document}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: xmn.pdf
Type: application/pdf
Size: 49628 bytes
Desc: not available
Url : http://tug.org/pipermail/xetex/attachments/20080418/5c363c44/attachment-0001.pdf 


More information about the XeTeX mailing list