Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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?

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

3 Answers 3

up vote 80 down vote accepted

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

share|improve this answer
    
I've noticed the xltxtra package - is this essential or only "nice to have"? –  lockstep Sep 11 '10 at 21:26
13  
@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
5  
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
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 Aug 12 '11 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 Jun 17 '13 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}
    \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.

share|improve this answer
    
Since polyglossia-1.2 you need to set the language explicitly with \setmainlanguage instead of relying on the class/package-option. –  canaaerus Feb 16 at 13:14
    
@canaaerus Thanks, now setting the main ployglossia language explicitly. –  matth Feb 16 at 13:18

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.

share|improve this answer
5  
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 Sep 10 '10 at 21:01
    
@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. –  Konrad Rudolph Sep 11 '10 at 8:13
9  
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 Sep 11 '10 at 21:15

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.