1

I want to create two colums of figures according to the following MWE. My solution is inspired by:

How can I vertically align two minipages with subfigures and differing caption length?

I have to use "subfigure" instead of subfloat because of incompatibilities from any other approaches with various packages I need for my non-MWE document.

As you can see from the MWE-Output, the left column's figures are somewhat misaligned - is there any remedy to this??? I am missing the text "Testing a long text string" in the left colum - the left column figures seem to be placed too far to the right. This is what happens in my original document, too.

In my original problem, things look like this:

enter image description here

Clearly, the column(s) is/are somewhat misaligned...

Basically I copied the above cited solution - why do I nest all the stuff in a figure environment? I know that if I don't put all this in a figure-environment, the minipage/subfigure approach won't work out...

\documentclass[]{article} 


\usepackage{graphicx}                       % Grafikpaket (ermöglicht     unter anderem das Einbinden von .jpg-Bildern)
\usepackage{subcaption}
\usepackage{psfrag}
\usepackage{lscape}
\usepackage{color}                       % Color Paket wird benötigt, damit matlab2tikz-Farben richtig übersetzt werden

%pgfplots etc
\usepackage{todonotes}

\begin{document}

\begin{figure}
\begin{minipage}[t]{.48\textwidth}
\centering
\begin{subfigure}[b]{0.48\linewidth}
\missingfigure[figwidth=\textwidth]{Testing a long text string}
    \caption{efe}
\end{subfigure}\\
\begin{subfigure}[b]{0.48\linewidth}
\missingfigure[figwidth=\textwidth]{Testing a long text string}
    \caption{efe}
\end{subfigure}\\
\begin{subfigure}[b]{0.48\linewidth}
\missingfigure[figwidth=\textwidth]{Testing a long text string}
    \caption{efe}
\end{subfigure}

\caption{First figure with two subfigures with very very very very long caption}
\label{fig:testa}
\end{minipage}\hfill     \begin{minipage}[t]{0.48\textwidth}
\begin{subfigure}[b]{0.48\linewidth}
\missingfigure[figwidth=\textwidth]{Testing a long text string}
        \caption{efe}
\end{subfigure}\\
\begin{subfigure}[b]{0.48\linewidth}
\missingfigure[figwidth=\textwidth]{Testing a long text string}
    \caption{efe}
\end{subfigure}\\
\begin{subfigure}[b]{0.48\linewidth}
 \missingfigure[figwidth=\textwidth]{Testing a long text string}
        \caption{efe}
\end{subfigure}
 \caption{Second figure with two subfigures}
\label{fig:testb}
    \end{minipage}
     \end{figure}


\end{document}
  • Could you post a compilable code? The \missingfigure command is undefined. – Bernard Jun 3 '16 at 14:54
  • Hi Bernard, this is strange... \missingfigure should be available in todonotes according to: tex.stackexchange.com/questions/44195/… I can definitely compile the above example w/o any problems... – user62795 Jun 3 '16 at 14:56
  • I use pdflatex, if this is of relevance...?!? – user62795 Jun 3 '16 at 15:27
1

Link which you provide, show the way how to managede your images. Using example-image from package graphics and change subfigure and included image width that consider width of minipage you can obtain:

enter image description here

MWE for above image:

\documentclass[]{article}
\usepackage{graphicx}
\usepackage{subcaption}

\begin{document}
    \begin{figure}
\begin{minipage}[t]{.48\textwidth}
\centering
\begin{subfigure}[b]{\linewidth}
\includegraphics[width=0.9\hsize]{example-image}
    \caption{efe}
\end{subfigure}\\
\begin{subfigure}[b]{\linewidth}
\includegraphics[width=0.9\hsize]{example-image}
    \caption{efe}
\end{subfigure}\\
\begin{subfigure}[b]{\linewidth}
\includegraphics[width=0.9\hsize]{example-image}
    \caption{efe}
\end{subfigure}

