Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Make LaTeX table caption same width as table?

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} 
like image 307
webjunkie Avatar asked Jul 23 '10 21:07

webjunkie


People also ask

How do I change the width of a caption in LaTeX?

If all your figures have the same width, you can set the option \captionsetup{width=<len>} globally.

How do you align table captions in LaTeX?

Add to your preamble \usepackage{caption} \captionsetup[table]{singlelinecheck=false} . Otherwise, you can center the table adding \centering just after \begin{table} (probably this way it looks better inside a document).

How do I increase the space between a table and caption in LaTeX?

You can add the required space by using the \vspace .


2 Answers

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)

like image 158
Johu Avatar answered Sep 22 '22 09:09

Johu


I've had success by putting my caption in a parbox:

\parbox{5cm}{\caption{Lorem ipsum dolor sit amet...}} 
like image 38
lubar Avatar answered Sep 25 '22 09:09

lubar