An environment is a predefined context within a document that applies specific formatting, structure, or functionality to the enclosed content.
We've already seen these contexts for document
, itemize
, enumerate
, etc...
So the syntax has already been explained:
\begin{environmentname}
...
your stuff
...
\end{environmentname}
What are the environments (apart from document
) that are a "must include" for writing in $\LaTeX$?
equation
(or align
/gather
)It's used for mathematical expressions, almost like the 4 $ signs. It's included in the amsmath
package.
equation
Formatting in this environment can add different features: for example, it automatically enumerates the equations, making them easier to reference later in the text, and offers integrated captions/label support.
The four dollars syntax, to be fair, it's considered deprecated (but a lot of people still use it (myself included))
minipage
It's used to create text boxes or side-by-side content.
It's just a small page inside your main page (quite literally).
Easier done than said!
minipage
\begin{minipage}[t]{0.5\textwidth}
\lipsum[1-2]
\end{minipage}%
\begin{minipage}[t]{0.5\textwidth}
\centering
\includegraphics[width=\textwidth]{example-image-a}
\caption{Example figure}
\label{fig:example}
\end{minipage}
tabular
: to create tablesfigure
/table
: for adding and formatting figures side by sidelistings
: to write fancy code in your documentmulticols
: to display text in different columnscenter
: quite self explanatoryNote that a lot of environments are package-provided.
If you get good enough (or even if you don't) you can create your custom environment!