Rules / Build

LaTeX Error: Missing \begin{document} — Text in the preamble

Typeset text appears before \begin{document}.

Fix

Move the text after \begin{document} or comment it out.

Example

Reproduced on TeX Live 2026 by CI · pdflatex · corpus/missing-begin-document

Fails: main.tex
\documentclass{article}
\usepackage{amsmath}
\title{A Study of Things}
This draft was last edited on Monday.
\begin{document}
\maketitle
\end{document}
Fixed
\documentclass{article}
\usepackage{amsmath}
\title{A Study of Things}
% This draft was last edited on Monday.
\begin{document}
\maketitle
\end{document}
What TeX prints in main.log
! LaTeX Error: Missing \begin{document}.

See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help.
 ...                                              
                                                  
l.4 T
     his draft was last edited on Monday.
You're in trouble here.  Try typing  <return>  to proceed.
If that doesn't work, type  X <return>  to quit.