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?
- 250,273
-
10Related question -- the same for LuaLaTeX: Frequently loaded packages: Differences between pdfLaTeX and LuaLaTeX – doncherry Sep 22 '12 at 19:37
3 Answers
- Don't load
inputencorfontencmanually; use UTF-8 input and thefontspecpackage instead - Don't load the
textcomppackage; if you want macros to enter varios symbols, load thexunicodepackage (EDIT BY LOCKSTEP: According to Ulrike Fischer, "[i]n a current system you don't need to loadxunicodeat all,fontspecwill do it at the correct place") - Use
polyglossiainstead ofbabel - For OpenType math support, use
unicode-mathinstead ofamsfonts/amssymbetc. (butamsmathcan/should still be used). - The
xltxtrapackage isn't necessary any more
Everything in this list is probably valid for LuaLaTeX, too, with the exception of xunicode, which requires XeTeX.
-
I've noticed the
xltxtrapackage - is this essential or only "nice to have"? – lockstep Sep 11 '10 at 21:26 -
17@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 03:24
-
1What about the
textcomppackage - is this redundant/wrong when using XeLaTeX? – lockstep Sep 13 '10 at 19:54 -
6The
textcomppackage provides access to symbols from the TS1 encoding. In XeLaTeX, these can be directly entered or accessed via the macros from thexunicodepackage. So I'd say thattextcompis wrong and should be left out or replaced byxunicode. – Philipp Sep 14 '10 at 08:08 -
-
fontenccan be used for Type1 fonts in old font encoding. In factfontspecitself loadsfontencand setEU1as default encoding. It's OK to use more font encodings likeT1,LY1, etc. – Leo Liu Aug 12 '11 at 16:04 -
2
amssymband 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 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 08: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.
- 12,381
-
1Since
polyglossia-1.2you need to set the language explicitly with\setmainlanguageinstead of relying on the class/package-option. – bodo Feb 16 '14 at 13:14 -
@canaaerus Thanks, now setting the main ployglossia language explicitly. – matth Feb 16 '14 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.
- 39,394
- 22
- 107
- 160
-
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. – lockstep Sep 10 '10 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. – Konrad Rudolph Sep 11 '10 at 08: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). – Philipp Sep 11 '10 at 21:15