Make a LaTeX table fit the page width

Help centre › LaTeX › Tables · Packages: tabularx, booktabs

Use \usepackage{tabularx} and \begin{tabularx}{\linewidth}{l X X}: the X columns share the remaining width and wrap their text, so the table is exactly as wide as the text. For a table that is only slightly too wide, a smaller font (\small) or less column spacing (\setlength{\tabcolsep}{4pt}) is often enough; scaling with \resizebox works but makes the font size inconsistent.

A complete example

A whole document: paste it into an empty project and compile it.

\documentclass{article}
\usepackage{tabularx}
\usepackage{booktabs}
\begin{document}
\begin{table}[htbp]
  \centering
  \caption{Methods compared.}\label{tab:methods}
  \begin{tabularx}{\linewidth}{l >{\raggedright\arraybackslash}X >{\raggedright\arraybackslash}X}
    \toprule
    Method & Strengths & Limitations \\
    \midrule
    Survey & Reaches many people at low cost and gives comparable answers
      & Answers are self-reported and response rates can be low \\
    Interview & Gives depth and lets the researcher follow up on answers
      & Takes time and the sample is small \\
    \bottomrule
  \end{tabularx}
\end{table}
\end{document}

tabularx: X columns

tabularx takes the total width as its first argument and makes every X column as wide as needed to reach it, all X columns equally wide. Text in X columns wraps like a paragraph. Use \linewidth (the current text or column width); in a two-column table*, \textwidth.

X columns are justified by default, which leaves wide gaps in narrow columns. >{\raggedright\arraybackslash}X sets them ragged-right; define it once with \newcolumntype{L}{>{\raggedright\arraybackslash}X} and write L.

p{} columns: fixed widths that wrap

In a plain tabular, p{4cm} makes a column of that width whose text wraps. It is enough when you know the widths you want; the table's total width is the sum of the columns plus the spacing between them.

\begin{tabular}{l p{5cm} p{5cm}}

Slightly too wide: smaller font and tighter spacing

Put the size command inside the table environment, before the tabular; it then applies to the table only. \tabcolsep is half the space between columns (6pt by default).

\documentclass{article}
\begin{document}
\begin{table}[htbp]
  \centering
  \small
  \setlength{\tabcolsep}{4pt}
  \caption{Smaller type and tighter columns.}
  \begin{tabular}{lrrrrrrr}
    \hline
    Group & Mean & SD & Min & Q1 & Median & Q3 & Max \\
    \hline
    Control & 12.4 & 3.1 & 5.0 & 10.2 & 12.5 & 14.6 & 19.8 \\
    Treated & 15.1 & 2.8 & 8.3 & 13.0 & 15.2 & 17.1 & 22.4 \\
    \hline
  \end{tabular}
\end{table}
\end{document}

\resizebox: a last resort

\resizebox{\linewidth}{!}{\begin{tabular}…\end{tabular}} (graphicx) scales the whole table to the width. It always fits, but every table ends up with a different font size, often much smaller than the text, which journals and examiners notice; it also scales small tables up. If you use it, scale only tables that are too wide: adjustbox with \begin{adjustbox}{max width=\linewidth} shrinks a table that is too wide and leaves others alone.

Common mistakes

In journal templates

Errors you may meet

In Manulyx

Insert → Table puts a table environment in place, and pasting a range copied from a spreadsheet (two or more rows and columns) goes in as a LaTeX table, with booktabs rules when the paper loads booktabs and \hline otherwise; a notice offers the plain text back.

Write in Manulyx for free · Journal templates

Related

The examples on this page were compiled with pdfLaTeX to check that they work as shown. LaTeX quick reference · LaTeX errors explained