# Include preamble statements depending on compiler

I am trying different compilers like pdfLatex, luaLatex, latex to try differences in compiling things like pgfplots. But when i shange the compiler I also need to change the preamble. How can i do something like this pseudo-code:

if compiler == lualatex
...
elseif compiler == pdflatex
\usepackage[utf8]{inputenc}
...
fi


to avoid repetitively commenting and uncommenting code?

• Packages ifluatex and ifpdf? – user31729 Jul 1 '15 at 15:14

The packages ifluatex provide for \ifluatex and ifpdf for \ifpdf statements.

Use it \ifluatex ... \else ... \fi

(\ifpdf as well)

\documentclass{article}

\usepackage{ifluatex}
\usepackage{ifpdf}

\ifluatex
\else
\ifpdf
\usepackage[utf8]{inputenc}
\typeout{PDF only}
\fi
\fi

\begin{document}

\ifluatex
Yeah, it's lualatex
\else
\ifpdf
Hooray, it's pdflatex
\fi
\fi

\end{document}

• Note that \ifpdf only checks whether the output is PDF or DVI, so it's true when lualatex is used. – egreg Jul 1 '15 at 15:43
• There is also the ifxetexpackage. – Bernard Jul 1 '15 at 16:01
• Thanks Christian, that did the job! And thanks egreg, that explains why the suggested structure worked and two separate statements gaver errors when using Lua. – Jonatan Öström Jul 2 '15 at 11:14