Table placement & styling

tabular sets only the *contents* of a table. Giving that table a numbered heading (a caption) and floating it to a sensible spot on the page is the job of the floating **table environment**. This page covers everything *around* the tabular: the placement specifiers in \begin{table}[htbp], the conventions for \caption and \label, the scaling and rotation tricks for a table that overflows the page, and **threeparttable** for adding notes. For building the contents themselves, see “tabular basics.”

Why tables “float”

Tables and figures cannot be broken across a page boundary — they must sit whole on a single page. If LaTeX tried to put one exactly where it appears in the source and the remaining space were too small, you would get an ugly gap or an awkwardly clipped table. So LaTeX treats tables and figures as floats: it detaches them from the running text and floats them automatically to a convenient place, often the top of the next page.

The table environment is how you use this. You put a tabular inside it, give it a numbered heading like “Table 1” with \caption{…}, and make it referenceable from the text with \label{…} and \ref{…}. So in your prose you write a reference by number — “as shown in Table 1” — and no matter which page the table is floated to, the reference always resolves to the right number. That is the payoff of floating.

Placement specifiers [htbp] and [H]

In the brackets right after \begin{table} you pass, one letter at a time, your preferences for where it should go. There are four specifiers.

SpecifierMeaning
hHere — at the source position. But h is not allowed alone; t is added automaticallyHere
tTop of a text pageTop
bBottom of a text pageBottom
pA separate float-only page (no body text)Page

With no specifier, the default in both article and book is **tbp**. Stringing several together, as in [htbp], gives the set of places you permit — “here if possible, otherwise top, otherwise bottom, otherwise a float page.” Crucially, the order you write them does not change the order LaTeX tries them: it always attempts t, then b, then p, so [htbp] and [bpht] behave identically. Think of it as a fallback chain for when your first choice will not fit.

A leading exclamation mark, as in [!ht], says “for this float only, ignore the internal limits on how many floats and how much float-versus-text may sit on a page, and try to place it.” **! does not mean “put it here” — it merely relaxes the criteria. If you genuinely want it pinned in place, use [H]** from the float package: with \usepackage{float}, writing \begin{table}[H] makes the table stop floating and set exactly at that point in the source (which can leave a large gap at the foot of the page). It helps to think of H as “a float that does not float.”

document.tex
\usepackage{float}   % \begin{table}[H] のために

\begin{table}[htbp]
  \centering
  \caption{四半期ごとの売上}
  \label{tab:sales}
  \begin{tabular}{lrr}
    \hline
    四半期 & 売上 & 前年比 \\
    \hline
    Q1 & 1{,}200 & +5\% \\
    Q2 & 1{,}350 & +8\% \\
    \hline
  \end{tabular}
\end{table}

You reference it from the body with Table~\ref{tab:sales} (the ~ is a tie that keeps the word and number from being split across a line break). What to do when placement stubbornly refuses to cooperate is covered in depth on the “Floats & placement” page.

Caption, label, and centering

\caption{…} gives a float a numbered heading, automatically labeling it “Table 1:” in an article or “Table 1.1:” in a book. Tables and figures use separate counters, so table numbers never mix with figure numbers. With the optional argument, \caption[short]{full caption}, the list of tables shows the short form while the body shows the full one.

Two conventions matter. First, **\caption is what advances the counter, so \label must come after \caption**; reverse them and \ref will point to the previous number. Second, placement convention: by long-standing practice, the caption goes above a table and below a figure (the reader sees a table’s heading before reading it, and reads a figure’s caption after looking at it). In LaTeX you get the caption *above* by writing \caption *before* the tabular, and *below* by writing it *after*.

\centering is a declaration that switches the float’s contents from the default left to centered. Inside floats the idiom is \centering, *not* the center environment (\begin{center}…\end{center}): the center environment adds extra vertical space above and below, whereas \centering is just a declaration and adds none. To fine-tune the caption’s formatting (font, separator, width), reach for the caption package — see the “Captions & subfigures” page.

Tables wider than the page

Because l, c, and r columns do not wrap, a table with many columns or long entries will spill past the text width (\textwidth). The quickest fix is to shrink the whole table with graphicx’s **\resizebox**. Its form is \resizebox{width}{height}{material}, and setting one of the two to **! scales proportionally** to the other, preserving the aspect ratio.

latex
\resizebox{\textwidth}{!}{%
  \begin{tabular}{lrrrrr}
    \hline
    項目 & 1月 & 2月 & 3月 & 4月 & 5月 \\
    \hline
    売上 & 120 & 135 & 128 & 142 & 150 \\
    \hline
  \end{tabular}%
}

