I'm currently typesetting my lecture notes for classical electrodynamics using the tufte-book
class and XeLaTeX.
This is my first time using XeLaTeX and so I stumbled upon the two packages unicode-math
and mathspec
, when it came to include an OpenType math font (here TeX Gyre Pagelle Math).
I browsed the documentation of the two packages a little bit, but wasn't able to find out, which is the "better practice" to use.
Question: Should I use unicode-math
or mathspec
for my XeLaTeX documents?
Best Answer
(Please note that this answer has been revised to reflect issues raised in the comments.)
unicode-math
The
unicode-math
andmathspec
packages have very different goals. Theunicode-math
package is designed to map math markup into unicode characters as supplied by real OpenType math fonts such as the Latin Modern Math, STIX, Asana Math. It also allows (as much as makes sense/is possible) Unicode input of math, as well as output so that you can enter unicode math characters in the source and have them be interpreted correctly as math by TeX.For example, you could create the following document:
which would produce
The
unicode-math
package is compatible with both XeTeX and LuaTeX.mathspec
The
mathspec
package is not designed to allow you to use unicode characters in your source math input. Instead it is designed to allow you to use open-type fonts within math so that you can, for example, match the text font of your math with the text font in your document.So for example you can use:
which will produce:
The
mathspec
package can only be used with XeTeX; it cannot be used with LuaTeX.Which should you use
If you want to use one of the available OpenType math fonts, then using
unicode-math
makes sense.If you want to match a non-math font with the math font then
mathspec
can help, but because TeX does not apply kerning between characters from different fonts, usingmathspec
has its drawbacks, since you may find places in which the switch from the text font to the math font produces bad spacing, as in the example given.