FormaTeX
FatalDocument Structure

Two \documentclass Commands

! LaTeX Error: Two \documentclass or \documentstyle commands.

What this error means

A LaTeX document can only have one \documentclass declaration. If LaTeX encounters a second one, it reports this error. This usually happens when two files are accidentally merged or a template is incorrectly concatenated.

Common causes

  • Two .tex files were merged without removing one \documentclass
  • A \input{} file contains its own \documentclass
  • Template duplication during copy-paste

How to fix it

Remove the duplicate \documentclass. Each LaTeX document must have exactly one class declaration, and all other content should be after \begin{document}. Input files should not contain \documentclass.

Code examples

Causes the error
\documentclass{article}
\documentclass{report}  % Second class — error!
\begin{document}
Hello
\end{document}
Fixed
\documentclass{article}
\begin{document}
Hello
\end{document}

Related errors

Test the fix live

Paste your LaTeX into the playground and compile instantly.

One quick thing

We track anonymous usage — page views, feature usage, compilation events — to understand what works and what doesn't. No ads, no personal data, no third-party sharing.

Cookie policy