How-to

How to Fit a Wide Table on the Page in LaTeX

The fix

When a table is wider than the page, use tabularx to auto-wrap columns to \textwidth, or wrap the tabular in \resizebox{\textwidth}{!}{...} to scale it down. For very wide tables, rotate the whole thing with the sidewaystable environment (rotating package). tabularx is cleanest because text wraps instead of shrinking.

Why it happens

A tabular takes exactly the width of its content, so many columns or long cell text push it past the text margin — you get an Overfull \hbox warning and the table bleeds into the margin. You have to wrap the text, scale the box, or rotate the page.

Example

% Best — wrap columns to text width (X columns flex):
\usepackage{tabularx}
\begin{tabularx}{\textwidth}{l X X}
  Name & Long description ... & More text ... \\
\end{tabularx}

% Quick scale-to-fit (keeps layout, shrinks font):
\usepackage{graphicx}
\resizebox{\textwidth}{!}{%
\begin{tabular}{lccc} ... \end{tabular}}

% Rotate a very wide table:
\usepackage{rotating}
\begin{sidewaystable} ... \end{sidewaystable}

Frequently asked questions

tabularx or resizebox — which should I use?

Prefer tabularx: it wraps cell text so everything stays readable at the normal font size. \resizebox is faster but shrinks the font, which can become too small on wide tables.

How do I shrink column padding instead?

Reduce inter-column space with \setlength{\tabcolsep}{4pt} and/or set a smaller font (\small, \footnotesize) right before the tabular. Often enough for a slightly-too-wide table.

My table is tall, not wide.

Use longtable (from the longtable package) so it breaks across pages, repeating the header row at the top of each page.

Try the fix in LetX

Open the editor, paste your code, and compile in 1 second to see the error clear — free, in your browser.

Open LetX Free