An XeLaTeX Compilation Error: Undefined control sequence. \pdfglyphtounicode

Jul. 24, 2024

Today, when I compile a .tex file (which I created on another computer before) in TeXstudio, some errors like Undefined control sequence. \pdfglyphtounicode are printed in Log box:

image-20240724171201996

But on the other hand, corresponding PDF file can be normally generated, and I can preview it as usual. Besides, these errors don’t exist when I compile other .tex files.

Later, I notice messages in Messages box:

image-20240724171327589

which shows that complier pdflatex works well but xelatex doesn’t. Probably this is why above case appears.

I remember that previously these two “green” lines always appeared after a successful compilation, and I thought they indicate that everything is OK, so I have never read it carefully. Now I realize that I have been using two compilers to compile .tex files all along, and Default Compiler configuration also shows this point:

image-20240724172921385

After I changing Default Compiler option from txs:///pdflatex | txs:///xelatex to txs:///pdflatex, that is cancel xelatex compilation, aforementioned errors disappear. So, I guess these errors are caused by that some characters in this .tex file are not supported by xelatex (but I’m not certain, because all characters in the file are English letters).


As introduced on 31th page of Prof. Liu’s book, Introduction to LaTeX1, there are different compilation methods, and hence different compilers like pdflatex2, xelatex3, and dvips4, to convert TeX source code to PDF file, and in which xelatex can best support processing Chinese characters:

image-20240724165541952

So, I think for this reason I added xelatex as a default compiler before.


References

  1. LaTeX入门,刘海洋编著, pp. 31. ˄

  2. pdfTeX ˄

  3. XeTeX ˄

  4. dvips˄