4

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.
(/usr/local/texlive/2015/texmf-dist/tex/latex/base/article.cls
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
    Related: http://tex.stackexchange.com/questions/64000/executables-of-formats-engines-and-executables-of-engines and http://tex.stackexchange.com/questions/161042/the-role-of-latex-at-the-beginning-of-a-source-latex-file – egreg Nov 17 '15 at 23:17
  • @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
  • @ArunDebray If you try ls -l $(which -p xelatex) you'll see something like /usr/texbin/xelatex@ -> xetex in the output. – egreg Nov 17 '15 at 23:20
  • @egreg: do you mean which -a xelatex? I tried with -p and it said Illegal option -p. (I'm using TeXLive on Ubuntu, so perhaps things are different here.) I tried which -a, and for me, xetex and xelatex are different files. – Arun Debray Nov 17 '15 at 23:26
  • @ArunDebray That's shell dependent, I guess. – egreg Nov 17 '15 at 23:30
  • @cfr Thanks. I'm worry about if the alias is not available in some case. I want to use XeLaTeX to generate PDF in my future project. Then different machines may have some situations. :) – Stark Shaw Nov 17 '15 at 23:34
  • Hi @ArunDebray as comments made above, which itself doesn't tell you if that is an alias. I found it out by using "Get Info" in Finder. However ls -l $(which -p xelatex) works perfect for me on OS X. However, I didn't find anything about -p on man which. Hope this helps. :) – Stark Shaw Nov 17 '15 at 23:37
  • @StarkShaw If the machine does not have xelatex in some form (alias or otherwise - not sure what Windows does) then you have more to worry about than needing to specify the format explicitly. Of course, it is possible. But it is also possible the machine won't have the LaTeX format or the xetex binary. If the machine has anything like a working installation of TeX which is not truly ancient, it will have xelatex. – cfr Nov 17 '15 at 23:38
  • 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
  • @cfr Thanks for your heads-up! :) – Stark Shaw Nov 17 '15 at 23:40
  • @egreg On my system, which is not shell-dependent. It is provided by a package called which and the manual includes stuff about both sh and csh style shells. No -p. – cfr Nov 17 '15 at 23:48
  • @StarkShaw Maybe Apple has doctored the command. Or there's a default configuration file for the shell setting which as an alias. (Which is also probably Apple doctoring the command.) I don't necessarily mean this is bad. All systems do it to some extent or other. But -p does not seem to be standard. Unless it is a BSD extension, which is also possible but then I'd expect a suitable man page. – cfr Nov 17 '15 at 23:51
  • @cfr Yes, I have it in my .bashrc (I don't remember from when). – egreg Nov 17 '15 at 23:53
  • Or @egreg doctoring the command.... But probably that is standard if it is the same for Stark Shaw ? – cfr Nov 17 '15 at 23:55

1 Answers1

4

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.

cfr
  • 198,882
  • @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