Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Figure captions seem to wrap at the page width. How could I make them wrap at the figure width instead? Currently, they can easily be mistaken for normal text.

\begin{figure}[!htb]
    \begin{center
    \begin{tikzpicture} ... \end{tikzpicture}
    \caption{Caption goes here.}
    \end{center}
\end{figure}

pdf example

share|improve this question
1  
possible duplicate of Caption fontsize and margin on individual figures? –  lockstep Sep 20 '11 at 17:45

3 Answers 3

up vote 13 down vote accepted

The caption package provides many enhancements: for example

\usepackage[margin=1cm]{caption}

Reducing the caption to the figure width seems not a good idea in general, particularly if a couple of figures are on the same page or on facing pages. On the other hand reducing the width and maybe the font size can be a good typographical device to isolate them better from the context.

share|improve this answer
3  
The OP seems to want to adapt caption widths to the widths of individual figures, not to reduce the caption width by a fixed amount. –  lockstep Sep 20 '11 at 17:49
    
Yes, you're right. I'll edit the answer. –  egreg Sep 20 '11 at 17:51
2  
@egreg: You convinced me that decreasing the caption width with a constant amount would be better. Thanks! –  Tim N Sep 20 '11 at 18:00

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.

\documentclass{article}
\usepackage{floatrow}
\begin{document}

\begin{figure}
\ffigbox[\FBwidth]
{\caption{caption text caption text caption text caption text 
caption text caption text caption text caption text 
caption text caption text caption text caption text }\label{...}}
{\rule{50mm}{20mm}}
\end{figure}

\end{document}
share|improve this answer
    
Hadi Safi aghdam - that works, but it doesn't respect 'width' options of includegraphics. That is, the caption is much wider than the figure with something like this: \begin{figure} \ffigbox[\FBwidth] {\caption{caption text caption text caption text caption text caption text caption text caption text caption text }\label{...}} {\includegraphics[width=.4\linewidth]{dummy}} \end{figure} –  David Doria Feb 3 at 17:09

I also encountered the problem. Sometimes I use therefore two minipages to put two figures beside each other, so not much vertical space is lost.

\documentclass{article}
\usepackage{caption}
\begin{document}
 \begin{figure}
   \begin{minipage}[b]{0.6\textwidth}
     \centering
     \rule{0.4\textwidth}{3cm}
     \captionof{figure}{%
       Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
       Ut purus elit, vestibulum ut, placerat ac, adipiscing vitae, felis.
       Curabitur dictum gravida mauris. Nam arcu libero, nonummy eget, consectetuer id, vulputate a, magna.
     }
     \label{fig:a}
   \end{minipage}\hfill
   \begin{minipage}[b]{0.3\textwidth}
     \centering
     \rule{0.8\textwidth}{3cm}
     \captionof{figure}{%
       Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
       Ut purus elit, vestibulum ut, placerat ac, adipiscing vitae, felis.
     }
     \label{fig:b}
   \end{minipage}
 \end{figure}
\end{document}

enter image description here

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.