How to use the command "lualatex" (with examples)
“Lualatex” is an extended version of TeX that uses Lua to compile. It offers additional features and capabilities compared to the traditional TeX compiler. This article will guide you through various use cases of the “lualatex” command, providing examples and explanations for each case.
Use case 1: Start texlua
to act as a Lua interpreter
Code:
lualatex
Motivation:
Starting texlua
, which acts as a Lua interpreter, can be useful when you want to execute Lua scripts or interact with Lua directly. This provides a way to test and debug Lua code without having to compile an entire TeX document.
Explanation:
By simply running the command lualatex
without any arguments, the “lualatex” compiler starts the Lua interpreter, allowing you to interact with Lua directly.
Example output:
This is LuaTeX, Version 1.12.0 (TeX Live 2020)
restricted system commands enabled.
**[texlua prompt appears]**
Use case 2: Compile a TeX file to PDF
Code:
lualatex path/to/file.tex
Motivation: Often, we need to compile TeX files to generate PDF output. This use case demonstrates how to compile a TeX file using the “lualatex” compiler.
Explanation:
In this use case, the command lualatex
is followed by the path to the TeX file you want to compile. The “lualatex” compiler processes the TeX file and generates a PDF output.
Example output:
This is LuaTeX, Version 1.12.0 (TeX Live 2020)
restricted system commands enabled.
(./path/to/file.tex
LaTeX2e <2020-02-02> patch level 5
...
Output written on file.pdf (X pages, Y bytes).
Transcript written on file.log.
Use case 3: Compile a TeX file without error interruption
Code:
lualatex -interaction nonstopmode path/to/file.tex
Motivation: By default, when compiling a TeX file, any error encountered will halt the compilation process, requiring user intervention to fix the issue. In some cases, when the TeX file contains multiple errors, this can become cumbersome. The “-interaction nonstopmode” option prevents the compilation from stopping at the first error, allowing it to continue and log all errors encountered.
Explanation: This use case extends the previous example by adding the “-interaction nonstopmode” option before the path to the TeX file. This option tells the “lualatex” compiler to continue compiling the file even if errors occur, logging all encountered errors.
Example output:
This is LuaTeX, Version 1.12.0 (TeX Live 2020)
restricted system commands enabled.
**[compiling process output]**
! Undefined control sequence.
...
! LaTeX Error: Missing \begin{document}.
...
(./path/to/file.tex
LaTeX Warning: ...
Output written on file.pdf (X pages, Y bytes).
Transcript written on file.log.
Use case 4: Compile a TeX file with a specific output file name
Code:
lualatex -jobname=filename path/to/file.tex
Motivation: In some cases, we may want to specify a custom name for the output PDF file generated from the TeX file. The “-jobname” option allows us to do exactly that.
Explanation: This use case demonstrates how to compile a TeX file, but instead of using the default name for the output file, we specify a custom name using the “-jobname” option followed by the desired filename. The “lualatex” compiler will generate the PDF output file with the provided name.
Example output:
This is LuaTeX, Version 1.12.0 (TeX Live 2020)
restricted system commands enabled.
(./path/to/file.tex
LaTeX2e <2020-02-02> patch level 5
...
Output written on filename.pdf (X pages, Y bytes).
Transcript written on filename.log.
Conclusion:
The “lualatex” command offers several use cases that demonstrate the capabilities and flexibility of this extended version of TeX. Whether you need to start a Lua interpreter, compile TeX files to PDF, handle errors, or specify custom output file names, the “lualatex” command provides a versatile solution. By exploring and utilizing these use cases, you can effectively harness the power of “lualatex” for your TeX document compilation needs.