I decided venture into the very basics of the world of TeX and LaTeX. I have been playing around with tex, pdftex and latex and after paying close attention to the binaries and not being able to figure out what is going on I decided it was time to come and ask for help from someone with knowledge.

latex == pdftex

Are the latex and pdftex binaries the same? I am using Mac OS X 10.7.5 and this is what I have from the terminal:

jmlopez$ which pdftex
jmlopez$ ls -al /usr/texbin/pdftex
-rwxr-xr-x  1 root  wheel  1662700 Jun 21  2011 /usr/texbin/pdftex

This tells me that pdftex is an actual binary which I can execute. Let us take a look at latex:

jmlopez$ which latex
jmlopez$ ls -al /usr/texbin/latex
lrwxr-xr-x  1 root  wheel  6 Feb 13  2012 /usr/texbin/latex -> pdftex

It seems that latex is a symbolic link to pdftex. So in reality, latex and pdftex and even pdflatex are the same program, that is pdftex.


The next set of commands displays what happens when I submit commands to pdftex:

jmlopez$ pdftex
This is pdfTeX, Version 3.1415926-2.3-1.40.12 (TeX Live 2011)
 restricted \write18 enabled.
entering extended mode

> \newcommand=undefined.
<*> \show\newcommand


pdftex is not latex since it doesn't know the definition of \newcommand. But now let us see what happens with latex.


jmlopez$ latex
This is pdfTeX, Version 3.1415926-2.3-1.40.12 (TeX Live 2011)
 restricted \write18 enabled.
entering extended mode
LaTeX2e <2009/09/24>
Babel <v3.8l> and hyphenation patterns for english, dumylang, nohyphenation, ge
rman-x-2009-06-19, ngerman-x-2009-06-19, 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

> \newcommand=macro:
->\@star@or@long \new@command .
<*> \show\newcommand


From the first line when you enter latex and pdftex you can see that it is the exact same program. The only difference is that pdftex somehow knows that when it is executed as the symbolic link latex then it needs to load all the latex definition. Definitions which include the \newcommand macro.

Loading latex from pdftex or tex

My actual question is, given that I have executed pdftex or tex, how can load latex so that all the macros that latex defines are available in pdftex?

The reason I wish to know this is because I want to find the actual files that defines all of these macros so that I can try to have a better understanding of what is going on when I use the command latex. I wish to know how latex defines all of its enviroments and how it knows where to look for its packages. Those may be other question for the future, but for now I just want to know if it is possible to load the latex macros from pdftex or tex.

  • Try pdflatex in the terminal. The pdfTeX engine is used when you issue either the command latex or pdflatex; the XeTeX engine is used when you issue the command xelatex; and the LuaTeX engine is used when you issue the command lualatex. All of these commands expect a LaTeX file. There are other formats also, which don't want you to use commands that end *latex (e.g., 'plain' TeX or ConTeXt). Probably a duplicate, however; see here and here.
    – jon
    Mar 29 '13 at 18:25
  • @jon, I did try pdflatex in terminal. For this reason in my post I said: "So in reality, latex and pdftex and even pdflatex are the same program, that is pdftex". They all point to pdftex. I'm not ready to venture into xelatex or LuaTeX. For now all I wish to know is how pdftex knows when and how to load the latex macros.
    – jmlopez
    Mar 29 '13 at 18:31
  • Sorry: I missed the mention of pdflatex. But this seems like a long way around to ask how pdfTeX-the-engine knows that you are asking for LaTeX when you type (pdf)latex in a terminal. Compare pdftex -fmt latex <filename>, for example.
    – jon
    Mar 29 '13 at 18:41
  • @jon, I read the other posts which talk about the differences between the different *tex versions but I don't see anything that explains how to get the core driver (in this case pdftex) to load all of the other latex macros.
    – jmlopez
    Mar 29 '13 at 18:43
  • I think this answer contains the information you need. Best of luck trying to understand the LaTeX kernel code! Mar 29 '13 at 18:49

The way the binaries are set up in texlive (at least) the binary uses its name to customise its behaviour. so pdftex and pdflatex might be copies (or symbolic links) of the same binary but one will load the plain TeX format and the other will load the latex format so their behaviour is very different. The source for the latex format is latex.ltx or in its documented forms source2e try texdoc source2e or kpsewhich latex.ltx on the command line.

for further details see

Executables of formats, engines and executables of engines

  • Speak of the devil... Mar 29 '13 at 19:59
  • So does that mean pdftex -fmt latex <file> does the same as latex <file>?
    – jon
    Mar 29 '13 at 20:02
  • I had thought about the possibility that the pdftex binary uses its name for custom behavior but I wanted someone to verify it. The last two commands provided are big help. Is there a way to know the exact custom behavior for pdftex? What jon pointed out is interesting, the -ftm latex option seems to load all the necessary things from latex.
    – jmlopez
    Mar 29 '13 at 20:07
  • 3
    @jmlopez there is a question on site where it's detailed but the classic way is to have virtex with just the the primitives and then latex would be a script virtex &latex which loads latex format and tex would be virtex &plain to load plain tex (try kpsewhich plain.tex) but wev2c added the convenience of using the executable name to determine the format loaded if you make your own mytexfmt format then you can make a symbolic link mytexfmt to the tex executable to get an executable that preloads your format. Mar 29 '13 at 21:00
  • added link to answer Mar 29 '13 at 21:03

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.