[Tex/LaTex] LaTeX Error: \begin{document} ended by \end{section}

sectioning

I am encountering the above error message. This is what I have so far:

\documentclass{article}
\title{Assignment \#1}
\author{First Name Last Name}
\date{March 20, 2014}

\begin{document}
\maketitle     
\section*{Question 1}
\textit{Scenario containing 2 pirates :} \\*\\*
Regardless of how the gold is split, the 2nd pirate will vote against the 1st pirate and take all the gold. \\*\\*
\end{section}

\textit{Scenario containing 3 pirates:} 

\begin{table}[ht]
\caption{3 Pirates}
\centering
\begin{tabular}{c c c}
\hline\hline
Pirate\#1 & Pirate\#2 & Pirate\#3 \\  
\hline
x & x &  x \\
\hline
\end{tabular}
\end{table}


\end{document}

Best Answer

LaTeX provides two forms for executing content: the macro, and the environment. Which is preferable depends on the use. Which is available is often beyond your control. Some commands are given in both forms, e.g., \centering versus \begin{center}...\end{center}.

But the key usage difference is that a macro's arguments (if any) are provided at the time of invocation, whereas an environment is told to begin with a \begin{environment-name} statement and continues under the control of that environment's settings until an \end{environment-name} is invoked. In this regard, the environment requires the symmetry of a \begin{}...\end{} "book-ends".

In your example, \section is a macro, not an environment. That is to say, it did not begin with \begin{section}. When invoked, it produces a header to show the section title, it creates a number for the section, and it may make note of an entry for a table of contents. The section header may be stylized in larger, bolder font, or in any number of ways, depending on how \section has been defined by the class and or included packages. But once the argument(s) to \section have been processed, the subsequent text is not within the confines of a "section environment", but just regular document text. \section has no more to do with it.

Thus, \end{section}, which appears in your MWE, is incorrect. Remove that line and the code compiles.

Related Question