This makes the table exactly as wide as the text. But **\resizebox *scales* its contents, so glyph weights, rule thicknesses, and even math symbols are all stretched or squeezed uniformly, and the type usually ends up mismatched with the surrounding text. Treat shrinking as a stopgap; the proper fix is to repair the table itself** — drop columns, wrap with p{width}, or abbreviate. In place of \resizebox, the **adjustbox** package integrates better with the surrounding layout and can be written as an environment, e.g. \begin{adjustbox}{width=\textwidth}…\end{adjustbox}.

To avoid scaling altogether, you can drop the whole table down a type size: declaring \small or \footnotesize inside \begin{table} sets it in a genuinely smaller font without distorting rule or math proportions. For finer control you can, say, put \hfill before the contents to push the table to the right rather than centering it. More fundamental width control — such as tabularx, which stretches columns to a target width — is covered on the “Advanced table environments” page.

Rotation — landscape tables

A table too big for a portrait page can be turned landscape (sideways) to use a full page. The rotating package (built on the standard graphics layer) provides the **sidewaystable** environment, which you use in place of table. The table is placed rotated 90° on its own dedicated page, caption and number rotated with it, and it still appears in the list of tables. In two-sided documents the package even chooses the rotation direction automatically so the spread reads naturally. For figures there is the matching sidewaysfigure.

document.tex
\usepackage{rotating}

\begin{sidewaystable}
  \centering
  \caption{多数の列を持つ横向きの表}
  \label{tab:wide}
  \begin{tabular}{lrrrrrrrr}
    \hline
    地域 & Q1 & Q2 & Q3 & Q4 & 合計 & 前年 & 増減 & 比率 \\
    \hline
    東日本 & 120 & 135 & 128 & 142 & 525 & 500 & +25 & 105\% \\
    \hline
  \end{tabular}
\end{sidewaystable}

To rotate just part of a table at an arbitrary angle, use **\rotatebox{angle}{material}** (also from graphicx/rotating). A common use is standing a single header cell on end with \rotatebox{90}{long column name} (positive angles turn counter-clockwise). Note that rotating deals in rotated boxes, and a box always stays on one page. To set running *text* in landscape across several pages, use lscape (or pdflscape, which rotates the PDF page itself) rather than rotating.

threeparttable — tables with notes

You often want footnotes attached to a table’s cells. But \footnote inside a tabular misbehaves — the note jumps to the bottom of the page, or fails to print at all. The **threeparttable package solves this. As the name suggests, it treats a table as three parts — title (caption), body (tabular), and notes (tablenotes) — and sets the notes to the width of the table, directly beneath it**.

To use it, inside a threeparttable environment you place, in order, **\caption, then the tabular, then a tablenotes environment. Linking notes is manual**: put a marker like \tnote{a} in a cell, and write the note with the same letter as \item[a] … inside tablenotes (the author kept it manual deliberately, since one note is often referenced from several cells). A threeparttable does not float on its own, so to get a number and placement you wrap the whole thing in a table.

document.tex
\usepackage{threeparttable}

\begin{table}[htbp]
  \centering
  \begin{threeparttable}
    \caption{品種ごとの収量}
    \label{tab:yield}
    \begin{tabular}{lrr}
      \hline
      品種 & 収量\tnote{a} & 価格\tnote{b} \\
      \hline
      コシヒカリ & 540 & 380 \\
      あきたこまち & 520 & 360 \\
      \hline
    \end{tabular}
    \begin{tablenotes}
      \footnotesize
      \item[a] 単位は 10a あたりの kg。
      \item[b] 1kg あたりの卸売価格(円)。
    \end{tablenotes}
  \end{threeparttable}
\end{table}

Here the outer table carries the number and placement, while threeparttable binds the three parts — caption, body, notes. The \tnote{a} and \tnote{b} in the header cells appear as small superscript markers, and beneath the table the matching a and b notes line up at the same width as the table. The tablenotes environment takes formatting options, used as follows.

OptionEffect
paraNotes run one after another in a single paragraph, no line breaksNotes one-after-another
flushleftNo hanging indentation on the notesNo hanging indent
onlineThe \item tag prints at normal size, not as a superscriptNormal-size tag
normalRestores default formatting (to override document-wide options)Restore defaults

These can be set document-wide, as in \usepackage[para]{threeparttable}, or per table, as in \begin{tablenotes}[flushleft]. Note that threeparttable does not itself style the caption, so for a proper heading look pair it with the caption package. To put notes on a page-spanning table (longtable), use the sister package threeparttablex.