On my Mac I wanted to create the PDF via terminal, and I found I cannot use xetex filename.tex, but xelatex filename.tex works just fine. I checked the file, xelatex is actually an alias pointed to xetex. But why they behave so different? I may need to use the original executable rather than alias to avoid exceptions.

Here's some output:

$ xetex Assignment\ 4.tex

This is XeTeX, Version 3.14159265-2.6-0.99992 (TeX Live 2015) (preloaded format=xetex)
restricted \write18 enabled.
entering extended mode
(./Assignment 4.tex
! Undefined control sequence.
l.4 \documentclass
              [a4paper, 11pt]{article} % Font size (can be 10pt, 11pt or...

? ^Z
[3]  + 44568 suspended  xetex Assignment\ 4.tex 

$ xelatex Assignment\ 4.tex

This is XeTeX, Version 3.14159265-2.6-0.99992 (TeX Live 2015) (preloaded format=xelatex)
restricted \write18 enabled.
entering extended mode
(./Assignment 4.tex
LaTeX2e <2015/10/01> patch level 2
Babel <3.9m> and hyphenation patterns for 79 languages loaded.
Document Class: article 2014/09/29 v1.4h Standard LaTeX document class
  • On the command line, what are the outputs of which xetex and which xelatex? This indicates which program is actually executed. – Arun Debray Nov 17 '15 at 23:15
  • 2
  • @ArunDebray The same executable is used in each case. which does not tell you which programme is executed if the result is an alias. – cfr Nov 17 '15 at 23:17
  • What exceptions are you worried about exactly? Why would using the alias be a problem? – cfr Nov 17 '15 at 23:18
  • 1
    @ArunDebray They are different files but only one is an executable. The other is a symbolic link to the executable. Try ls -l $(which xelatex). – cfr Nov 17 '15 at 23:40

XeTeX is the engine. LaTeX is the format. When you compile with xetex, the LaTeX format is not loaded so things like \documentclass are not defined. You can compile this way if your document is not using LaTeX but plain TeX.

The executable is the same, but the name you call it by matters. This is because the executable tests to find out what name it has been called by. If the answer is xelatex, it loads the LaTeX format and things like \documentclass are defined. You can see this early in the output where the console shows

... preloaded format=xelatex ...

If the answer is xetex, it does not load the LaTeX format and things like \documentclass are not defined.

... preloaded format=xetex ...

If you wish, you can use

xetex -fmt=<format>

and specify the format you want explicitly. However, in general, there's no reason to do that when an alias such as xelatex is available, although there's no harm in doing it either - the result will be the same.

  • @StarkShaw It is a little odd at first. But a rose by any other name is not always the same rose, even if it is equally sweet ;). – cfr Nov 17 '15 at 23:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.