186

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?

1

3 Answers 3

142

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

12
  • 17
    @lockstep: nowadays (TL2010) xltxtra isn't really necessary at all; all of its essential components have been incorporated into fontspec. Commented Sep 12, 2010 at 3:24
  • 1
    What about the textcomp package - is this redundant/wrong when using XeLaTeX?
    – lockstep
    Commented Sep 13, 2010 at 19:54
  • 6
    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
    Commented Sep 14, 2010 at 8:08
  • 2
    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
    Commented Aug 12, 2011 at 16:14
  • 2
    @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
    Commented Jun 17, 2013 at 8:39
55

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}
    \setmainlanguage[spelling=new,babelshorthands=true]{german}
    \usepackage{fontspec}
    \usepackage[]{unicode-math}
    \setmainfont{XITS}
    \setmathfont{XITS Math}
\else
    % default: pdfLaTeX
    \usepackage{babel}
    \usepackage[T1]{fontenc}
    %\usepackage{lmodern}
    \usepackage[adobe-utopia]{mathdesign}
    \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.

2
  • 1
    Since polyglossia-1.2 you need to set the language explicitly with \setmainlanguage instead of relying on the class/package-option.
    – bodo
    Commented Feb 16, 2014 at 13:14
  • @canaaerus Thanks, now setting the main ployglossia language explicitly.
    – matth
    Commented Feb 16, 2014 at 13:18
34

Apart from the packages you mentioned, the only difference that I have is that I don’t load the inputenc package and don’t set a font encoding.

Furthermore, you should remove any explicit driver names if you have given them in options to packages (e.g. hyperref or xcolor). These driver names are wrong at worst and redundant at best, since the packages do find the correct driver automatically when loaded within xelatex.

3
  • 7
    Thanks for reminding me that package options may also have to be modified - I've edited my question accordingly. Regarding driver name options, my understanding is that they are "bad practice" in both pfdLateX and XeLaTeX.
    – lockstep
    Commented Sep 10, 2010 at 21:01
  • 2
    @lockstep: yes, they are. But I distinctly remember that a few years ago I needed them to get things to work. Not sure if that was my own incompetence or if the packages have gotten better at recognizing the processor. Commented Sep 11, 2010 at 8:13
  • 11
    Driver options are required if and only if you want to post-process a DVI file with something other than dvips (e.g., dvipdfmx).
    – Philipp
    Commented Sep 11, 2010 at 21:15

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .