# LaTeX Error: Can be used only in preamble

LaTeX Error: Can be used only in preamble
translation: Xovee
translation time: June 11, 2020
LaTeX Error: Can be used only in preamble
This error occurs if you introduce a package or class in the body of the text, rather than in the preamble. Before the command \begin{document}, everything is called a prologue. In the prologue, you define the type of document, the language of the document, and many basic Settings. For example, the preface to a general document looks something like this:

\documentclass[12pt, letterpaper]{article}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}

\title{First document}
\author{Hubert Farnsworth \thanks{funded by the ShareLaTeX team}}
\date{February 2014}


If you introduce the package in the body (after \begin{document}) instead of in the preface, you will get this error:

To resolve this error, you must ensure that all packages introduce the command \usepackage{… }, and \ documentClass []{… }, before the \begin{document} command. If you want to learn more about LaTeX document structure, please refer to this document.