1

I have problem: I would like to put a side caption on a subfigure. Here is my actual code (that doesn't perform the side caption):

\begin{figure}[H]
\begin{center}
    \subfigure[\footnotesize{...}]{
        \label{...}
        \includegraphics[width=0.25\textwidth]{...}
    }
    \subfigure[\footnotesize{...}]{
        \label{...}
        \includegraphics[width=0.25\textwidth]{...}
    }\\
    \subfigure[\footnotesize{...}]{
        \label{...}
        \includegraphics[width=0.25\textwidth]{...}
    }
    \subfigure[\footnotesize{...}]{
        \label{...}
        \includegraphics[width=0.25\textwidth]{...}
    }\\
    \subfigure[\footnotesize{...}]{
        \label{...}
        \includegraphics[width=0.25\textwidth]{...}
    }
    \subfigure[\footnotesize{...}]{
        \label{...}
        \includegraphics[width=0.25\textwidth]{...}
    }\\
    \subfigure[\footnotesize{...}]{
        \label{...}
        \includegraphics[width=0.25\textwidth]{...}
    }
    \subfigure[\footnotesize{...}]{
        \label{...}
        \includegraphics[width=0.25\textwidth]{...}
    }\\
    \subfigure[\footnotesize{...}]{
        \label{...}
        \includegraphics[width=0.25\textwidth]{...}
    }
    \subfigure[\footnotesize{...}]{
        \label{...}
        \includegraphics[width=0.25\textwidth]{...}
    }\\
\end{center}
\caption{"I would like that this text is put on the side of the image"}
\label{...}
\end{figure}

Where I put "..." is text that I delete. I tried with the sidecap package and edit the environment with SCfigure instead of figure, but this gives me a lot of errors.

Vincent
  • 20,157
Simo
  • 41

2 Answers2

1

This differs from sidecap in that it computes the width available for the caption and it aligns the tops using \raisebox.

The caption \label should go inside the minipage with the caption.

\documentclass{article}
\usepackage{subfigure}
\usepackage{graphicx}
\usepackage{varwidth}

\begin{document}
\begin{figure}[htp]
\sbox0{\begin{varwidth}{\textwidth}% get width of combined subfigures
    \subfigure[\footnotesize{...}]{
        \includegraphics[width=0.25\textwidth]{example-image}
    }
    \subfigure[\footnotesize{...}]{
        \includegraphics[width=0.25\textwidth]{example-image}
    }\\
    \subfigure[\footnotesize{...}]{
        \includegraphics[width=0.25\textwidth]{example-image}
    }
    \subfigure[\footnotesize{...}]{
        \includegraphics[width=0.25\textwidth]{example-image}
    }\\
    \subfigure[\footnotesize{...}]{
        \includegraphics[width=0.25\textwidth]{example-image}
    }
    \subfigure[\footnotesize{...}]{
        \includegraphics[width=0.25\textwidth]{example-image}
    }\\
    \subfigure[\footnotesize{...}]{
        \includegraphics[width=0.25\textwidth]{example-image}
    }
    \subfigure[\footnotesize{...}]{
        \includegraphics[width=0.25\textwidth]{example-image}
    }\\
    \subfigure[\footnotesize{...}]{
        \includegraphics[width=0.25\textwidth]{example-image}
    }
    \subfigure[\footnotesize{...}]{
        \includegraphics[width=0.25\textwidth]{example-image}
    }\\
\end{varwidth}}%
\raisebox{-\height}{\usebox0}% left
\hspace{\columnsep}% gap
\raisebox{-\height}{\begin{minipage}{\dimexpr \textwidth-\wd0-\columnsep}
\abovecaptionskip=0pt
\caption{"I would like that this text is put on the side of the image"}
\end{minipage}}
\end{figure}
\end{document}
John Kormylo
  • 79,712
  • 3
  • 50
  • 120
1

Please, be aware that subfigure is obsolete. Either use subfig (and \subfloat instead of \subfigure) or the more recent and maintained subcaption package.

I guess that you want the caption to be next to the set of images because the caption text is long. Otherwise bottom placement would be much better.

Just use a tabular to align the images and a minipage to set the caption.

\documentclass{article}
\usepackage{subfig}
\usepackage{graphicx}

\usepackage{lipsum} % for mock caption text

\begin{document}

\begin{figure}
\begin{tabular}{@{}cc@{}}
    \subfloat[subfigure]{%
        \label{a}%
        \includegraphics[width=0.25\textwidth]{example-image}%
    }&
    \subfloat[subfigure]{%
        \label{b}%
        \includegraphics[width=0.25\textwidth]{example-image}%
    }\\
    \subfloat[subfigure]{%
        \label{c}%
        \includegraphics[width=0.25\textwidth]{example-image}%
    }&
    \subfloat[subfigure]{%
        \label{d}%
        \includegraphics[width=0.25\textwidth]{example-image}%
    }\\
    \subfloat[subfigure]{%
        \label{e}%
        \includegraphics[width=0.25\textwidth]{example-image}%
    }&
    \subfloat[subfigure]{%
        \label{f}%
        \includegraphics[width=0.25\textwidth]{example-image}%
    }\\
    \subfloat[subfigure]{%
        \label{g}%
        \includegraphics[width=0.25\textwidth]{example-image}%
    }&
    \subfloat[subfigure]{%
        \label{h}%
        \includegraphics[width=0.25\textwidth]{example-image}%
    }\\
    \subfloat[subfigure]{%
        \label{i}%
        \includegraphics[width=0.25\textwidth]{example-image}%
    }&
    \subfloat[subfigure]{%
        \label{j}%
        \includegraphics[width=0.25\textwidth]{example-image}%
    }\\
\end{tabular}\hfill
\begin{minipage}{0.4\textwidth}
\caption{\lipsum[2]}
\label{x}
\end{minipage}
\end{figure}

\end{document}

Using [H] as the placement specifier is generally wrong; even more in this case where the float is quite large.

enter image description here

With a couple of tricks you can get top alignment.

  1. change \begin{tabular}{@{}cc@{}} into

    \begin{tabular}[t]{@{}cc@{}} \\[-\dp\strutbox]
    
  2. change \begin{minipage}[t]{0.4\textwidth} into

    \begin{minipage}[t]{0.4\textwidth}
    

The rest remains unchanged.

enter image description here

egreg
  • 1,121,712