# How to detect LuaLaTex inside my .tex file and exclude bits and pieces conditionally

Let me state my "problem" first. When using PdfLateX my .tex file compiles rather swiftly and all is fine. I use TeXStudio and make use of the PDF preview feature. Since my LaTeX fu isn't the strongest, I compile quite often (to see if I broke something recently; and yes I make use of a version control system as well).

Now using PdfLaTeX we're talking about 3 to 3.5 seconds for it to compile.

Recently I added \usepackage{fontawesome} which apparently requires XeLaTex or LuaLaTex. Trying out the two options only LuaLaTeX was left, as the other one errored out.

I use the fontawesome package to get a symbol for external links onto each \href for which I define my own command, though (see below).

Now what I noticed once I switched to LuaLaTeX was that it takes considerably longer to compile the document: 10 seconds.

So my thought process was the following: if I could detect the presence of LuaLaTeX, I could conditionally include the parts that are "offending" to PdfLaTeX.

Is it possible to do that, i.e. distinguish between PdfLaTeX and LuaLaTeX?

### Without fontawesome

\documentclass[12pt,a4paper,oneside]{book}
% ... a bunch of packages, including hyperref
% ... actual document


### With fontawesome

\documentclass[12pt,a4paper,oneside]{book}
% ... a bunch of packages
\usepackage{fontawesome}
% ... more packages, including hyperref
% ... actual document


Yes, I realize that this "complaint" about speed is laughable with respect to the speeds from some years ago. But if not for the speed, please consider answering it to satisfy my curiosity.

• Independently of your question, you’re not necessarily doing yourself a favour by switching engines for the sake of a single symbol. – Arthur Reutenauer May 27 '15 at 10:31
• @ArthurReutenauer: care to explain? I guess I don't know enough to even appreciate your comment. Any pointers to documentation? I always thought of LuaTeX as more or less a preprocessor. – 0xC0000022L May 27 '15 at 10:33
• It’s not. It’s a completely different TeX engine (incidently based, amongst others, on pdfTeX). It’s not meant to be fully compatible and if you have longish documents, you should probably check carefully that the output of LuaTeX is satisfactory to you before switching. – Arthur Reutenauer May 27 '15 at 10:36
• @ArthurReutenauer: thanks for the clarification. Then I guess I need to read a little more about how they all differ. – 0xC0000022L May 27 '15 at 10:39

Use the ifluatex package.

\documentclass{article}
\usepackage{ifluatex}
\begin{document}
\ifluatex
hello
\else
goodbye
\fi
\end{document}

• wow, that's a swift response. Thanks. So that package also works without LuaTeX then? Let me just try and get back here :) – 0xC0000022L May 27 '15 at 10:29
• Well, obviously it works with all engines. What would be the point of a package to detect engines if it only worked with some of them? – Arthur Reutenauer May 27 '15 at 10:30
• @ArthurReutenauer: yeah, in my life I have learned that common sense isn't so common after all, so I decided to ask. Tested it also and it works. – 0xC0000022L May 27 '15 at 10:32

If you want to differentiate between PDF-, Xe- and Lua(La)TeX, you might want consider the iftex package which provides the commands \ifPDFTeX, \ifXeTeX and \ifLuaTeX.