# Crash Course in LaTeX

## Workin' It: Floats

A float is a table or figure, usually numbered consecutively. Professional editors/typesetters don't automatically put these exactly in the place where they are first mentioned. Sometimes the page looks better with the table at the top of the page, sometimes it looks better placed at the bottom, or on a page of its own. LaTeX does this too, using the float commands table and figure.

FAQ:

• Why bother using floats? There are several good reasons.
• Letting tables and figures move around means fewer weird blank areas caused by them not fitting well on a page.
• Automatic numbering.
• Automatic List of Figures and List of Tables.
• Makes it easy to refer to figures and tables by number and page, even when the number and page change. (See References for full details.)
• What's the difference bewteen tabular and table? This is a common source of confusion.
• Use tabular to make tables.
• Use table wrapped around a tabular environment to float a table. You might use tabular without table, but generally you won't use table without tabular.
Here is a sample table we saw when learning about tables:

Example:

\begin{tabular}{|c|l|}
\hline
Cell 1 & Cell 2 \\
\hilne
Bottom row is longer & but the table adjusts to fit! \\
\hline
\end{tabular}

Which looks like

 Cell 1 Cell 2 Bottom row is longer but the table adjusts to fit!
Now, let's wrap this with a float, specifically a table.
\begin{table}
\begin{tabular}{|c|l|}
\hline
Cell 1 & Cell 2 \\
\hilne
Bottom row is longer & but the table adjusts to fit! \\
\hline
\end{tabular}
\end{tabular}
That isn't too hard, is it? Now it will float around: woo hoo. But this is not the whole feast; let's add the trimmings.
\begin{table}
\caption{Example Table in a Float}
\label{tab:example-float}
\begin{center}

\begin{tabular}{|c|l|}
\hline
Cell 1 & Cell 2 \\
\hilne
Bottom row is longer & but the table adjusts to fit! \\
\hline
\end{tabular}

\end{center}
Notes: This table is an example. Source: my imagination.

\end{tabular}
Let's break this down.
• \caption: This is the title of the table or figure. This one would be rendered 'Table 1: Example table in a Float'. The caption is also how the table or figure will be listed in any automatically generated List of Tables/Figures.
• \label: This is an internal label you use to refer to this table or figure. This label is never seen in the final document. Genereally, I use the prefix 'tab:' for tables and 'fig:' for figures, but this is not necessary. Key: the label should describe the content and not just contain a number, because the numbering may change later. I cover this in detail when I discuss References.
• center: Generally, the table or figure itself should be centered, but the 'Notes' at the bottom should not. The Notes will wrap lines, so you can have a full paragraph (or more) in the Notes section, but don't go crazy here.
(More content coming...)