TransWikia.com

Getting xetex to complain when a character is missing

TeX - LaTeX Asked on April 28, 2021

Consider the following minimal document:

documentclass{article}
begin{document}

tām आ ṁ

end{document}

If you compile it with xelatex se.tex, you get something normal and innocuous, like:

This is XeTeX, Version 3.1415926-2.2-0.9995.2 (TeX Live 2009/Debian)
entering extended mode
(./se.tex
LaTeX2e <2009/09/24>
Babel <v3.8l> and hyphenation patterns for english, usenglishmax, dumylang, noh
yphenation, farsi, arabic, croatian, bulgarian, ukrainian, russian, czech, slov
ak, danish, dutch, finnish, french, basque, ngerman, german, german-x-2009-06-1
9, ngerman-x-2009-06-19, ibycus, monogreek, greek, ancientgreek, hungarian, san
skrit, italian, latin, latvian, lithuanian, mongolian2a, mongolian, bokmal, nyn
orsk, romanian, irish, coptic, serbian, turkish, welsh, esperanto, uppersorbian
, estonian, indonesian, interlingua, icelandic, kurmanji, slovenian, polish, po
rtuguese, spanish, galician, catalan, swedish, ukenglish, pinyin, loaded.
(/usr/share/texmf-texlive/tex/latex/base/article.cls
Document Class: article 2007/10/19 v1.4h Standard LaTeX document class
(/usr/share/texmf-texlive/tex/latex/base/size10.clo)) (./se.aux) [1] (./se.aux)
 )
(see the transcript file for additional information)
Output written on se.pdf (1 page).
Transcript written on se.log.

which does not seem to contain any error message. But if you open the PDF file, you’ll notice that it just says “tm” (or if you had used usepackage{fontspec}, it says “tām”) instead of tām आ ṁ.

XeTeX has silently dropped characters, without user warning!

To be fair, if you really look inside se.log, it contains a line saying:

Missing character: There is no ā in font cmr10!

or, if you had used usepackage{fontspec}, it may contain:

Missing character: There is no ṁ in font [lmroman10-regular]:mapping=tex-text
!

but most people are not in the habit of looking inside the log file when there’s no indication of error.

Is there a way of telling XeTeX that missing characters should be treated more seriously, and reported in the main screen itself? Some command-line flag, environment variable, or config file change, perhaps?

(Of course, now that I’ve been bitten by this, I can write a shell script that will grep for such messages in the log file… but I’m wondering if there’s a way to make it the default, and get this change into default distributions, so that it will help other users as well.)

One Answer

If you set tracinglostchars=2, then the message is printed also during the run on the terminal

This is XeTeX, Version 3.1415926-2.3-0.9997.5 (TeX Live 2011)
 restricted write18 enabled.
entering extended mode
(./lostla.tex
LaTeX2e <2011/06/27>
Babel <v3.8m> and hyphenation patterns for english, dumylang, nohyphenation, ge
rman-x-2011-07-01, ngerman-x-2011-07-01, afrikaans, ancientgreek, ibycus, arabi
c, armenian, basque, bulgarian, catalan, pinyin, coptic, croatian, czech, danis
h, dutch, ukenglish, usenglishmax, esperanto, estonian, ethiopic, farsi, finnis
h, french, galician, german, ngerman, swissgerman, monogreek, greek, hungarian,
 icelandic, assamese, bengali, gujarati, hindi, kannada, malayalam, marathi, or
iya, panjabi, tamil, telugu, indonesian, interlingua, irish, italian, kurmanji,
 lao, latin, latvian, lithuanian, mongolian, mongolianlmc, bokmal, nynorsk, pol
ish, portuguese, romanian, russian, sanskrit, serbian, serbianc, slovak, sloven
ian, spanish, swedish, turkish, turkmen, ukrainian, uppersorbian, welsh, loaded
.
(/usr/local/texlive/2011/texmf-dist/tex/latex/base/article.cls
Document Class: article 2007/10/19 v1.4h Standard LaTeX document class
(/usr/local/texlive/2011/texmf-dist/tex/latex/base/size10.clo))
No file lostla.aux.
Missing character: There is no ā in font cmr10!
Missing character: There is no आ in font cmr10!
[1] (./lostla.aux) )
Output written on lostla.pdf (1 page).
Transcript written on lostla.log.

If I also add usepackage{fontspec} I get instead only

Missing character: There is no आ in font [lmroman10-regular]:mapping=tex-text!

Update

With TeX Live 2021 (and an up-to-date MiKTeX), you can get an actual error by setting tracinglostchars=3. This works with both XeTeX and LuaTeX.

tracinglostchars=3

documentclass{article}
begin{document}

tām आ ṁ

end{document}

On the console you'll get

! Missing character: There is no आ (U+0906) in font [lmroman10-regular]:mapping
=tex-text;.
l.5 tām आ
          ṁ
?
! Missing character: There is no ṁ (U+1E41) in font [lmroman10-regular]:mapping
=tex-text;.
l.5 tām आ ṁ

?

(Thanks to ShreevatsaR for pointing to the recent update.)

Correct answer by egreg on April 28, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP