[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Choosing a LaTeX Compiler (my predilection for LuaTeX)

From: Diego Zamboni
Subject: Re: Choosing a LaTeX Compiler (my predilection for LuaTeX)
Date: Wed, 7 Apr 2021 16:16:27 +0200

Hi Juan Manuel,

Thank you for writing this, which is the clearest explanation I have seen of the advantages of LuaLaTeX/XeLaTeX. I have been using LaTeX for nearly 30 years, but stopped using it intensively every day when pdfLaTeX was still the bleeding edge. When I started again in the last couple of years, it has been a bit confusing to understand why and what all these different versions are. These days I use LuaLaTeX as well, but most of the documents I process are exported from Org-mode.


On Mon, Apr 5, 2021 at 10:49 PM Juan Manuel Macías <maciaschain@posteo.net> wrote:
Hi all,

There have been some threads recently about exporting to LaTeX, but I
think something that I consider interesting for novice Org/LaTeX users
has not been commented: the choice of the TeX engine. I think this is
important because although people often say they "use LaTeX", what they
actually use is TeX via the La-TeX format. What TeX engine to choose? I
would dare to say the following: unless you want to maintain some
backward compatibility with old documents, I highly recommend using
LuaTeX or XeTeX, especially LuaTeX. Although pdfTeX is very popular
among average or veterans LaTeX users, I think using it nowadays doesn't
make much sense (IMHO). LuaTeX is the natural evolution of pdfTeX and
adds the great advantage of accesing the TeX internals through Lua

(What follows is specially intended for those Org users who haven't used
XeTeX or LuaTeX yet).

LuaTeX and XeTeX are *100% Unicode-based* and you can use your system
fonts (open type, true type, etc.) in your documents in a simple way
through the fontspec (https://www.ctan.org/pkg/fontspec) package, which
provides a very neat interface and manages all OpenType features (LuaTeX
and XeTeX use HarfBuzz as otf rendering engine). In LuaTeX also you can
use any font that is not installed in your system: just indicate the
path to the fonts files. This is very useful to test new fonts without
installing them... In all modern word processing systems the user has
always been able to pick a font easily, and that has been historically
quite complex, hard and complicated in the (La)TeX ecosystem.

For example, if we want to use globally the Palatino Linotype family in
our LuaLaTeX document:

\setmainfont{Palatino Linotype}

We can add some OpenType features, like old style numbering:

\setmainfont{Linux Libertine O}[Numbers=LowerCase]

And if we want to use another font for italics, with certain properties
(color[1] and scaling):


([1] Requires the xcolor package)

We can also define our own family with its properties (for example, with
upper case numbers and letters tracking):


Furthermore (for more advanced users), in LuaTeX we can define new
opentype features on the fly, both positional and of substitution (as
long as the typeface includes the glyphs needed to replace). For
example, if I use the Crimson typeface, a contextual substitution for
character Q + u can be defined, by including some Lua code through the
LuaTeX primitive `directlua':

    name = "mycontextual",
    type = "chainsubstitution",
    lookups = {
        type = "substitution",
        data = "">           ["Q"] = "Q.alt01",
    data = "">       rules = {
          after  = { { "u" } },
          current = { { "Q" } },
          lookups = { 1 },

... And add anywhere in the text:


If I had to choose, finally, between XeTeX and LuaTeX, I would choose
LuaTeX, for things like these and many other reasons. In addition, there
are emerging cool new packages that only work with LuaTeX.

Anyway, XeTeX is another very good option too, especially for users who
prefer something that works more "out of the box" and is less esotheric
than LuaTeX.

To export to PDF always with LuaTeX we can put in our ~ /.emacs:

(setq org-latex-pdf-process
      '("lualatex -shell-escape -interaction nonstopmode -output-directory %o %f"
        "lualatex -shell-escape -interaction nonstopmode -output-directory %o %f"
        "lualatex -shell-escape -interaction nonstopmode -output-directory %o %f"))

Or with latexmk, which will take care of compiling as many times as
necessary for indexes, bibliographies, etc .:

(setq org-latex-pdf-process
      '("latexmk -lualatex -e '$lualatex=q/lualatex %%O -shell-escape %%S/' %f"))

Best regards,

Juan Manuel

reply via email to

[Prev in Thread] Current Thread [Next in Thread]