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.
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.
pdflatexin the terminal. ThepdfTeXengine is used when you issue either the commandlatexorpdflatex; theXeTeXengine is used when you issue the commandxelatex; and theLuaTeXengine is used when you issue the commandlualatex. 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:25pdflatexin terminal. For this reason in my post I said: "So in reality,latexandpdftexand evenpdflatexare the same program, that ispdftex". They all point topdftex. I'm not ready to venture intoxelatexorLuaTeX. For now all I wish to know is howpdftexknows when and how to load thelatexmacros. – jmlopez Mar 29 '13 at 18:31pdflatex. But this seems like a long way around to ask howpdfTeX-the-engine knows that you are asking for LaTeX when you type(pdf)latexin a terminal. Comparepdftex -fmt latex <filename>, for example. – jon Mar 29 '13 at 18:41pdftex) to load all of the otherlatexmacros. – jmlopez Mar 29 '13 at 18:43LaTeXkernel code! – Ian Thompson Mar 29 '13 at 18:49latexorpdflatex; why do you need to callpdftexand get 'all the otherlatexmacros'? (And what are all these other macros? Many of important LaTeX things are in separate packages.) – jon Mar 29 '13 at 18:52