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?
-
10Related question -- the same for LuaLaTeX: Frequently loaded packages: Differences between pdfLaTeX and LuaLaTeX– doncherryCommented Sep 22, 2012 at 19:37
3 Answers
- Don't load
inputenc
orfontenc
manually; use UTF-8 input and thefontspec
package instead - Don't load the
textcomp
package; if you want macros to enter varios symbols, load thexunicode
package (EDIT BY LOCKSTEP: According to Ulrike Fischer, "[i]n a current system you don't need to loadxunicode
at all,fontspec
will do it at the correct place") - Use
polyglossia
instead ofbabel
- For OpenType math support, use
unicode-math
instead ofamsfonts
/amssymb
etc. (butamsmath
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
, which requires XeTeX.
-
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
-
1What about the
textcomp
package - is this redundant/wrong when using XeLaTeX?– lockstepCommented Sep 13, 2010 at 19:54 -
6The
textcomp
package provides access to symbols from the TS1 encoding. In XeLaTeX, these can be directly entered or accessed via the macros from thexunicode
package. So I'd say thattextcomp
is wrong and should be left out or replaced byxunicode
.– PhilippCommented 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 withoutunicode-math
, e.g. Latin Modern by default. And font packages likeeuler
,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 LiuCommented 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).– ogerardCommented Jun 17, 2013 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.
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
.
-
7Thanks 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.– lockstepCommented 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
-
11Driver options are required if and only if you want to post-process a DVI file with something other than
dvips
(e.g.,dvipdfmx
).– PhilippCommented Sep 11, 2010 at 21:15