\caption{First figure with two subfigures with very very very very long caption}
\label{fig:testa}
\end{minipage}
    \hfill     
\begin{minipage}[t]{0.48\textwidth}
\begin{subfigure}[b]{\linewidth}
\includegraphics[width=0.9\hsize]{example-image}
        \caption{efe}
\end{subfigure}\\
\begin{subfigure}[b]{\linewidth}
\includegraphics[width=0.9\hsize]{example-image}
    \caption{efe}
\end{subfigure}\\
\begin{subfigure}[b]{\linewidth}
 \includegraphics[width=0.9\hsize]{example-image}
        \caption{efe}
\end{subfigure}
 \caption{Second figure with two subfigures}
\label{fig:testb}
\end{minipage}
    \end{figure}
\end{document}
  • Zarko, you are my personal hero, thank you! When I compile your example, everything works fine - if I integrate it into my document, however, the two columns of figures will placed below each other and not side by side... Do you have any idea what this could come from? Thank you!!! – user62795 Jun 3 '16 at 15:46
  • Hm, this is unusual. Do you maybe have two column document? If this is a case, than try in mini-pages replace \textwidth with \columnwidth. Or show preamble your real document, that we/I can see/test the suggested solution. The problem can also be size of real images. – Zarko Jun 3 '16 at 15:55
  • I found the solution: I had a white space in there somewhere because of reformatting the code I copied from you: this tex.stackexchange.com/questions/114520/… helped me :-) Thank you. How long have you been using Latex? It seems you're a real pro! – user62795 Jun 3 '16 at 15:57
  • about 25 year : -) – Zarko Jun 3 '16 at 15:59
0

In your code, once you've entered a minipage, the widths become \linewidth, not 0.48\linewidth:

\documentclass[]{article}

\usepackage[showframe]{geometry} \usepackage{graphicx} % Grafikpaket (ermöglicht unter anderem das Einbinden von .jpg-Bildern)
\usepackage{subcaption}
\usepackage{psfrag}
\usepackage{lscape}
\usepackage{color} % Color Paket wird benötigt, damit matlab2tikz-Farben richtig übersetzt werden

%pgfplots etc
\usepackage{todonotes}

\begin{document}

\begin{figure}
\begin{minipage}[t]{.48\textwidth}
\begin{subfigure}[b]{\linewidth}
\centering
\missingfigure[figwidth=\linewidth]{Testing a long text string}
    \caption{efe}
\end{subfigure}\\
\begin{subfigure}[b]{\linewidth}
\centering
\missingfigure[figwidth=\linewidth]{Testing a long text string}
    \caption{efe}
\end{subfigure}\\
\begin{subfigure}[b]{\linewidth}
\centering
\missingfigure[figwidth=\linewidth]{Testing a long text string}
    \caption{efe}
\end{subfigure}

\caption{First figure with two subfigures with very very very very long caption}
\label{fig:testa}
\end{minipage}\hfill \begin{minipage}[t]{0.48\linewidth}
\begin{subfigure}[b]{\linewidth}
\centering
\missingfigure[figwidth=\linewidth]{Testing a long text string}
        \caption{efe}
\end{subfigure}\\
\begin{subfigure}[b]{\linewidth}
\centering
\missingfigure[figwidth=\linewidth]{Testing a long text string}
    \caption{efe}
\end{subfigure}\\
\begin{subfigure}[b]{\linewidth}
\centering
 \missingfigure[figwidth=\linewidth]{Testing a long text string}
        \caption{efe}
\end{subfigure}
 \caption{Second figure with two subfigures}
\label{fig:testb}
    \end{minipage}
     \end{figure}

\end{document} 

enter image description here

  • Thank you, Bernard, this works well, too! I just became aware that this approach to figure placing does not feature any page breaks. Do you know of any approach how to achieve a page break after row (a) or (b), for example? This would add some visual value in some cases... – user62795 Jun 15 '16 at 6:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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