TeXpad

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.
or paste your own document

Ready. Press Compile (or Ctrl/Cmd + Enter).

Open in the full editor →

Common causes

How to fix it

  1. Make sure \begin{document} comes after the last preamble command and before your text. TeXpad offers to add it.
  2. Look at the line number in the error for a stray character in the preamble and remove it.

Related errors