[Tex/LaTex] Subfigure with caption on the side

captionsfloatssubfloats

I am trying to arange four images in a 2 by 2 grid. The caption of the entire figure (not the subfigure) should appear on the right side and not on the bottom. I tried using the caption and subcaption package and minipages and came up with this code:

\begin{figure*}[t!]
    \centering 

    \begin{minipage}[l]{0.7\textwidth}
        \begin{subfigure}{.33\linewidth}
            \centering
            \fakeimage
            \caption{Colum 1}\label{fig:image1}
        \end{subfigure}
        \begin{subfigure}{.33\linewidth}
            \centering
            \fakeimage
            \caption{Colum 2}\label{fig:image2}
        \end{subfigure}

        \bigskip
        \begin{subfigure}{.33\linewidth}
            \centering
            \fakeimage
        \end{subfigure}
        \begin{subfigure}{.33\linewidth}
            \centering
            \fakeimage
        \end{subfigure}
    \end{minipage}

    \begin{minipage}[r]{.10\textwidth}
        \centering
         \caption{This is the caption for all four images.}
     \end{minipage}
\end{figure*}

Sadly, the caption does not appear right to the images but under the bottom right image. How can I fix this?

Best Answer

The main cause of your problem is the empty line between the first ...\end{minipage} and the second \begin{minipage}.... You should remove it.

However, there are problems with your code:

  1. For minipage, there are no options l or r. There are only t (top aligned), c (vertically center aligned) and b (bottom aligned).
  2. Why are you creating a 70% column for your four figures while only 10% for you caption on the right?
  3. Meanwhile, within your 70% column, each figure only takes up 33% of the width. Why?

I propose the following solution. Note the use of the comment character %.

\documentclass[a4paper]{article}

\usepackage{graphicx}
\newcommand*\fakeimage{\includegraphics[width=\linewidth]{example-image}}
\usepackage{caption}
\usepackage{subcaption}

\begin{document}

\begin{figure*}
    \centering
    \begin{minipage}[t]{0.7\linewidth}
        \begin{subfigure}{0.48\linewidth}
            \centering
            \fakeimage
            \caption{Colum 1}\label{fig:image1}
        \end{subfigure}% <- don't forget this %
        \hfill
        \begin{subfigure}{0.48\linewidth}
            \centering
            \fakeimage
            \caption{Colum 2}\label{fig:image2}
        \end{subfigure}

        \begin{subfigure}{0.48\linewidth}
            \centering
            \fakeimage
            \caption{Colum 1}\label{fig:image3}
        \end{subfigure}% <- don't forget this %
        \hfill
        \begin{subfigure}{0.48\linewidth}
            \centering
            \fakeimage
            \caption{Colum 2}\label{fig:image4}
        \end{subfigure}
    \end{minipage}% <- don't forget this %
    \hfill
    \begin{minipage}[b]{0.27\linewidth}
        \caption{This is the caption for all four images.}
    \end{minipage}
\end{figure*}

\end{document}

caption to the right

The above should not be consider as a good practice. To me, it seems like you are looking for a format that places figure caption in the “margin note” position.