luatex xetex add tag
samcarter
If one has to choose between using either XeLaTeX or LuaLaTeX, which criteria would you use to choose one or the other in 2022?

*(I realise that [similar questions](https://tex.stackexchange.com/questions/126206/why-choose-lualatex-over-xelatex) have already been asked a decade ago, but since then a lot of development has happened, so I think it is time to gather an up-to-date overview of advantages or disadvantages)*


Top Answer
Skillmon
For any new document use LuaLaTeX, for old documents consider migrating them to LuaLaTeX.

---

Reasoning:

With the tagging project up and running there are bad news for XeLaTeX: Due to the internal working of XeLaTeX (that doesn't produce PDFs directly but rather compiles to an intermediate format that then gets converted to PDF by dvipdfmx) tagging can't be done in XeLaTeX. As a result XeLaTeX will not get new features but will be switched to maintenance only mode.

For reference you can take a look here: https://www.texdev.net/2024/11/05/engine-news-from-the-latex-project

Other key points which speak in favour of LuaTeX over XeTeX:

- better `microcode` support
- exploitable/hackable hooks to achieve things impossible in classic TeX (for instance the `lua-ul` package)
- Lua as another language you can program your document in within the same source file and without any preprocessing

Noticable drawback: LuaTeX is slower than XeTeX, but if you're after speed neither of the two beat pdfTeX, and compilation speed shouldn't be your biggest concern.
Answer #2
निरंजन
At the time of writing this answer, XeLaTeX is very far from LuaLaTeX in multilingual typesetting. I provide the following example which can be run with both XeLaTeX and LuaLaTeX. The objective is to typeset a multilingual document involving four languages. 1) English (main) 2) Malayalam 3) Marathi 4) Hindi. We use fonts already distributed with TeX Live. Tested with fully updated TeX Live 2024 (full installation). Marathi and Hindi share the same scripts, but differ in some typographic conventions. Especially with respect to two characters `ल` and `श`.

