Consider the following "Hello, World!" document.
Hello, world!
\end
If you try to compile this using latex.exe
, you get the error**
! LaTeX Error: Missing \begin{document}.
Okay, so on one hand, it should be obvious that one would get this error---this is a bit like trying to compile a C program without a main
function. On the other hand, if I am thinking of LaTeX as just TeX with a bunch of macros loaded, one would think that any document that would compile fine using tex.exe
should work just as well without latex.exe
, at least so long as I'm not using any macros specific to Plain TeX.***
This suggests that my understanding of LaTeX as being effectively equivalent to TeX but with an \input{latex}
command at the beginning of the document is incorrect, which thus raises a couple of related questions.
My understanding was that loading a TeX format is essentially equivalent to
\input
ing a file at the beginning of the document, except perhaps that the file has been precompiled. Is this understanding inaccurate?Is a call to
latex.exe
actually equivalent to a call totex.exe
with the LaTeX format loaded?If in fact running
latex.exe
is equivalent to just running TeX with the LaTeX format, then how does this format tell TeX to throw an error if it doesn't see a\begin{document}
?
** Incidentally, you also get an error related to the fact that \end
means something different in LaTeX. I also find this confusing because I didn't think you could redefine TeX primitives, but perhaps this is better saved for a separate question.
*** Actually, I'm not even sure if there are macros specific to Plain TeX that LaTeX doesn't also define.
LaTeX must be made using an initex with no format preloaded
so the answer to the 1 and 2 is no.\everypar{\@nodocument} %% To get an error if text appears before the
where\@nodocument
is error message. and\document
redefine\@nodocument
to\relax