How to use the command 'lualatex' (with examples)
Luatex is a versatile typesetting system that extends TeX, a highly popular and powerful tool for formatting documents, particularly used in academia and publishing. By integrating Lua, a lightweight programming language, LuaLaTeX provides enhanced scripting capabilities. This makes it easier to automate tasks and integrate additional functionalities into document processing workflows. It is particularly favored for creating complex publications, mathematical documents, and professional-grade PDFs from TeX files.
Use case 1: Using lualatex
as a Lua Interpreter
Code:
lualatex
Motivation:
Sometimes, users may want to run Lua code directly without opening a separate Lua interpreter. This could be useful for testing small Lua scripts, learning Lua programming, or debugging custom scripts designed to interact with TeX documents. Using LuaLaTeX as a Lua interpreter simplifies the process by providing an integrated environment.
Explanation:
By running lualatex
without any additional arguments, the command starts the texlua
interpreter mode. This mode allows users to enter Lua code interactively or run Lua scripts, leveraging LuaLaTeX’s built-in Lua capabilities.
Example output:
$ lualatex
This is LuaTeX, Version 1.12.0 (TeX Live 2020/W32TeX)
** _
Use case 2: Compiling a TeX file to PDF
Code:
lualatex path/to/file.tex
Motivation:
Compiling a TeX file into a PDF is perhaps the most common use of LuaLaTeX. This is typically done when users want to produce high-quality, typeset documents for professional or academic purposes, such as resumes, research papers, books, or presentations.
Explanation:
lualatex
: This invokes the LuaLaTeX command.path/to/file.tex
: This specifies the path to the TeX source file that needs to be compiled into a PDF. The path can be either absolute or relative.
Example output:
$ lualatex path/to/file.tex
This is LuaTeX, Version 1.12.0 (TeX Live 2020/W32TeX)
(Set various fonts)
(/path/to/document.cls
No file document.aux.
(/path/to/document.aux) )
Output written on document.pdf (1 page, 5430 bytes).
Transcript written on document.log.
Use case 3: Compile a TeX file without error interruption
Code:
lualatex -interaction nonstopmode path/to/file.tex
Motivation:
While compiling complex documents, it’s not uncommon to encounter minor errors that do not necessarily impede the final output but could stop the compilation process. Using non-stop mode allows the document to be compiled fully without pausing at each error, hence reducing manual intervention.
Explanation:
-interaction nonstopmode
: This option tells LuaLaTeX to continue processing despite errors, only logging them instead of halting execution.path/to/file.tex
: As before, this indicates the path to the TeX file to be processed.
Example output:
$ lualatex -interaction nonstopmode path/to/file.tex
This is LuaTeX, Version 1.12.0 (TeX Live 2020/W32TeX)
(Set various fonts)
(/path/to/document.cls
Warning: Error detected (continued in non-stop mode)
...
Output written on document.pdf.
Transcript written on document.log.
Use case 4: Compile a TeX file with a specific output file name
Code:
lualatex -jobname=filename path/to/file.tex
Motivation:
By default, the PDF output file name matches the TeX file’s base name. However, users may need to specify a different output name to avoid overwriting files, organize outputs more efficiently, or conform to file naming conventions required in a specific context.
Explanation:
-jobname=filename
: This option defines the name of the output file, omitting the file extension.path/to/file.tex
: This specifies the TeX file to be compiled.
Example output:
$ lualatex -jobname=newfile path/to/file.tex
This is LuaTeX, Version 1.12.0 (TeX Live 2020/W32TeX)
...(compilation details)...
Output written on newfile.pdf (1 page, 5430 bytes).
Transcript written on newfile.log.
Conclusion:
LuaLaTeX provides a powerful means of compiling TeX files into professionally formatted PDFs while offering flexibility through its integration with Lua scripting. Whether used for simple document compilation or more complex processing tasks, LuaLaTeX caters to various needs through its robust command-line options. This article illustrated four practical use cases of LuaLaTeX’s capabilities, offering a starting point for users looking to leverage this powerful tool in their document preparation workflows.