% !TEX root = ../manual.tex
% !TEX program = xelatexmk
% !TEX spellcheck = en_GB

\section{Commands, environments and comments}
\LaTeX is mostly written using two ‘structures’: commands and environments. Commands start as follows and can have multiple \emph{arguments}, some of which can be \emph{optional}. The order and amount of  arguments varies per command.

\begin{lstlisting}
\command{argument}[optional argument]
\end{lstlisting}

In \LaTeX\ curly brackets (|{}|) denote mandatory arguments and square brackets (|[]|) denote optional arguments.

Environments work by using the \emph{begin} and \emph{end} commands.

\begin{lstlisting}
\begin{environment}[optional argument]
	environment content
\end{environment}
\end{lstlisting}

The most important thing is to make sure every bracket is closed and every environment is ended. If you don't you’ll get errors like:

\begin{lstlisting}
Runaway argument?
[...]
! File ended while scanning use of \emph .
\end{lstlisting}

or

\begin{lstlisting}
! LaTeX Error: \begin{figure} on input line 73 ended by \end{document}.
\end{lstlisting}

You can comment a line in your document by starting it with a percent sign (\texttt{\%}):
\begin{lstlisting}
% This is a comment and will not be shown in your pdf.
\end{lstlisting}
