2

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
  \usepackage{luaotfload}
  ...
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
1

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
  \usepackage{luaotfload}
\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}
  • 1
    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
  • 1
    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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.