```
\documentclass{article}
\usepackage{babel}
\usepackage{hologo}
\usepackage{iftex}
\babelprovide[import,main]{english}
\ifLuaTeX
  \babelprovide[%
    import,%
    onchar            = {ids fonts}%
  ]{malayalam}
  \babelprovide[%
    import,%
    onchar            = {ids fonts}%
  ]{marathi}
  \babelprovide[%
    import,%
    onchar            = {ids fonts}%
  ]{hindi}
\else
  \babelprovide[import]{malayalam}
  \babelprovide[import]{marathi}
  \babelprovide[import]{hindi}
\fi
\usepackage{fontspec}
\babelfont{rm}[%
  BoldFont          = {NewCM10-Bold.otf},%
  ItalicFont        = {NewCM10-BookItalic.otf}%
]{NewCM10-Book.otf}
\babelfont{sf}[%
  BoldFont          = {NewCMSans10-Bold.otf},%
  ItalicFont        = {NewCMSans10-BookOblique.otf}%
]{NewCMSans10-Book.otf}
\babelfont{tt}[%
  BoldFont          = {NewCMMono10-Bold.otf},%
  ItalicFont        = {NewCMMono10-BookItalic.otf}%
]{NewCMMono10-Book.otf}
\babelfont[malayalam]{rm}[%
  Scale             = {1.275},%
  % Scale the font to treat both the scripts equally. This
  % is a new typographic trend to democratise typesetting!
  Script            = {Malayalam},%
  Renderer          = {HarfBuzz},%
  BoldFont          = {RIT-Rachana-Bold.ttf},%
  ItalicFont        = {Rit-Rachana-Regular.ttf}%
]{Rit-Rachana-Regular.ttf}
\babelfont[malayalam]{sf}[%
  Scale             = {1.275},%
  Script            = {Malayalam},%
  Renderer          = {HarfBuzz}%
]{RIT-MeeraNew.ttf}
\babelfont[malayalam]{tt}[%
  Scale             = {1.275},%
  Script            = {Malayalam},%
  Renderer          = {HarfBuzz}%
]{RIT-tnjoy-regular.ttf}
\babelfont[marathi]{rm}[%
  Script            = {Devanagari},%
  Language          = {Marathi},%
  Renderer          = {HarfBuzz},%
  BoldFont          = {Eczar-Bold.otf},%
  ItalicFont        = {Eczar-Regular.otf}%
]{Eczar-Regular.otf}
\babelfont[marathi]{sf}[%
  Script            = {Devanagari},%
  Language          = {Marathi},%
  Renderer          = {HarfBuzz}
]{Mukta-Regular.ttf}
\babelfont[marathi]{tt}[%
  Script            = {Devanagari},%
  Language          = {Marathi},%
  Renderer          = {HarfBuzz}%
]{Baloo2-Regular.ttf}
\babelfont[hindi]{rm}[%
  Script            = {Devanagari},%
  Language          = {Hindi},%
  Renderer          = {HarfBuzz},%
  BoldFont          = {Eczar-Bold.otf},%
  ItalicFont        = {Eczar-Regular.otf}%
]{Eczar-Regular.otf}
\babelfont[hindi]{sf}[%
  Script            = {Devanagari},%
  Language          = {Hindi},%
  Renderer          = {HarfBuzz}%
]{Mukta-Regular.ttf}
\babelfont[hindi]{tt}[%
  Script            = {Devanagari},%
  Language          = {Hindi},%
  Renderer          = {HarfBuzz}%
]{Baloo2-Regular.ttf}

\begin{document}
\setlength{\parindent}{0pt}
\section*{With markup}

\emph{Comments:}
Works correctly with both \hologo{LuaLaTeX} and
\hologo{XeLaTeX}.

\subsection*{Serif}

\begingroup
hello world

NewCM10-Book.otf

\selectlanguage{malayalam}
മലയാളം

\foreignlanguage{english}{RIT-Rachana-Regular.ttf}

\selectlanguage{marathi}
शालेय शिक्षणाचे महत्त्व.

\foreignlanguage{english}{Marathi text in Eczar-Regular.otf
  with Marathi} ल श

\selectlanguage{hindi}
शालेय शिक्षा का महत्त्व।

\foreignlanguage{english}{Hindi text in Eczar-Regular.otf
  with Hindi} ल श
\endgroup

\subsection*{Sans serif}

\begingroup
\sffamily
hello world

NewCMSans10-Book.otf

\selectlanguage{malayalam}
മലയാളം

\foreignlanguage{english}{RIT-MeeraNew.ttf}

\selectlanguage{marathi}
शालेय शिक्षणाचे महत्त्व.

\foreignlanguage{english}{Marathi text in Mukta-Regular.ttf
  with Marathi} ल श

\selectlanguage{hindi}
शालेय शिक्षा का महत्त्व।

\foreignlanguage{english}{Hindi text in Mukta-Regular.ttf
  with Hindi} ल श
\endgroup

\subsection*{Monospaced}

\begingroup
\ttfamily
hello world

NewCMMono10-Book.otf

\selectlanguage{malayalam}
മലയാളം

\foreignlanguage{english}{RIT-tnjoy-regular.ttf}

\selectlanguage{marathi}
शालेय शिक्षणाचे महत्त्व.

\foreignlanguage{english}{Marathi text in Baloo2-Regular.ttf
  with Marathi} ल श

\selectlanguage{hindi}
शालेय शिक्षा का महत्त्व।

\foreignlanguage{english}{Hindi text in Baloo2-Regular.ttf
  with Hindi} ल श
\endgroup

\newpage

\section*{Without markup}

\emph{Comments:}
Works correctly with \hologo{LuaLaTeX}, but fails to detect
two languages that use the same script. Can partially work
with \hologo{XeLaTeX} using package \textsf{ucharclasses},
but a) it is not a reliable solution as documented in the
package documentation itself; b) it doesn't support font
switching between families.

\subsection*{Serif}

\begingroup
hello world

NewCM10-Book.otf

മലയാളം

RIT-Rachana-Regular.ttf

शालेय शिक्षणाचे महत्त्व.

Marathi text in Eczar-Regular.otf, but Hindi ल श

शालेय शिक्षा का महत्त्व।

Hindi text in Eczar-Regular.otf with Hindi ल श
\endgroup

\subsection*{Sans serif}

\begingroup
\sffamily
hello world

NewCMSans10-Book.otf

മലയാളം

RIT-MeeraNew.ttf

शालेय शिक्षणाचे महत्त्व.

Marathi text in Mukta-Regular.ttf, but Hindi ल श

शालेय शिक्षा का महत्त्व।

Hindi text in Mukta-Regular.ttf with Hindi ल श
\endgroup

\subsection*{Monospaced}

\begingroup
\ttfamily
hello world

NewCMMono10-Book.otf

മലയാളം

RIT-tnjoy-regular.ttf

शालेय शिक्षणाचे महत्त्व.

Marathi text in Baloo2-Regular.ttf, but Hindi ल श

शालेय शिक्षा का महत्त्व।

Hindi text in Baloo2-Regular.ttf with Hindi ल श
\endgroup
\end{document}
```

Conclusions:
--

1. LuaLaTeX is able to detect languages based on the Unicode characters used and doesn't require markup. XeLaTeX isn't able to do this and requires explicit markup for language switching.
2. LuaLaTeX cannot detect languages which share one script. But IMHO it's an extremely difficult task with which even top-notch AI would struggle. As an example consider the words शालेय, महत्त्व, शिक्षा and का seen in the examples. All these four words are present in both Hindi and Marathi*. Without analysing the sentence, it would be impossible to detect the language which as of now no programme (not even the recent AIs) can do.

\* Fun facts: 1) The first three of the four words listed here are borrowed to Marathi and Hindi from an ancient language Sanskrit. There is a slight chance that another language Nepali (which uses Devanagari script and also heavily borrows from Sanskrit) too has them, but I can't be sure as I don't speak Nepali. 2) Third  and fourth words mean completely different things in both Hindi and Marathi. शिक्षा means education in Hindi and punishment in Marathi (well, not too different if observed carefully :P). 3) Funnily, it can mean both in Sanskrit. Have no idea what happens in Nepali. 4) Fourth word is the funniest. It is _which (feminine)_ of Sanskrit, _a yes/no auxiliary_ of Marathi and the masculine genitive case of Hindi. Again, have to check a) if it exists in Nepali or not b) if it does, does it make the picture more bizarre or not.

Enter question or answer id or url (and optionally further answer ids/urls from the same question) from

Separate each id/url with a space. No need to list your own answers; they will be imported automatically.