[XeTeX] How to write a header for XeTeX, pdfTeX, and dvips/dvipdfm

Peter Dyballa Peter_Dyballa at Web.DE
Sun Nov 25 12:09:53 CET 2007


Hello!

The body of a LaTeX document can be assumed to be independent of the  
"machine" that actually converts the mixture of text and graphics  
with commands/macros to some output. But how would one set up the  
part before \begin{document}, where the use of fonts is declared or  
logos are defined (\XeTeX and \XeLaTeX should also work outside  
XeTeX) or micro-typography is arranged or hyper-references are set  
up? Such a construct would be perfect for testing whether XeLaTeX and  
LaTeX produce different results with different "machines." This  
example seems to be a good start:

	\documentclass[11pt]{article}
	\usepackage{ifpdf,ifxetex,graphicx}
	\usepackage[ngerman]{babel}
	\ifxetex
	     \immediate\write16{==In XeTeX==}
	  \usepackage{fontspec,xltxtra,xunicode}
	  \defaultfontfeatures{Mapping=tex-text}
	  \setromanfont{Lucida Bright}
	  \setsansfont{Lucida Sans}
	  \setmonofont{Lucida Sans Typewriter}
	  \usepackage{hyperref}
	\else
	     \immediate\write16{==No XeTeX==}
	  \usepackage[utf8]{inputenc}
	  \ifpdf
	       \immediate\write16{\jobname: Bonjour, PDF!}
	    \usepackage{cmap}
	    \usepackage[activate={true,nocompatibility}]{microtype}
	%    \usepackage[protrusion=true,expansion=true]{microtype}
	    \usepackage{PDF-Fonts}
	    \usepackage{hyperref}
	  \else
	       \immediate\write16{¡Hola \jobname: DVI!}
	%    \DeclareGraphicsExtensions{.ps,.eps,.png,.gif,.jpeg}
	    \usepackage[protrusion=true,expansion=false]{microtype}
	    \usepackage{DVI-Fonts}
	  \fi
	  \usepackage[T1]{fontenc}
	%  space for \XeTeX, \XeLaTeX ... definitions
	\fi

Anything better?

--
Greetings

   Pete

"No man was ever taken to hell by a woman unless he already had a  
ticket in his pocket, or at least had been fooling around with  
timetables."
                                        -- Archie Goodwin




More information about the XeTeX mailing list