Clique aqui e veja a página ShareLaTeX em Inglês

[edit] ShareLaTeX guides

[edit] LaTeX Basics

[edit] Mathematics

[edit] Figures and tables

[edit] References and Citations

[edit] Languages

[edit] Document structure

[edit] Formatting

[edit] Fonts

[edit] Presentations

[edit] Commands

[edit] Field specific

[edit] Class files

This error appears when you have forgotten to include \begin{document} in your document. It can also appear if you have not written \documentclass[...]{...} at the beginning of your main document.

[edit] Common Causes

Forgetting to include \begin{document}:

The most basic cause of this error occurs when you have forgotten to write \begin{document} after the preamble in your main document. If you make this mistake, you will generate the error message shown below:

main.tex, line 5

LaTeX Error: Missing \begin{document}.

See the LaTeX manual or LaTeX Companion for explanation. Type H <return> for immediate help. ... You're in trouble here. Try typing <return> to proceed. If that doesn't work, type X <return> to quit.

To resolve this error, simply make sure that you have included \begin{document} after the preamble in your main document. See here to learn more about how to structure documents in LaTeX.

\documentclass[...]{...} in wrong place:

Another common cause of this error is if \documentclass[...]{...} is written in the wrong place. This must be written at the start of the main document. If you have a separate file for your preamble, you cannot include \documentclass[...]{...} in that file. It still must appear at the top of the main project file, or else only the preamble file will be compiled.

Main document set incorrectly:

This error may also appear if you have set the main document incorrectly in the left hand menu. This can happen if \documentclass[...]{...} is written in the wrong place, so you should correct this first if needed. To change the choice of main document, open the left hand menu:


and go to the Main document drop down menu: