Fixing a LaTeX table that is too wide for the page
A table that is too wide triggers an Overfull \hbox warning and runs into the margin. Fix it in order: reduce column padding and font size, wrap long text columns, scale the table with adjustbox or resizebox only if needed, and rotate the page with landscape or sidewaystable when the table is genuinely wide. Each step costs some legibility, so stop at the first one that fits.
Convert a table from a PDF or screenshot →By TableToLatex · · Examples tested with pdfLaTeX, TeX Live 2023, graphicx, adjustbox, rotating, pdflscape
Fix it in this order
LaTeX prints Overfull \hbox (76.4pt too wide) when a tabular is wider than the text block, and the table runs into the margin. The number tells you how much to recover. In a test, a ten-column results table in the article class, with a 6.5 inch text block, was 76 pt too wide. Work down the list and stop at the first fix that fits, because each one costs something.
First, tighten. Shorter headers (Acc., Prec., Lat. (ms)) were enough for the test table. A smaller font and tighter padding also work: \small with \tabcolsep at 4pt left it 4.4 pt over, and 3pt fitted. Put both inside the table environment so they stay local.
\begin{table}[htbp]
\centering
\small
\setlength{\tabcolsep}{3pt} % default is 6pt
\caption{Wide results table.}
\begin{tabular}{lrrrrrrrrr}
% ... same rows ...
\end{tabular}
\end{table}If one column holds sentences, give it a fixed width so the text wraps instead of widening the table.
% preamble: \usepackage{array}
\begin{tabular}{l p{6cm} r}
\toprule
Dataset & Description & Size \\
\midrule
A & A long description that wraps inside a fixed-width column. & 12k \\
\bottomrule
\end{tabular}Scaling comes next. adjustbox with max width=\linewidth shrinks the table only when it is too wide. The same test table fitted at about 86% of its size, so 10 pt type became roughly 8.6 pt.
% preamble: \usepackage{adjustbox}
\begin{table}[htbp]
\centering
\caption{Wide results table.}
\begin{adjustbox}{max width=\linewidth}
\begin{tabular}{lrrrrrrrrr}
% ... same rows ...
\end{tabular}
\end{adjustbox}
\end{table}For a table that is genuinely wide, rotate it. sidewaystable from the rotating package puts the table and its caption on their own turned page. Wrapping a table[p] in a landscape environment from pdflscape rotates the whole page, notes included.
% preamble: \usepackage{rotating}
\begin{sidewaystable}
\centering
\caption{Wide results table.}
\begin{tabular}{lrrrrrrrrr}
% ... same rows ...
\end{tabular}
\end{sidewaystable}Two-column templates have a narrower measure, so the limits are tighter; see two-column tables for table*. A table that is taller than a page is a longtable problem, and long group labels can often be shortened with grouped headers.
Fix a wide table in seven steps
- 1
Read the number
The warning "Overfull \hbox (76.4pt too wide)" says how much width to recover.
- 2
Shorten the headers
Abbreviate long labels, keep units short, and consider moving rarely used columns to an appendix table.
- 3
Tighten the type
Inside the table environment, add \small and \setlength{\tabcolsep}{4pt}, or 3pt for a tighter fit.
- 4
Wrap long text
Give a sentence column a fixed width with p{6cm}, or use tabularx with an X column.
- 5
Scale only if needed
Wrap the tabular in an adjustbox with max width=\linewidth, and note the scale it applies.
- 6
Rotate a genuinely wide table
Use sidewaystable, or a landscape page, when scaling would make the text too small to read.
- 7
Recompile and re-check
Compile twice, look for remaining Overfull warnings, and check the final type size against the venue's guidance.
When each fix is right
| Fix | Package | Right when | What it costs |
|---|---|---|---|
| Short headers, \small, smaller \tabcolsep | none | Over by a few dozen points | A little density |
| p{} or tabularx X columns | array, tabularx | One or two columns of sentences | Taller rows |
| adjustbox max width | adjustbox | Slightly too wide; must stay in the text | Smaller type; never enlarges |
| resizebox | graphicx | Same, and you want an exact width | Smaller type; also enlarges narrow tables |
| sidewaystable | rotating | Genuinely wide; one or two tables | Own page; readers turn the page |
| landscape | pdflscape | Several wide tables or a table with notes | Whole page rotated |
What goes wrong
- Sizing to the wrong width. In a two-column template
\textwidthis the full page, so a table sized to it spills over the neighbouring column. In IEEEtran,\linewidthmeasured 252 pt inside a table and 516 pt inside a table*. - Enlarging by accident.
\resizebox{\linewidth}{!}{...}on a narrow table magnifies it. adjustbox with max width does not. - Different scales in one paper. Each scaled table gets its own factor, so type size varies from table to table.
- The font change leaks.
\smallwritten outside the float affects the paragraphs that follow. - A landscape page that reads sideways on screen. In a test, the older
lscapepackage left the PDF page unrotated, whilepdflscapeset it to 90 degrees. - Testing in a scratch document. The same table can fit a plain article page and overflow a conference template.
How TableToLatex helps
TableToLatex writes plain l, r and c columns without scaling, so a table with many columns arrives as wide as its content, and merged header cells are flattened into one header row. Paste it into your template, then apply the fixes above. The LaTeX table generator is the place to start. The table tool is free and runs in your browser. Paste a tab-separated range from a spreadsheet. See pricing.
Questions about wide tables
Why does LaTeX warn Overfull hbox for my table?+
The tabular is wider than the line it sits on. The number in the warning is how many points too wide it is. LaTeX still typesets the table and lets it run into the right margin.
Should I use resizebox or adjustbox?+
Prefer adjustbox with max width=\linewidth: it shrinks a table only when it is too wide and leaves a narrow one alone. \resizebox{\linewidth}{!}{...} always scales to the given width, so it also enlarges a narrow table. In a test it blew a two-column table up to the full line.
How small can the text in a table be?+
Check your venue's author instructions; some set a minimum type size for tables and figures. Scaling by 86%, as in the test table here, turns 10 pt text into about 8.6 pt, so compute the result before you submit.
How do I fit a table into one column of a two-column paper?+
Size everything to \columnwidth: abbreviate headers, use \footnotesize, set \tabcolsep to 3pt or less, and wrap text columns. If it still does not fit, make it span both columns with table*, as described in the two-column guide.
Landscape or sidewaystable?+
sidewaystable rotates one float onto its own page, caption included, so it suits a single table. A landscape environment rotates the whole page, which suits a table with notes or several tables in a row. Use pdflscape rather than lscape so the PDF page itself is rotated.
How do I reduce the space between columns?+
Set \setlength{\tabcolsep}{4pt} inside the table environment. The default is 6pt on each side of a column, so every column costs 12pt of padding before any text.
Does changing the font size for one table affect the rest of the document?+
No. \small, \footnotesize and \setlength{\tabcolsep}{...} only apply inside the group they are written in; put them right after \begin{table} and \centering, and the surrounding text keeps its normal size.
What if the table is both too wide and too long?+
Fix the width first with the steps above, then move to longtable or xltabular for the length, as covered in the tables-across-pages guide. Doing it in that order avoids resizing a table you are about to reflow anyway.
Keep reading
- Two-column tables
table*, [!t] placement, widths and float order in IEEEtran-style templates.
- longtable
Repeating headers across pages with longtable and xltabular.
- Grouped headers
Grouped headers with \multicolumn, \multirow and trimmed \cmidrule rules.
Have a table in a spreadsheet? Paste it into the table tool, or see all LaTeX table guides.