6

A footnote on page 12 of the subfig documentation says in part:

Note that the ‘width’ may be larger than the width of the sub-float body, or equivalently, the ‘width’ may be negative to provide more room for a caption if the sub-float body is small. The box holding the caption is centered relative to the sub-float body.

I must not be understanding something.

First, by looking at Figure 91 on page 35, don't they mean to say that you can set the margin to a negative value in order to get a caption that is wider than (and centered relative to) the sub-float body?

Even if this is right, I can't get a simple example to work. See my MWE below.

What am I doing wrong?

MWE:

\documentclass{article} \usepackage{caption} \usepackage{subfig} \begin{document} \begin{figure}[ht] \centering \subfloat[very long subfloat caption]{ \framebox[3cm][c]{ subfloat body } } \end{figure} \begin{figure}[ht] \centering \captionsetup[subfloat]{width=-2cm} \subfloat[very very long subfloat caption]{ \framebox[3cm][c]{ subfloat body } } \end{figure} \begin{figure}[ht] \centering \captionsetup[subfloat]{margin=-2cm} \subfloat[very very long subfloat caption]{ \framebox[3cm][c]{ subfloat body } } \end{figure} \end{document} 

enter image description here

1
  • Better using subcaption, anyway. Commented Apr 17, 2015 at 23:22

1 Answer 1

3

You can fool subfig letting it think that the subfloat is, e.g., \textwidth wide, by inserting the subfloat body in a box of that width.

Example:

\documentclass{article} \usepackage{subfig} \begin{document} \begin{figure}[ht] \centering \subfloat[very very very very very long subfloat caption]{% \makebox[\textwidth]{\framebox[3cm][c]{subfloat body}}% } \end{figure} \end{document} 

Output:

enter image description here

3
  • Yes, thanks. That has been my workaround for a few years now. I am specifically wondering about the question I asked. Commented Apr 18, 2015 at 11:53
  • @TysonWilliams I don't think it can be done any better... Commented Apr 18, 2015 at 11:58
  • Yes, I agree that the output of your workaround looks perfect. That is why I also have been using that workaround for years now. I really am just trying to understand this footnote in the subfig documentation. Commented Apr 18, 2015 at 12:01

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.