\
begin
{document}
Give it a file of plain text, or a LaTeX file that really does have no
\
begin{document}
command in it, and LaTeX will produce
this error, quite correctly. LaTeX needs
\
begin{document}
so as to know when to execute the commands
that finish off the document preamble.
Other than that, the error can occur as a result of an error of yours,
of a corrupt .aux
file, or of a buggy class or package.
The errors you might commit are absent-mindedly typing a document
command (such as \
section
) in the preamble of your document,
missing the comment marker from the beginning of a line, or giving too
many arguments to one of the setup commands related to the class or a
package that you have loaded.
A corrupt .aux
file might be due to any number of things;
delete the file and to run LaTeX again, twice. If the error
recurs, it's probably due to a buggy class or package.
If the error occurs while LaTeX is reading a class or package, then there's probably a bug in the file. The author of the class or package stands the best chance of finding the bug, but with luck you (or someone you ask on a mailing list or on comp.text.tex) will be able to spot the problem and provide a work-around. Always report such bugs, even if you have found a work-around.
This question on the Web: http://www.tex.ac.uk/cgi-bin/texfaq2html?label=missbegdoc