About
Shop
LaTeX
Software
Books
Gallery
News
Contact
Blog
Settings
Latest news 2019-11-04: The giveaway of two signed copies of “Quack, quack, quack. Give my hat back!” has closed and the winning entrants have been selected. Thank you to everyone who took part.


7.2 Tables

Tables are produced in much the same way as figures, except that the table environment is used instead.

\begin{table}[<placement specifiers>]

Where the optional argument <placement specifiers> is as described earlier.

As mentioned at the start of this chapter, tables typically have the caption at the top of the table [17]. With the KOMA-Script classes, such as scrartcl, scrreprt and scrbook, use the class option captions=tableabove to ensure that the vertical spacing appears correctly between the caption and the table content and put \caption at the start of the table environment. [Tables longer than a single page]Page breaks are not permitted in the table environment. (The longtable package can be used for that instead. See the longtable documentation for further details.)

Example:

In the preamble:

\documentclass[captions=tableabove]{scrbook}

Later in the document:

\begin{table}[htbp]
 \caption{A Sample Table}
 \label{tab:sample}
 \centering
 \begin{tabular}{lr}
 Item  & Cost\\
 Video & 8.99\\
 CD    & 9.99\\
 DVD   & 15.00
 \end{tabular}
\end{table}

This produces Table 7.1.


Table 7.1: A Sample Table
\begin{tabular}{lr}
Item & Cost\\
Video & 8.99\\
CD & 9.99\\
DVD & 15.00
\end{tabular}


Again, the \centering declaration is used to centre the tabular environment. As with figures, you can create a list of tables using the command

\listoftables

This creates a file with the extension .lot (see §2.4. Auxiliary Files). As with the table of contents and list of figures, you will need to LaTeX your document twice to get the list of tables up-to-date, unless you're using latexmk (as described in §5.5. Cross-Referencing) in which case it will be done automatically.

Exercise 17: Creating Tables

If you did Exercise 7, you should have a tabular environment in your document. Try turning this into a table, and add Table 7.1. You could also try adding a list of tables. As before, you can download or view the solution.


This book is also available as A4 PDF or 12.8cm x 9.6cm PDF or paperback (ISBN 978-1-909440-00-5).

© 2012 Dickimaw Books. "Dickimaw", "Dickimaw Books" and the Dickimaw parrot logo are trademarks. The Dickimaw parrot was painted by Magdalene Pritchett.

Terms of Use Privacy Policy Cookies Site Map FAQs