# Switching from LaTeX to XeLaTeX - fontspec and unicode-math defaults

I'm currently switching from LaTeX to XeLaTeX and I personally like to write down the defaults in my default preamble to be able to modify some slight things (but not accidentally changing everything).

So far I didn't found the default fonts for fontspec and unicode-math (somehow quite the only packages to add when using XeLaTex besides xltxtra right? Sorry for the side question but it can be really confusing to get what has to be changed when doing the switch). Can someone help me out on this?

• The default text font is Latin Modern. – Bernard Dec 1 '20 at 14:16
• xltxtra is not recommended now. Just use fontspec directly. – David Carlisle Dec 1 '20 at 20:22
• Oh then that't one of these things one often reads in older docs I guess. Thanks for the hint – atticus Dec 1 '20 at 20:33

fontspec sets hundreds of things and unicode-math thousands, but I assume you mean the main user-settable fonts that you might want to change.

fontspec defaults to Latin Modern so more or less the same as

    \setmainfont{Latin Modern Roman}


which is the same font as used if the package is not loaded (the family name is lmr with the default settings but it is the same font)

fc-list gives the following locations in texlive 2020

/usr/local/texlive/2020/texmf-dist/fonts/opentype/public/lm/lmroman10-regular.otf: Latin Modern Roman,LM Roman 10:style=10 Regular,Regular


and

/usr/local/texlive/2020/texmf-dist/fonts/opentype/public/lm-math/latinmodern-math.otf: Latin Modern Math:style=Regular


unicode-math defaults to latin modern math so

\setmathfont{Latin Modern Math}


which is not the same as not using the package, the default math font in xelatex is the 7 bit Computer Modern and the classic tfm math layout not the OpenType math layout.

Depending on your font-config settings you may want to use the filename rather than the internal fontname so

lmroman10-regular.otf and latinmodern-math.otf in the above commands.

\documentclass{article}
\usepackage{unicode-math}

% \setmainfont{Latin Modern Roman}
\setmainfont{lmroman10-regular.otf}

% \setmathfont{Latin Modern Math}
\setmathfont{latinmodern-math.otf}

\begin{document}

\end{document}

• @atticus most basic "as described in the latex book" documents "just work", many packages (hyperref,graphicx,tikz, etc) detect the engine and do the right thing automatically so you do not need to change anything, but if your document was full of pdftex specific extensions such as \pdfliteral or \pdfinfo etc then those primitives will not work (but normally you should never use those primitives directly anyway) so it all depends.... – David Carlisle Dec 1 '20 at 15:16
• @atticus luatex is much closer to pdftex (and in fact was derived from it) if you are looking for a unicode tex that is "close" to pdftex. – David Carlisle Dec 1 '20 at 15:18
• @atticus well that's weird sorry!! I even had a test file but I managed to copy the line incorrectly.. Roman not Regular. – David Carlisle Dec 1 '20 at 19:34
• @atticus I extended the answer to give filename as well as fontname versions. – David Carlisle Dec 1 '20 at 19:42
• @atticus that probably means fontconfig has found the wrong (older?) font, what path does fc-list 'Latin Modern Math report? – David Carlisle Dec 1 '20 at 19:48