Fix a table that runs off the page in Overleaf.
LaTeX tables exceed the page margin because standard column types like l, c and r never wrap text automatically. You can solve wide tables cleanly with auto-wrapping columns in tabularx, reduced column padding, or landscape orientation without distorting font sizes.
The short answer: replace tabular with tabularx and use X columns for text that must wrap. If the table has many short numeric columns, reduce the default padding with \setlength{\tabcolsep}{4pt} or rotate the table into landscape mode using sidewaystable.
Identify why your table overflows
Tables overflow the right margin for distinct structural reasons. Use this guide to pick the appropriate fix rather than guessing.
| Symptom | Underlying cause | Recommended solution |
|---|---|---|
| Single column stretches far past the margin | Sentences inside standard l, c, or r column types | Switch to tabularx with an X column, or use p{width} |
1. Wrap text automatically with tabularx or p columns
Standard LaTeX column specifiers treat cell contents as single unbroken lines. When a cell contains a full sentence, LaTeX typesets it onto a single horizontal axis that pushes subsequent columns past the right margin.
The cleanest remedy is the tabularx package. It introduces the X column specifier, which expands to fill the remaining text width while automatically wrapping long sentences onto multiple lines. If you need exact widths instead of automatic distribution, specify fixed dimensions with p{width}.
Code examples for wrapping columns
Automatic width calculation with tabularx
Set the table width to \textwidth. The X specifier calculates the space left over after fitting the standard columns and wraps text smoothly across multiple rows.
\usepackage{tabularx} \begin{table}[htbp] \centering \begin{tabularx}{\textwidth}{l X X} \hline Method & Description & Expected Result \\ \hline Baseline & Standard model without data augmentations applied & Stable convergence \\ Proposed & Mixed training routine using synthetic datasets & Lower error rate \\ \hline \end{tabularx} \end{table}Fixed width wrapping with p columns
If you do not want to import tabularx, use p{width} in a standard tabular environment. Add the array package to left-align text instead of justifying it awkwardly in narrow cells.
\usepackage{array} \begin{tabular}{l >{\raggedright\arraybackslash}p{6cm} r} \hline Item & Description & Cost \\ \hline Service & Cloud compute hours including storage backups & $120 \\ \hline \end{tabular}
2. Squeeze whitespace and headers
When tables overflow by only 10 to 30 points, simple typographic adjustments will pull the table back within the margins without changing column structures.
Reduce inter-column padding with tabcolsep
LaTeX adds 6pt of horizontal whitespace on both sides of every column by default. In a table with ten columns, that padding alone accounts for 120pt of horizontal space. Reduce it inside the table environment to tighten spacing.
\begin{table}[htbp] \centering \setlength{\tabcolsep}{3.5pt} % Default is 6pt \begin{tabular}{llllllll} \hline ... & ... & ... & ... & ... & ... & ... & ... \\ \hline \end{tabular} \end{table}Break header cells across lines with makecell
Data columns with small numbers often stretch wide because their headings are long. The makecell package lets you insert manual line breaks inside individual headers.
\usepackage{makecell} % In your table row: \makecell{Average\\Runtime (s)} & \makecell{Peak Memory\\Usage (MB)} & \makecell{Final\\Accuracy (\%)}Adjust font size locally
Drop the table text size slightly by placing \small or \footnotesize inside the table environment. Never apply this globally across the document. Keep the sizing declaration scoped strictly inside the float.
\begin{table}[htbp] \centering \small \begin{tabular}{lllll} \hline ... \\ \hline \end{tabular} \end{table}
3. Handle wide tables in two-column and landscape documents
Complex scientific tables often contain too much data to fit inside a single column or portrait page. Use the document structure to grant the table more space.
Span both columns in two-column documents
If you are writing for an IEEE, ACM, or Elsevier journal in a two-column template, standard tables get confined to \columnwidth. Use table* to span both columns across the top of the page.
\begin{table*}[t] \centering \begin{tabular}{llllllllll} \hline Trial & Metric A & Metric B & Metric C & Metric D & Metric E & Metric F & Metric G \\ \hline ... \\ \hline \end{tabular*} \end{table*}Rotate the table into landscape
For exceptionally broad datasets, rotate the table 90 degrees using sidewaystable from the rotating package. The caption and table rotate together, leaving the page orientation intact.
\usepackage{rotating} \begin{sidewaystable} \centering \caption{Broad experimental results across all sample sites} \begin{tabular}{llllllllllll} \hline ... \\ \hline \end{tabular} \end{sidewaystable}Rotate the entire PDF page
If you want the PDF reader itself to display the page in horizontal format for screen reading, wrap the table in the pdflscape package instead of rotating only the float.
\usepackage{pdflscape} \begin{landscape} \begin{table}[htbp] \centering \begin{tabular}{llllllllllll} \hline ... \\ \hline \end{tabular} \end{table} \end{landscape}
4. The modern solution: tabularray
The newer tabularray package replaces older tabular hacks with a consistent syntax. It separates formatting from data, handles auto-wrapping with X columns natively, and allows direct vertical and horizontal alignment without loading array or makecell.
It also works seamlessly inside long tables that need to span multiple vertical pages while maintaining bounded column widths.
Writing a clean table with tabularray
Basic tabularray table
Specify total width with width=\textwidth and assign wrapping columns with X. You can add alignment markers inside brackets, such as X[2,l] for a column that takes twice the proportional width and aligns left.
\usepackage{tabularray} \begin{table}[htbp] \centering \begin{tblr}{ width = \textwidth, colspec = {l X[2,l] X[1,c] r}, hlines, } ID & Experiment Notes & Status & Score \\ 1 & Initial run showed minor calibration divergence & Validated & 94.2 \\ 2 & Repeated with temperature control enabled & Complete & 98.7 \\ \end{tblr} \end{table}
Why resizebox should be your last resort
Many forum posts recommend wrapping stubborn tables in \resizebox{\textwidth}{!}{...}. While this forces the table to fit between the page margins immediately, it produces severe typographic issues.
Resizebox scales the table as an arbitrary vector graphic rather than formatting text. Fonts shrink to inconsistent point sizes, horizontal lines become hair-thin, and numbers often turn completely illegible. Peer reviewers and publishers frequently reject papers with scaled tables.
Reserve \resizebox strictly for emergency submissions when a deadline is minutes away. For final publications, wrap long sentences with tabularx or reduce whitespace systematically.
Questions
Why does my table overflow the right margin in Overleaf?
LaTeX table columns set to l, c, or r do not wrap lines. Any text you enter stays on a single continuous horizontal line, forcing the edge of the table off the page if the text is longer than the remaining page width.
How do I make text wrap automatically inside table cells?
Load the tabularx package and replace tabular with tabularx{\textwidth}{...}. Use the X column specifier for any column containing descriptive sentences. LaTeX will then compute the remaining width and break lines naturally.
Can I use resizebox to fix a wide table quickly?
Try your own paper in Texeno.
Start free, upload a project as a .zip and press Recompile. Upgrade when you need longer compiles.
Start writing