Make LaTeX table caption same width as table?

webjunkie picture webjunkie · Jul 23, 2010 · Viewed 52.1k times · Source

It looks bad in my paper if a caption is wider than the table underneath it. How can I make them both align?

Right now my code looks like:

\begin{table}[th!]
\caption{Reference temperature blah blah}
\centering
\begin{tabular}{llll}
...
\end{tabular}
\end{table}

Answer

Johu picture Johu · May 9, 2012

Actually there is a more legal way to do this using captions package option width.

For global effect

\usepackage[width=.75\textwidth]{caption}

For local effect only in current environment:

\usepackage{caption}
\captionsetup{width=.75\textwidth}


More info in caption package doc:

https://www.ctan.org/pkg/caption?lang=en

http://mirrors.ctan.org/macros/latex/contrib/caption/caption-eng.pdf (direct link to PDF subject to change)