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
/usr/texbin/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
/usr/texbin/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.

## 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.
**\relax
entering extended mode

*\show\newcommand
> \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.

## latex

jmlopez\$ latex
This is pdfTeX, Version 3.1415926-2.3-1.40.12 (TeX Live 2011)
restricted \write18 enabled.
**\relax
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
.

*\show\newcommand
> \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.

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! – Ian Thompson Mar 29 '13 at 18:49