I would like to be able to rely on the code in my document class to respond correctly to whether it is being rendered using pdfLaTeX or XeTeX engines. The editor I'm using (LyX) does this using several settings established through the document properties dialog, but I'd like to have a document class that configures itself correctly in response the the active engine alone, without requiring additional (editor specific) settings.
For example, I would like to be able to write something like:
\@ifundefined{XeTeXversion}{
% (1) Ensure that fontspec is not loaded
\usepackage[T1]{fontenc} % (*) In LyX, this is set in document properties, by un-checking Fonts > Use non-Tex fonts
\usepackage[latin9]{inputenc}
%...
\usepackage{tgpagella}
%...
\usepackage[protrusion=true]{microtype}
% (2) Possible additional engine-sepcifc packages and options
}{%
% (1) Ensure that fontenc is not loaded
\usepackage{fontspec} % (*) In LyX, this is set in document properties, by checking Fonts > Use non-Tex fonts
%...
\defaultfontfeatures{Mapping=tex-text}
\setromanfont[Ligatures=TeX]{Palatino}
%...
\usepackage{xunicode}
% (2) Possible additional engine-sepcifc packages and options
}
While, I can get this to work if I explicitly switch between fontspec and fontenc using LyX's settings in the LyX UI (*), I'm left with two questions:
- Is checking
XeTeXversiona reliable way to determine that XeTeX is in use? - Is there a way to (1) disable or "unload"
fontspecorfontencin code like the example above to override what LyX may be doing in the absence of specific (*) settings in the UI? - Are there common engine-specific packages or package options I should be using (or avoiding) when switching between pdfLaTeX and XeTeX (2).
microtypewith XeTeX? – Brent.Longborough Feb 20 '12 at 01:18microtype-- still the "official" version -- does not support XeTeX. Version 2.5 ofmicrotype, currently in advanced beta, does support protrusion but none of the other features of the package when run under XeTeX. (Under LuaLaTeX, the new version supports protrusion, font expansion, and letterspacing.) Version 2.5 (beta 8) is available online at http://tlcontrib.metatex.org/cgi-bin/package.cgi/action=view/id=569. – Mico Feb 20 '12 at 02:17