[Tex/LaTex] Put two pictures above one another within one sub float / reference problem

captionsminipagesubfloats

I was going through some crazy hoops to get minipage and subfloat work nicely (?) together, only to find out in the very end that I screwed up the figure references.

I have a figure with two subfloats, one on the left one on the right. The left is composed of two graphics above one another. That last fact causes big trouble because I cannot use \\ or \newline in subfloat alone. So I build a minipage around it, but then the subfloat cannot contain the minipage, so I reversed their nesting:

\documentclass[a4paper]{book}
% note: the following packages are _givens_, I cannot change them at this point
\usepackage[top=35mm, bottom=38mm, inner=40mm, outer=24mm]{geometry}
\usepackage[hang,small]{caption}
\usepackage{subfig}
\usepackage{graphicx}

\begin{document}

As shown in Fig.~\ref{fig:right}...

\begin{figure}
\centering 
\begin{minipage}{0.39\textwidth}%
\includegraphics[width=1\textwidth, trim=0 0 0 -70mm]{figures/zelle148_IMG_1903m.jpg}\\[2mm]%
\includegraphics[width=1\textwidth, trim=0 -60mm 0 0]{figures/zelle148_IMG_1901m.jpg}%
\\\centering \subfloat[Left]{\hspace{0.9\textwidth}}\label{fig:left}
\end{minipage}%
\begin{minipage}{0.58\textwidth}%
\includegraphics[width=1\textwidth, trim=-2mm 0 0 0]{figures/Zelle148ScoreCut.pdf}%
\\\centering \subfloat[Right]{\hspace{1\textwidth}}\label{fig:right}
\end{minipage}%
\caption{Full caption}
\label{fig:both}
\end{figure}

\end{document}

The problem is, I get errors

Package caption Warning: \label before \caption on input line 20.

LaTeX Warning: Reference `fig:right' on page 1 undefined on input line 9.

LaTeX Warning: There were undefined references.

The figure result looks as I want:

enter image description here

But the reference in the text just shows up as "??" instead of "1b".

Best Answer

Does the following fulfill your purpose? It comes without any trim or anything like that. The basic idea here is to create a two column table, both columns centered. The left column is again a single column table with two rows, where you put your Left pictures one above another. The right column is again a table, with only one row, which contains your Right picture. You align the last two tables at bottom. You will want to tweak the column widths. Here I have used 0.4\textwidth, but slightly wider should also be alright.

\documentclass[a4paper]{book}
\usepackage[top=35mm, bottom=38mm, inner=40mm, outer=24mm]{geometry}
\usepackage[hang,small]{caption}
\usepackage{subfig}
\usepackage{graphicx}

\begin{document}

As shown in Fig.~\ref{fig:right}...

\begin{figure}[!tbp]
  \centering
  \begin{tabular}[c]{cc}
    \subfloat[Left]{\label{fig:left}%
      \begin{tabular}[b]{c}
        \includegraphics[width=0.4\textwidth]{figures/zelle148_IMG_1903m.jpg}\\[2mm]
        \includegraphics[width=0.4\textwidth]{figures/zelle148_IMG_1901m.jpg}
      \end{tabular}}
    &
    \begin{tabular}[b]{c}
      \subfloat[Right]{\label{fig:right}%
        \includegraphics[width=0.4\textwidth]{figures/Zelle148ScoreCut.pdf}}
    \end{tabular}
  \end{tabular}
  \caption{Full caption}
  \label{fig:both}
\end{figure}

\end{document}

Here is the output,

enter image description here