You are linking there to plain.tex
which is a file written in TeX not the source of tex-the-program (which is tex.web
)
These days if you want to compile from source it is probably best to start with a full download of the texlive build sources.
The sources are at
http://www.tug.org/texlive/svn/
and that page has hints about where to start if you want to compile. See in particular:
http://www.tug.org/texlive/build.html
Good luck:-)
Category 1
\newwrite\out
\immediate\openout\out=\jobname
\immediate\write\out{Fool!}
\bye
This will overwrite the TeX file.
TeX will obey your instructions even if they're foolish. However, it will refuse to write file above the current working directory (under the standard settings of the most common distributions).
Obviously, if the current directory is /
and you run TeX with superuser privileges, you can overwrite anything on your system; but this is true of every scripting language interpreter that's able to write out files, so not a specific thing of TeX.
Category 2
If you run TeX with -shell-escape
enabled and sufficient privileges, you can execute any program, including rm -f /
. So be careful when enabling -shell-escape
. Some packages, notably minted
require -shell-escape
. Examine the input file you receive from other people before processing it.
Category 3
TeX engines different from LuaTeX only allocate a maximum amount of memory.
It's easy to make TeX loop forever without wasting resources with
\def\fool{\fool}\fool
On the other hand, complicated graphics with LuaTeX, that has dynamic allocation of memory, can lead to consuming vast amount of resources.
Category 4
Redefine a primitive in a wrong way and you'll be welcomed by puzzling error messages such as
! A <box> was supposed to be here.
<to be read again>
-
l.9 \end{document}
which is produced by
\documentclass{article}
\renewcommand{\box}[1]{-#1-}
\begin{document}
\box{abc}
\end{document}
The most dangerous command is \renewcommand
(or \def
). Another instance is the following
\documentclass{article}
\renewcommand{\fi}{whatever}
\begin{document}
\end{document}
that makes LaTeX stop with the very puzzling error message
! LaTeX Error: Missing \begin{document}.
See the LaTeX manual or LaTeX Companion for explanation.
Type H <return> for immediate help.
...
l.3 \begin{document}
Best Answer
In olden times, TeX came in two incarnations:
initex
andvirtex
. The first binary was used to create formats such as Plain and LaTeX, the second one was used for typesetting documents after loading one of the available formats.So one had to do
and save the created file
lplain.fmt
in some suitable directory; from then on, it was possible to typeset a document withOf course many users or system administrators defined aliases, so that one could simply call
During the years several tricks for easing the choice of formats were devised. For instance, some systems made a memory dump of
initex
instead of doing\dump
, so the dump could be turned into an executable, so speeding up the start of the run.Another trick was to allow TeX to parse the first line of the first input file, so if the file was
a simple call
would have been equivalent to
tex '&latex' file
. Yes, in more recent times, instead ofvirtex
the executable was being calledtex
and the format for LaTeX was being created withinitex latex.ltx
, so the format produced waslatex.fmt
.This “first line parsing” is available also with current TeX distributions. I'm not sure what's the status of MiKTeX (what I know is that it allows more options to be specified).
The TeX Live distribution uses a different strategy; when a format is created (using the script
mktexfmt-sys
), say forpdflatex
, a symbolic linkis created in the binary directory; this is what I have on my system:
This makes
pdflatex
into an “executable”, butpdftex
is actually run; the program has the ability of knowing what name it has been called with, and do the appropriate action when loading the format.So, what happens if you have the file above and run the command line
without any other option? The “first line parsing” is active, so this overrides the format choice based on the calling name and the
latex
format is chosen, which produces its output in DVI format rather than PDF.So, the best thing is not to use the first line in that format. It's confusing, at the least.
You can look at the documentation of TeX Live, for more information:
http://texdoc.net./texmf/doc/texlive/texlive-en/texlive-en.pdf
discovering that the option is not even described. The man page for pdftex has
The TeX Live manual talks a bit about TCX files that are, however, a relic of the past, mainly.
The feature can be turned off at run time by calling
(any symbolic link pointing to
pdftex
can be used). Note that the feature is turned off by default when usingtex
(that is, the original Knuth TeX, not able to produce PDF output). The relevant settings in the standardtexmf.cnf
file areIf you add
to the top level
texmf.cnf
file, that isfor the 2013 release, you turn off the feature for all binaries.