# Using LuaTeX as a replacement for pdfTeX

In this question Differences between LuaTeX, ConTeXt and XeTeX various differences between LuaTeX and XeTeX (and ConTeXt) are discussed. And in this question Using XeLaTeX instead of pdfLaTeX a recipe for switching from pdfLaTeX to XeLaTeX is given. In this question, I would like a similar recipe for using LuaLaTeX. I'm particularly interested in the degree to which LuaTeX can be used as a drop-in replacement for pdfTeX. I'm not interested in things that LuaTeX can do that pdfTeX can't.

So the question is:

What do I need to do to use LuaLaTeX instead of pdfLaTeX to compile existing or new documents?

Some specific sub-questions:

1. What packages are compatible with pdfLaTeX but not with LuaLaTeX?
2. Are there any packages specific to LuaLaTeX that should be loaded in most LuaLateX documents?
-
See lualatex-doc. – Martin Schröder Oct 22 '11 at 12:12
@MartinSchröder Thanks! I had found the LuaTeX reference document, but I didn't realize this document existed too. It's very helpful. – Alan Munn Oct 22 '11 at 13:23

I think we don't need to do much. The only incompatible thing I know is the UTF-8 encoding.

1. Any package related to input encodings and font encodings:

• inputenc. You should always use UTF-8 encoding to input the text. For backward compatibility, use luainputenc instead.
• fontenc. Don't use it with fontspec explictly.
• textcomp. Use xunicode instead, which is loaded by fontspec.
• Most old font packages (esp. for text fonts) are better not to be used. For example, use XITS, TeX Gyre Termes or Linux Libertine O fonts with fontspec instead of times package, and use Unicode fonts for main text together with mathptmx and txfonts (font math fonts only) to get proper text fonts.
• CJK is not compatible with LuaTeX. Today only a few unofficial LaTeX packages in Korea and Japan are available. This may be not very important for western users.
2. fontspec. To load TrueType/OpenType fonts. This is the only necessary one, I think. Also, luacode and unicode-math are useful.

-
I'm not quite sure about your font statement. Unicode maths fonts are only now approaching completion, so you may well still want to load something like mathptmx for the maths font, then set the text font using fontspec. – Joseph Wright Oct 22 '11 at 6:24
@Khaled Hosny: I said, that we need packages like libertine.sty for the normal user! Not every user is interested in loading fonts like \setmainfont[ItalicFont=Georgia Italic]{Chalkduster.ttf} ... – Herbert Oct 22 '11 at 16:04
@Herbert: but I disagree, as a normal user I want to just load the font I want, not wait for someone to write a package for me, and mixing roman and italic from different typefaces is not a common use case, and certainly not what a normal user would want. – Khaled Hosny Oct 22 '11 at 16:24
@Khalid: I must say I agree with here. It is great that luatex and xetex now give you the power to shoot yourself to the foot by selecting any horribly clashing combination of fonts and sizes. I am all for it, on the other hand, there are combinations of fonts that are very good match, and having packages that make using such combination as easy would definitely be a plus. After all, the new engines should not make selecting a well designed and balanced combination of fonts harder than it was in the old engines, especially as it is entirely possible to have both ways. – Jan Hlavacek Oct 22 '11 at 16:41
@GTK: luatexja does the stuff. It's rather new package, but usable. – Leo Liu Aug 11 '12 at 5:49

One thing you need to consider is:

If you are using (either directly or indirectly) pdftex primitives like e.g. \pdffilemoddate (see the pdftex manual) with LuaLaTeX then you need to load Heiko Oberdiek's pdftexcmds package which adds all these commands currently missing in LuaTeX. However, these are provided as macros not as primitives and therefore do not react 100% the same way. For example \pdffilemoddate requires one expansion step more. I programmed my filemod package accordantly to load it automatically for LuaLaTeX, but other packages might not check these commands so strictly.

I don't think this is an huge issue for most documents, but definitively worth mentioning.

-

AFAIK, the recipe is the same as for "Using XeLaTeX instead of pdfLaTeX". Generally, what works in XeLaTeX should work in luaLaTeX also. Some packages are not fully compatible between them, some new packages for XeLaTeX are still missing from luaLaTeX, but they stay as close as possible (with exception of access to lua of course).

-