Center a table in LaTeX (centering)

Write \centering at the start of the table environment. A tabular without a float goes into a center environment.

Center a table in a float

\centering applies to everything up to \end{table} and adds no vertical space.

\begin{table}
\centering
\begin{tabular}{lr}
\hline
Item  & Price \\
\hline
Apple & 0.50 \\
\hline
\end{tabular}
\caption{Fruit prices}
\end{table}
Result
The compiled example

Open in the editor

Center a table without a float

The center environment starts a new paragraph, centers its content and leaves space above and below.

Text before the table.
\begin{center}
\begin{tabular}{lr}
\hline
Item  & Price \\
\hline
Apple & 0.50 \\
\hline
\end{tabular}
\end{center}
Text after the table.
Result
The compiled example

Open in the editor

Center a table that is wider than the text

\centering cannot center a table that is wider than the text block; the table starts at the left margin and sticks out on the right. \makebox[\textwidth]{...} builds a box as wide as the text block and centers its content, so the table sticks out by the same amount on both sides.

\begin{table}
\makebox[\textwidth]{%
\begin{tabular}{|p{0.35\textwidth}|p{0.35\textwidth}|p{0.35\textwidth}|}
\hline
First column & Second column & Third column \\
\hline
\end{tabular}}
\caption{A table that is wider than the text block}
\end{table}
Result
The compiled example

Open in the editor

Pitfalls

Compiled with pdfLaTeX from TeX Live 2023.

Related pages