Tuesday, August 18, 2009

Compiling Documents via Both LaTeX and XeLaTeX

To compile files that require XeLaTeX-specific options using LaTeX, use the \ifx\XeTeXversion\undefinedcheck.

\documentclass[a4paper,12pt]{report}

\ifx\XeTeXversion\undefined
\usepackage[utf8]{inputenc}
\else
\usepackage{fontspec}
\usepackage{xunicode}
\usepackage{xltxtra}
\setmainfont[Mapping=tex-text]{Gentium}
\fi

\begin{document}


\ifx\XeTeXversion\undefined
Hello World from LaTeX!
\else
Hello World from XeLaTeX!
\fi


\end{document}

No comments: