5

Why would a simple file like:

\documentclass{report}

\usepackage[english,russian]{babel}

\begin{document}
\selectlanguage{english}
Next text in Russian:
\foreignlanguage{russian}{Элементарная теория аналитических}
\end{document}

produce completely different results using one or the other engine?

I do understand that they use different sets of fonts, but why that should be the case, specially if the coverage is different under pdflatex choice and the others choice?

1
  • Excellent question. And your puzzlement in the answers over what is apparently expected behavior, given this oh-so-simple input, getting casually dismissed ... well, that's disappointing (even if typical for fans of a given system that doesn't work right but they're used to its idiosyncrasies to the point where they don't understand your observation or even notice the inconsistencies anymore).
    – davidbak
    Aug 14, 2023 at 15:58

2 Answers 2

6

Output with pdflatex:

enter image description here

Output with xelatex or lualatex:

enter image description here

Hey! Where's the Russian sentence? Here it is:

Missing character: There is no Э (U+042D) in font [lmroman10-regular]:mapping=tex-text;!
Missing character: There is no л (U+043B) in font [lmroman10-regular]:mapping=tex-text;!
Missing character: There is no е (U+0435) in font [lmroman10-regular]:mapping=tex-text;!
Missing character: There is no м (U+043C) in font [lmroman10-regular]:mapping=tex-text;!
Missing character: There is no е (U+0435) in font [lmroman10-regular]:mapping=tex-text;!
Missing character: There is no н (U+043D) in font [lmroman10-regular]:mapping=tex-text;!
Missing character: There is no т (U+0442) in font [lmroman10-regular]:mapping=tex-text;!
Missing character: There is no а (U+0430) in font [lmroman10-regular]:mapping=tex-text;!
Missing character: There is no р (U+0440) in font [lmroman10-regular]:mapping=tex-text;!
Missing character: There is no н (U+043D) in font [lmroman10-regular]:mapping=tex-text;!
Missing character: There is no а (U+0430) in font [lmroman10-regular]:mapping=tex-text;!
Missing character: There is no я (U+044F) in font [lmroman10-regular]:mapping=tex-text;!
Missing character: There is no т (U+0442) in font [lmroman10-regular]:mapping=tex-text;!
Missing character: There is no е (U+0435) in font [lmroman10-regular]:mapping=tex-text;!
Missing character: There is no о (U+043E) in font [lmroman10-regular]:mapping=tex-text;!
Missing character: There is no р (U+0440) in font [lmroman10-regular]:mapping=tex-text;!
Missing character: There is no и (U+0438) in font [lmroman10-regular]:mapping=tex-text;!
Missing character: There is no я (U+044F) in font [lmroman10-regular]:mapping=tex-text;!
Missing character: There is no а (U+0430) in font [lmroman10-regular]:mapping=tex-text;!
Missing character: There is no н (U+043D) in font [lmroman10-regular]:mapping=tex-text;!
Missing character: There is no а (U+0430) in font [lmroman10-regular]:mapping=tex-text;!
Missing character: There is no л (U+043B) in font [lmroman10-regular]:mapping=tex-text;!
Missing character: There is no и (U+0438) in font [lmroman10-regular]:mapping=tex-text;!
Missing character: There is no т (U+0442) in font [lmroman10-regular]:mapping=tex-text;!
Missing character: There is no и (U+0438) in font [lmroman10-regular]:mapping=tex-text;!
Missing character: There is no ч (U+0447) in font [lmroman10-regular]:mapping=tex-text;!
Missing character: There is no е (U+0435) in font [lmroman10-regular]:mapping=tex-text;!
Missing character: There is no с (U+0441) in font [lmroman10-regular]:mapping=tex-text;!
Missing character: There is no к (U+043A) in font [lmroman10-regular]:mapping=tex-text;!
Missing character: There is no и (U+0438) in font [lmroman10-regular]:mapping=tex-text;!
Missing character: There is no х (U+0445) in font [lmroman10-regular]:mapping=tex-text;!

Is it expected? Yes. The default font with XeLaTeX or LuaLaTeX is Latin Modern, which doesn't cover Cyrillic at all. If you want to typeset Cyrillic text with XeLaTeX or LuaLaTeX you need to use a font that supports it.

For instance, fontsetup will choose NewComputer Modern.

\documentclass{report}
\usepackage{iftex}

\iftutex
% (Xe|Lua)LaTeX
\usepackage[russian,english]{babel}
\usepackage{fontsetup}
\else
\usepackage[T1,T2A]{fontenc}
\usepackage[russian,english]{babel}
\fi

\begin{document}

Next text in Russian:
\foreignlanguage{russian}{Элементарная теория аналитических}

\end{document}

The output with pdflatex is the same as before. The output with either XeLaTeX or LuaLaTeX is

enter image description here

Anyway, it's hopeless to make a real document that can be compiled with all engines. Decide which one you want to use and stick with its methods.

3
  • 3
    Enrico, your code works completely correct if you comment out the line \usepackage[T1,T2A]{fontenc} (in all 3 engines), so the only thing that is different is litereally \usepackage{fontsetup}. Now the question remains: Is that two big of a step for xeTeX and luaTeX to take -- in the name of an uniform interface to the user? Or even more than that: Should one not expect the same document to be compiled by all engines? I know your answer is "no", you already spelled that out, but I do not understand why, specially since 99.999% of everything else is the same. Aug 13, 2023 at 22:21
  • @TeXApprentice What is surprising to me is three different programs have the same input and output in 99.999% of the cases. Actually, many packages and LaTeX itself have different definitions internally so that the user doesn’t have to readjust anything, but it’s not always possible, easy or even desirable. Aug 14, 2023 at 6:40
  • @JavierBezos, now we got to the heart of my question -- why, in this example, that I tried to make very simple, it is not "possible", "easy" or "desirable"? Aug 14, 2023 at 8:32
3

The whole point with lualatex and xelatex is they offer many new features not available in pdflatex. Even in pdflatex, your document is not quite complete, because it misses the declaration of the font encoding (in this case it might work, but not always, and in any case it’s recommended declaring it). So, it’s to be expected that some readjustments will have to be made.

4
  • I am not sure I grasp the full meaning of the answer, or even small parts of it. I tried \usepackage[T1]{fontenc} which I would expect would work, but the result is exactly the same, such a file works on pdflatex, but not the other two. Could you complete the answer with what are the small adjustements that have to be made? Aug 13, 2023 at 18:22
  • @TeXApprentice T1 is the last thing you want here, T1 is a latin western European encoding that has no Cyrillic letters Aug 13, 2023 at 20:38
  • But David, the question remains -- what is the encoding needed for the specific situationa and (above all) why it could not be taken by babel? Aug 13, 2023 at 22:29
  • It seems the choice of the encoding is deterministic after one says: \usepackage[russian,english]{babel}, no? Aug 13, 2023 at 22:34

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .