Reputation: 7039
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}
Upvotes: 33
Views: 76459
Reputation: 638
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)
Upvotes: 41
Reputation: 9225
Put your table plus caption inside a minipage. The caption will wrap. This is also a great way to have proper footnotes for tables.
Upvotes: 2
Reputation: 51
in caption package guide:
Only fixed widths are supported here; if you are looking for a way to limit the width of the caption to the width of the figure or table, please take a look at the floatrow[8] or threeparttable[22] package.
Upvotes: 5
Reputation: 2649
I've had success by putting my caption in a parbox:
\parbox{5cm}{\caption{Lorem ipsum dolor sit amet...}}
Upvotes: 14
Reputation: 3620
if you know or find out the width of the table, let's say 5cm -
if you're using a KOMA-Script class:
\setcapwidth[c]{5cm}
if you're using the caption package:
\captionsetup{width=5cm}
Both may be applied inside the table environment.
An automatically calculating solution is more complicated, but could be done using the \settowidth command.
Upvotes: 14