LaTeX error: Missing \begin{document}
Everything between \documentclass and \begin{document} is the preamble, where only settings belong. The first character that would print on the page (a word, a stray symbol) triggers this error.
! LaTeX Error: Missing \begin{document}.
Try it: this example has the error
Press Fix it in the error box, and it compiles to a PDF. What pdfTeX printed for it:
! LaTeX Error: Missing \begin{document}.
See the LaTeX manual or LaTeX Companion for explanation.
Type H <return> for immediate help.
...
l.3 H
ello world, this is my document.
Ready. Press Compile (or Ctrl/Cmd + Enter).
Common causes
- The
\begin{document}line is missing or misspelled. - Text typed into the preamble, or a stray character such as a lone
]or.after a\usepackageline. - A package option list with a typo, so the rest of the line is read as text:
\usepackage[margin=1in]]{geometry}. - A file saved with a byte-order mark or invisible characters before
\documentclass.
How to fix it
- Make sure
\begin{document}comes after the last preamble command and before your text. TeXpad offers to add it. - Look at the line number in the error for a stray character in the preamble and remove it.