% !TeX root = ../easyfloats.tex \section{Motivation} \label{motivation} In this section I will explain how to insert figures and tables in standard \LaTeX\ without this package and how this package can improve that. If you are only interested in how to use this package not why, see \cref{examples} for examples and \cref{documentation} for an explanation of the commands, environments and options defined by this package. \subsection{Graphics} \label{graphics} Inserting a graphic without using this package requires 6 lines of code (\pkg{graphicx} or \pkg{graphbox} must be loaded for `\includegraphics`): \begin{examplecode\starred}{\ExamplecodeNoBox\ExamplecodeLinenumbers} \begin{figure} \centering \includegraphics[graphic width=.8\linewidth]{ctan_lion} \caption{CTAN lion drawing by Duane Bibby} \label{ctan_lion} \end{figure} \end{examplecode\starred} \begin{description} \item[Lines 1 and 6] open\slash close a floating environment. The content of this environment can float around so that it won't cause a bad page break. You don't need this if you really just want to insert a graphic exactly here (like a logo in a header) but a graphic cannot break across pages so if it is too large for the end of the current page it will move to the next page leaving the end of this page empty. This is a waste of paper and may confuse a reader by suggesting this might be the end of a chapter. A floating environment can help you by putting the figure where it fits best. The placement determines where a float is allowed to be placed. Initially that's the top or bottom of a text page or a separate page just for floats. The placement can be specified for a single floating object by passing an optional argument to the floating environment or for all floating objects using the `\floatplacement` command defined by the \pkg{float} package. (The floating environments `figure` and \env{table} are standard \LaTeX\ and do not require the \pkg{float} package.) The allowed values for the placement are described in the description of the \env{object} environment's `placement` key. There are people who are concerned that a figure not sitting at the exact position might confuse a reader. However, a graphic naturally attracts the reader's attention. Therefore it does not matter where it is located on the double page. The reader will see it. Of course the author must ensure that the figure does not float too far away. If that is the case changing the size of this or another graphic, `\usepackage[section]{placeins}`, `\FloatBarrier` (defined by the \pkg{placeins} package), moving this block of lines in the code, changing the placement or tweaking the parameters which govern the placing of floats \autocite[page~28]{latex2e} can help. \item[Line 2] centers the graphic horizontally on the line. The `\centering` command is used instead of the `center` environment because the latter would insert additional vertical space. \begin{examplecode\starred}{\ExamplecodeNoBox} \begin{center} ... \end{center} \end{examplecode\starred} is in \LaTeX2\footnote{This will change in \LaTeX3~\autocite{ltx3env}.} \makeatletter (somewhat simplified\footnote{`\begin` checks that it's argument is defined, `\end` checks that it's argument matches that of `\begin` and deals with `\ignorespacesafterend` and `\@endparenv`. Since 2019/10/01 `\begin` and `\end` are robust. Since 2020/10/01 they include hooks. \autocite[section \sectionname{ltmiscen.dtx}]{source2e}}) \makeatother equivalent to \begin{examplecode\starred}{\ExamplecodeNoBox} \begingroup \center ... \endcenter \endgroup \end{examplecode\starred} This means that if you accidentally try to use `\centering` as an environment instead of a command you will *not* get an error. You might expect to get an error at least for `\endcentering` not being defined but the \TeX\ primitive `\csname` which is used to produce the `\endcentering` token instead defines it to `\relax`, a no operation. The output, however, will not be as desired: the group is closed before the end of the paragraph and `\centering` is forgotten before it can take effect. \item[Line 3] inserts the graphic. This requires the \pkg{graphicx} or \pkg{graphbox} package. If you want all graphics to have the same width you can set the `width` globally with `\setkeys{Gin}{width=}`. However, that does not work with all options. Unfortunately the \pkg{graphicx} package documentation~\autocite[section~4.6]{graphicx} is not getting more specific than that this works with \enquote{Most of the keyval keys}. \item[Line 4] inserts the caption. Captions for a figure should be placed *below* the figure. Captions for a table should be placed *above* the table. \autocite{texexchange_caption_position} `\caption` can be used inside of a floating environment only. If you need a caption for a non-floating object you can either use `\captionof{}{}` defined by the \pkg{capt-of} or \pkg{caption} package or use a floating environment with the placement `H` defined by the \pkg{float} package. \item[Line 5] defines a label. This is not visible in the output but can be referenced using `\ref{