LaTeX Wiki
Register
Advertisement

The tabular environment can be used to insert tables in text mode.

Syntax[]

Columns are separated by &, and each row ends with a double backslash \\:

\begin{tabular}[position]{column definition}
  Lorum      & ipsum & dolor       \\
  sit        & amet  & consectetur \\
  adipiscing & elit  & sed
\end{tabular}

Column definition[]

A tabular environment takes one required parameter, the column definition. A column definition of lcr would left-align the first column, center the second column, and right-align the third column.

The column definition can include vertical bars, e.g. l|c|r, to draw vertical borders.

Position[]

As the tabular environment is rendered inline as a single large character, the optional parameter position controls the position of the table relative to the baseline of the surrounding text:

b bottom
c center (default)
t top

Floating tabular[]

To make the table float, simply include it in a table environment or a figure environment.

\usepackage{hyperref}
...
\begin{table}
  \caption{Caption needs to be before the label.}
  \centering
  \begin{tabular}{lll}
    ...
  \end{tabular}
  \label{tbl:tablelabel}
\end{table}

See example at \autoref{tbl:tablelabel}.

The \centering command may be preferable to the center environment in a float, as the center environment will add a paragraph and create extra whitespace in the float.

A tabular environment may be nested within a minipage to allow side-by-side tables within a table or figure environment, or to place an image next to a table:

\begin{figure}
  \begin{minipage}{2in}
    ... image ...
  \end{minipage}
  \qquad
  \begin{minipage}{2in}
    \begin{tabular}{lll}
      ... table ...
    \end{tabular}
  \end{minipage}
\end{figure}

Advantages and limitations[]

LaTeX doesn't require any packages to use tabular by itself, so tabular is ubiquitous. The limitations of tabular are that it doesn't add sufficient whitespace around cells.

The booktabs package has a few commands that vastly improve the quality of tabular's tables, and the documentation for booktabs has some advice on typesetting tables properly.

Other packages[]

  • The ctable package allows captioned floating tables, with table footnotes properly laid out. It is also somewhat less wordy.
  • For an alternative approach to side by side tables, try the subfigure package. This also removes the need for specifying subtable width.
  • For handling tables that span pages, longtable.
  • The tabularx package for columns that fill the page width

External links[]

Advertisement