emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Matt Huszagh <huszaghmatt@gmail.com>
To: "Juan Manuel Macías" <maciaschain@posteo.net>,
	orgmode <emacs-orgmode@gnu.org>
Subject: Re: LaTeX export:  when is it more useful to use LuaTeX instead of pdfTeX?
Date: Fri, 08 Jul 2022 17:34:23 -0700	[thread overview]
Message-ID: <87tu7r5dkg.fsf@gmail.com> (raw)
In-Reply-To: <87ilo7ztm3.fsf@posteo.net>

Juan Manuel Macías <maciaschain@posteo.net> writes:

> 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

I typically use luatex instead of pdftex and the sole reason is
performance for pgfplots. The performance gain is night and day when
generating plots with many points. I forget exactly why this is.

When I'm generating very simple documents I stick with pdftex, which is
faster in those cases.

As for lua scripting: I made some brief forays into this but found it
not to be especially useful for me: the reason for that may just have
been lack of persistent effort, though. When I want more modern
programming features I typically use pylatex.

Matt


      parent reply	other threads:[~2022-07-09  0:35 UTC|newest]

Thread overview: 55+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-08 12:17 LaTeX export: when is it more useful to use LuaTeX instead of pdfTeX? Juan Manuel Macías
2022-07-08 15:49 ` Uwe Brauer
2022-07-08 16:46   ` Juan Manuel Macías
2022-07-08 15:54 ` Greg Minshall
2022-07-08 16:13 ` Thomas S. Dye
2022-07-08 17:27 ` Bruce D'Arcus
2022-07-08 19:03   ` Juan Manuel Macías
2022-07-08 18:49 ` Thomas S. Dye
2022-07-09  2:23   ` Max Nikulin
2022-07-09  3:23     ` Thomas S. Dye
2022-07-09 11:10       ` Juan Manuel Macías
2022-07-09  3:24     ` Tim Cross
2022-07-09  3:50       ` Ihor Radchenko
2022-07-09  4:10         ` Tim Cross
2022-07-09  5:35           ` Dominik Schrempf
2022-07-09  6:31         ` Max Nikulin
2022-07-09  9:59       ` Juan Manuel Macías
2022-07-09 23:49         ` Tim Cross
2022-07-10 11:19           ` M-x org-create-worg-article command? (was: LaTeX export: when is it more useful to use LuaTeX instead of pdfTeX?) Ihor Radchenko
2022-07-10 19:06             ` Tim Cross
2022-07-11  2:09               ` Ihor Radchenko
2022-07-11  2:49                 ` Tim Cross
2022-07-11  3:18                   ` Ihor Radchenko
2022-07-11  4:00                     ` Tim Cross
2022-07-11  4:20                       ` Ihor Radchenko
2022-07-10 19:31           ` LaTeX export: when is it more useful to use LuaTeX instead of pdfTeX? Juan Manuel Macías
2022-07-09 10:42     ` Juan Manuel Macías
2022-07-09 12:15       ` Max Nikulin
2022-07-09 14:58         ` Juan Manuel Macías
     [not found]           ` <b58ee3cc-c58c-b627-9cc5-51993020db2c@gmail.com>
2022-07-09 20:22             ` Juan Manuel Macías
2022-07-10 20:23               ` [possible patch] Basic fontspec code for LuaLaTeX and XelaTeX (was "LaTeX export: when is it more useful...") Juan Manuel Macías
2022-07-10 20:31                 ` Juan Manuel Macías
2022-07-10 20:58                 ` Tim Cross
2022-07-11 13:34                   ` Juan Manuel Macías
2022-07-11  2:19                 ` Ihor Radchenko
2022-07-11  7:50                   ` Stefan Nobis
2022-07-11 14:19                   ` Timothy
2022-07-11 15:00                     ` Juan Manuel Macías
2022-07-11 17:45                       ` fontsets (was: [possible patch] Basic fontspec code for LuaLaTeX and XelaTeX (was "LaTeX export: when is it more useful...")) Timothy
2022-07-11 22:09                         ` fontsets Juan Manuel Macías
2022-07-12  7:12                           ` fontsets Stefan Nobis
2022-07-12 11:37                             ` fontsets Juan Manuel Macías
2022-07-12 15:26                               ` Fallback fonts in LuaTeX via 'luaotfload.add_fallback' (was "Fontsets") Juan Manuel Macías
2022-07-15 14:35                                 ` Max Nikulin
2022-07-11  3:59                 ` [possible patch] Basic fontspec code for LuaLaTeX and XelaTeX (was "LaTeX export: when is it more useful...") Greg Minshall
2022-07-11  8:05                 ` Stefan Nobis
2022-07-11 11:39                   ` Juan Manuel Macías
2022-07-11 12:04                     ` Juan Manuel Macías
2022-07-11 12:31                 ` Max Nikulin
2022-07-11 14:23                   ` Juan Manuel Macías
2022-07-11 17:20                     ` Max Nikulin
2022-07-16  3:01                     ` Max Nikulin
2022-07-11 17:08               ` LaTeX export: when is it more useful to use LuaTeX instead of pdfTeX? Max Nikulin
2022-07-10  2:12           ` Max Nikulin
2022-07-09  0:34 ` Matt Huszagh [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87tu7r5dkg.fsf@gmail.com \
    --to=huszaghmatt@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=maciaschain@posteo.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).