[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
LaTeX export: when is it more useful to use LuaTeX instead of pdfTeX?
From: |
Juan Manuel Macías |
Subject: |
LaTeX export: when is it more useful to use LuaTeX instead of pdfTeX? |
Date: |
Fri, 08 Jul 2022 12:17:24 +0000 |
TL;DR: A list of use cases where using LuaTeX is more advantageous than
using pdfTeX
------------
Many times Org users who frequently need to export their documents to
LaTeX, but who do not have much LaTeX experience (or their knowledge of
the TeX ecosystem is somewhat out of date), find themselves confused by
the different versions of the TeX engine: pdfTeX, XeTeX, LuaTeX… In Org
pdfTeX is the default engine, which in 2022 has a few limitations and is
really old, but still perfectly meets the needs of a significant group
of users. However, there may be a number of cases where it is more
advantageous to compile with LuaTeX, so here I will leave a short list
of those cases where LuaTeX may be a happy choice over pdfTeX.
But first it is worth clarifying some things about LuaTeX along with
some misunderstandings:
• LuaTeX is the evolution of pdfTeX, therefore LuaTeX can be considered
as the current de facto TeX engine. It is intended to replace pdfTeX,
and in fact many of us already consider pdfTeX obsolete and
deprecated.
• To use LuaTeX it is not necessary to learn anything new or to know how
to program in Lua. LuaTeX includes a Lua interpreter and the ability
to bypass TeX primitives through Lua scripting (hence called LuaTeX).
But all of that is more on the side of developers and packagers. For
example, I am currently writing two LaTeX packages (one in
collaboration with a colleague) where 80% of the code is Lua and 20%
is (La)TeX. Of course, any user who knows Lua can take advantage of
the \directlua primitive or the luacode environment in their
documents.
• A standard LaTeX document is always a LaTeX document, regardless of
the flavor of TeX used to compile that document. There will be some
minor differences. For example, in LuaLaTeX it is unnecessary to add
fontenc and inputenc commands in the preamble.
And now we go with the non-exhaustive list of cases where compiling with
LuaTeX can be more advantageous for the user:
1. When you need to work in a *real* Unicode environment and not in
pdfTeX’s 'fake Unicode'. And, especially, when it is required to work
with languages that use a non-Latin writing system: Greek, Arabic,
Hebrew, all the languages that use Cyrillic, oriental languages, etc.
An extreme example you can see in this small code that I wrote for
LuaTeX in order to be able to use the syllabograms of the ancient
Mycenaean script:
<https://gitlab.com/maciaschain/linealb-in-luatex>
2. When using truetype or opentype fonts is required. The pdfTeX user is
limited to using only the included type1 fonts, the number of which
is very limited. Besides, type1 is a deprecated and pre-unicode
format. In fact, it almost always ends up leaving the default
Computer Modern font. In LuaTeX we can use not only all the fonts
installed on our system but also any font (just indicate the path),
which is an important advantage over XeTeX. A basic command could be
something like (loading the fontspec package):
┌────
│ \setmainfont{Palatino Linotype}
└────
And with the latest versions of Babel we can associate fonts for
different writing systems, without the need to change languages
explicitly with a \selectlanguage.
We can define all the font families we want or redefine the default
families. For example, with this command I define the default
monospaced font and request that it be scaled according to the
height of the lowercase of the main font:
┌────
│ \setmonofont{Iosevka Fixed Curly}[Scale=MatchLowercase]
└────
3. When you need to take advantage, to a greater or lesser extent, of
the opentype features of a font. For example, here we define the main
font to use old style numbers:
┌────
│ \setmainfont{Palatino Linotype}[Numbers=Lowercase]
└────
We can also load the otf tags directly:
┌────
│ \setmainfont{Palatino Linotype}[RawFeature=+onum]
└────
The fontspec package for managing fonts in LuaTeX and XeTeX is very
versatile and powerful. We can also associate a different font as
italic for an already defined font family, use different optical
resolutions of a font, etc. If what you are looking for is precise
and absolute fine-tuning of the fonts used, of course LuaTeX is the
ideal choice.
4. In general, when professional-level typographic fine-tuning is needed
(and far superior to that offered by dtp programs like InDesign or
QuarkXpress). For example, we can define on the fly new position
opentype properties for a specific font, without having to edit the
font. It is a non-destructive method that uses the
fonts.handlers.otf.addfeature lua function. For example, we can
define a new kerning value for the letters A and V. We’ll call it
’mykern’
┌────
│ \directlua{
│ fonts.handlers.otf.addfeature
│ {
│ name ="mykern",
│ type ="kern",
│ data =
│ {
│ ["A"] = { ["V"] = 270 },
│ }}
│ }
│
│ \setmainfont{Linux Libertine O}[RawFeature=+mykern]
└────
Here you can see a more bizarre and vandalistic example, where I have
replaced the accent of the accented letters in Spanish with the image of
a hammer :-)
https://i.imgur.com/iixxJmx.png
Here I have placed the image of a dancer on the tilde of the spanish
letter ñ:
https://i.imgur.com/oIZzpbJ.png
(The process is simply to decompose the complex characters from the
precombined form to their canonical decomposition: NFC > NFD, and then
use a png image as a diacritic :-):
\newunicodechar{^^^^0301}{\raisebox{1.2ex}{\includegraphics[width=.28em]{martillo.png}}}
1. Lastly, a lot of new (increasingly) LaTeX packages are written on top
of the advanced features of LuaTeX and require LuaTeX. A very useful
package, for example, is impnattypo, for post-production fine-tuning
(<https://www.ctan.org/pkg/impnattypo>). Among the many features of
impnattypo we have the ability to prevent lines from ending in
single-letter words. It also highlights in draft mode, homeoarchy
cases, which are typographically incorrect. An example in one of my
recent works:
<https://i.imgur.com/Kf8Oot0.png>
Best regards,
Juan Manuel
- LaTeX export: when is it more useful to use LuaTeX instead of pdfTeX?,
Juan Manuel Macías <=
- Re: LaTeX export: when is it more useful to use LuaTeX instead of pdfTeX?, Uwe Brauer, 2022/07/08
- Re: LaTeX export: when is it more useful to use LuaTeX instead of pdfTeX?, Greg Minshall, 2022/07/08
- Re: LaTeX export: when is it more useful to use LuaTeX instead of pdfTeX?, Thomas S. Dye, 2022/07/08
- Re: LaTeX export: when is it more useful to use LuaTeX instead of pdfTeX?, Bruce D'Arcus, 2022/07/08
- Re: LaTeX export: when is it more useful to use LuaTeX instead of pdfTeX?, Thomas S. Dye, 2022/07/08