# Frequently loaded packages: Differences between pdfLaTeX and XeLaTeX

Until now, I have been compiling my LaTeX documents with pdfLaTeX. My standard document preamble includes the "usual suspects" for non-English speakers (inputenc, fontenc, babel) and a bunch of other packages. Assuming I were to convert to XeLaTeX, what modifications of my preamble are advisable? I'm aware that the expansion=true option of the microtype package is not (yet) available for XeLaTeX, and that fontspec is sort of a default package for OpenType fonts. What other packages (and package options) should be removed and, vice versa, incorporated when switching from pdfLaTeX to XeLaTeX?

-
Related question -- the same for LuaLaTeX: Frequently loaded packages: Differences between pdfLaTeX and LuaLaTeX –  doncherry Sep 22 '12 at 19:37

• Don't load inputenc or fontenc manually; use UTF-8 input and the fontspec package instead
• Don't load the textcomp package; if you want macros to enter varios symbols, load the xunicode package (EDIT BY LOCKSTEP: According to Ulrike Fischer, "[i]n a current system you don't need to load xunicode at all, fontspec will do it at the correct place")
• Use polyglossia instead of babel
• For OpenType math support, use unicode-math instead of amsfonts/amssymb etc. (but amsmath can/should still be used).
• The xltxtra package isn't necessary any more

Everything in this list is probably valid for LuaLaTeX, too, with the exception of xunicode and polyglossia, which require XeTeX.

-
I've noticed the xltxtra package - is this essential or only "nice to have"? –  lockstep Sep 11 '10 at 21:26
@lockstep: nowadays (TL2010) xltxtra isn't really necessary at all; all of its essential components have been incorporated into fontspec. –  Will Robertson Sep 12 '10 at 3:24
The textcomp package provides access to symbols from the TS1 encoding. In XeLaTeX, these can be directly entered or accessed via the macros from the xunicode package. So I'd say that textcomp is wrong and should be left out or replaced by xunicode. –  Philipp Sep 14 '10 at 8:08
amssymb and other math font packages can still be used. In fact, usually we still use Type1 fonts without unicode-math, e.g. Latin Modern by default. And font packages like euler, txfonts, cmbright, mathdesign ... are still very useful when using XeTeX. There are only very few OpenType math fonts, AFAIK only 4 are free: LM, Asana, XITS, Euler. –  Leo Liu Aug 12 '11 at 16:14
@JLDiaz : the latest versions of polyglossia (1.3.x May 2013) are compatible with LuaLaTeX. They are included in TexLive 2013 (currently under test). –  ogerard Jun 17 at 8:39

Trying to implement all the answers and comments given in this thread using the ifxetex package, I ended up with the following code for my preamble. It allows to switch forth and back anytime between pdflatex and xelatex as compiler. Note: When switching the compiler, one should delete the aux files.

\documentclass[
a4paper,
ngerman
]{scrbook}

\usepackage{amsmath}

\usepackage{ifxetex}
\ifxetex
% XeLaTeX
\usepackage{polyglossia}
\usepackage{fontspec}
\usepackage[]{unicode-math}
\setmainfont{XITS}
\setmathfont{XITS Math}
\else
% default: pdfLaTeX
\usepackage{babel}
\usepackage[T1]{fontenc}
%\usepackage{lmodern}
\usepackage[utf8]{inputenc}
\usepackage[babel=true]{microtype}
\fi

% some more packages like csquotes, biblatex, hyperref

\begin{document}
...
\end{document}

I had to load the amsmath package before the xelatex setmathfont command to avoid the error \dddot already defined. With MiKTeX 2.9 one has to manually install the XITS fonts using the MiKTeX package manager.

-