1

I'm trying to put together a couple subplots using minipage and subfloat and I keep getting the following misalignment issue: enter image description here

There's clearly enough space in the minipage and I reduced the size of the last two images/increased the size of the minipages just to be sure and no dice. It doesn't happen when I only put six images (three per minipage); could there be some sort of issue with having four per minipage?

This is my code for the plot:

\begin{figure}
\centering
\begin{minipage}[c][17cm][t]{.5\textwidth}
\centering
\subfloat[$t_{1}=3$,$t_{2}=0.5$ initial conditions.]{%
  \includegraphics[clip,width=0.9\linewidth]{mode2range3-2_1.png}%
  \label{fig:mode2range3-05_1}
}

\subfloat[$t_{1}=2$,$t_{2}=0.5$ initial conditions.]{%
  \includegraphics[clip,width=0.9\linewidth]{mode2range2-1_1.png}%
  \label{fig:mode2range2-05_1}
}

\subfloat[$t_{1}=4$,$t_{2}=1$ m initial conditions.]{%
  \includegraphics[clip,width=0.9\linewidth]{mode2range4-2_1.png}%
  \label{fig:mode2range4-1_1}
}
\subfloat[$t_{1}=4$,$t_{2}=1.5$ m initial conditions.]{%
  \includegraphics[clip,width=0.9\linewidth]{mode2range4-15_1.png}%
  \label{fig:mode2range4-15_1}
}
\end{minipage}%
\begin{minipage}[c][17cm][t]{.5\textwidth}
\centering
\subfloat[$t_{1}=3$,$t_{2}=0.5$ ISWs.]{%
  \includegraphics[clip,width=0.9\linewidth]{mode2range3-2_2.png}%
  \label{fig:mode2range3-05_2}
}

\subfloat[$t_{1}=2$,$t_{2}=0.5$ ISWs.]{%
  \includegraphics[clip,width=0.9\linewidth]{mode2range2-1_2.png}%
  \label{fig:mode2range2-05_2}
}

\subfloat[$t_{1}=4$,$t_{2}=1$ ISWs.]{%
  \includegraphics[clip,width=0.9\linewidth]{mode2range4-2_2.png}%
  \label{fig:mode2range4-1_2}
}
\subfloat[$t_{1}=4$,$t_{2}=1.5$ ISWs.]{%
  \includegraphics[clip,width=0.9\linewidth]{mode2range4-15_2.png}%
  \label{fig:mode2range4-15_2}
}
\end{minipage}
\caption{The density profile of the initial conditions (left) and the point where the ISWs reach the right boundary (right) for the cases in which the coefficients for the two thicknesses of the pycnocline have been varied to $t_{1}=3$,$t_{2}=0.5$, $t_{1}=2$,$t_{2}=0.5$, $t_{1}=4$,$t_{2}=1$, and $t_{1}=4$,$t_{2}=1.5$.}
\end{figure}

and the packages I'm using:

\documentclass[titlepage, 11pt]{article}
\usepackage[utf8]{inputenc}
\usepackage{graphicx}
\usepackage{caption}
\usepackage{subcaption}
\usepackage[margin=1in]{geometry}
\usepackage[style=apa]{biblatex}
\usepackage{amsmath}
\usepackage[dvipsnames]{xcolor}

What could the issue be? Thanks in advance!

2
  • you have no paragraph break before the last subfloat in each minipage Jan 11, 2021 at 23:53
  • @DavidCarlisle Ahh, thank you! Should have known it was something that dumb.
    – Petra
    Jan 12, 2021 at 0:48

2 Answers 2

1

There is no need to use minipages and it's also not clear why setting them to some height.

Use \subcaptionbox (or the subfigure environment).

\documentclass[titlepage, 11pt]{article}
\usepackage[utf8]{inputenc}
\usepackage{graphicx}
\usepackage{caption}
\usepackage{subcaption}
\usepackage[margin=1in]{geometry}
\usepackage[style=apa]{biblatex}
\usepackage{amsmath}
\usepackage[dvipsnames]{xcolor}

\begin{document}

\begin{figure}
\centering\setlength{\parskip}{2ex}

\subcaptionbox
  {$t_{1}=3$, $t_{2}=0.5$ initial conditions.\label{fig:mode2range3-05_1}}
  {\includegraphics[height=3cm,width=0.45\textwidth]{example-image}}
\subcaptionbox
  {$t_{1}=2$, $t_{2}=0.5$ initial conditions.\label{fig:mode2range2-05_1}}
  {\includegraphics[height=3cm,width=0.45\textwidth]{example-image}}

\subcaptionbox
  {$t_{1}=4$, $t_{2}=1$ m initial conditions.\label{fig:mode2range4-1_1}}
  {\includegraphics[height=3cm,width=0.45\textwidth]{example-image}}
\subcaptionbox
  {$t_{1}=4$, $t_{2}=1.5$ m initial conditions.\label{fig:mode2range4-15_1}}
  {\includegraphics[height=3cm,width=0.45\textwidth]{example-image}}

\subcaptionbox
  {$t_{1}=3$, $t_{2}=0.5$ ISWs.\label{fig:mode2range3-05_2}}
  {\includegraphics[height=3cm,width=0.45\textwidth]{example-image}}
\subcaptionbox
  {$t_{1}=2$, $t_{2}=0.5$ ISWs.\label{fig:mode2range2-05_2}}
  {\includegraphics[height=3cm,width=0.45\textwidth]{example-image}}

\subcaptionbox
  {$t_{1}=4$, $t_{2}=1$ ISWs.\label{fig:mode2range4-1_2}}
  {\includegraphics[height=3cm,width=0.45\textwidth]{example-image}}
\subcaptionbox
  {$t_{1}=4$, $t_{2}=1.5$ ISWs.\label{fig:mode2range4-15_2}}
  {\includegraphics[height=3cm,width=0.45\textwidth]{example-image}}

\caption{The density profile of the initial conditions (left) and the point 
  where the ISWs reach the right boundary (right) for the cases in which the 
  coefficients for the two thicknesses of the pycnocline have been varied to 
  $t_{1}=3$, $t_{2}=0.5$, $t_{1}=2$, $t_{2}=0.5$, $t_{1}=4$, $t_{2}=1$,
  and $t_{1}=4$, $t_{2}=1.5$.}
\end{figure}

\end{document}

Some points to note:

  1. I changed the file names in order to produce a picture; reinstate the correct file names and also remove the height=3cm option that I used just to emulate your picture;

  2. the clip option is redundant unless you specify viewport;

  3. there should always be a space after a comma;

  4. I added a (local) setting of \parskip in order to separate rows of images;

  5. the [htp] option is necessary for such a big float.

enter image description here

1

Some off-topics suggestions (main problem is already solved by @David Carlisle comment):

  • Move by use of subcaption options belowskip and skip subcation closer to image and away from image below.
  • Make minipages narrower and image width equal to minipages width.
  • Because all images have equal setting, it is sensible to use leays Gin for them. By this code is much shorter.
  • Pairs $t_1=...$,$t_2=...$, is better to write as $t_1...,t_2=...$, . Beside that code is wee bit shorter and the result is (to my opinion) nicer:
\documentclass[titlepage, 11pt]{article}
\usepackage[margin=1in]{geometry}

\usepackage[demo]{graphicx}
\usepackage{caption}
\usepackage[skip=0.5ex,
            belowskip=1ex]{subcaption}

\begin{document}
    \begin{figure}
    \setkeys{Gin}{clip,width=\linewidth}
\centering
\begin{minipage}{.48\textwidth}
\centering
\subfloat[$t_{1}=3,t_{2}=0.5$ initial conditions.]{%
  \includegraphics{mode2range3-2_1.png}%
  \label{fig:mode2range3-05_1}
}

\subfloat[$t_{1}=2,t_{2}=0.5$ initial conditions.]{%
  \includegraphics{mode2range2-1_1.png}%
  \label{fig:mode2range2-05_1}
}

\subfloat[$t_{1}=4,t_{2}=1$ m initial conditions.]{%
  \includegraphics{mode2range4-2_1.png}%
  \label{fig:mode2range4-1_1}
}

\subfloat[$t_{1}=4,t_{2}=1.5$ m initial conditions.]{%
  \includegraphics{mode2range4-15_1.png}%
  \label{fig:mode2range4-15_1}
}
\end{minipage}%
\hfill
\begin{minipage}{.48\textwidth}
\centering
\subfloat[$t_{1}=3,t_{2}=0.5$ ISWs.]{%
  \includegraphics{mode2range3-2_2.png}%
  \label{fig:mode2range3-05_2}
}

\subfloat[$t_{1}=2,t_{2}=0.5$ ISWs.]{%
  \includegraphics{mode2range2-1_2.png}%
  \label{fig:mode2range2-05_2}
}

\subfloat[$t_{1}=4,t_{2}=1$ ISWs.]{%
  \includegraphics{mode2range4-2_2.png}%
  \label{fig:mode2range4-1_2}
}

\subfloat[$t_{1}=4,t_{2}=1.5$ ISWs.]{%
  \includegraphics{mode2range4-15_2.png}%
  \label{fig:mode2range4-15_2}
}
\end{minipage}
\caption{The density profile of the initial conditions (left) and the point where the ISWs reach the right boundary (right) for the cases in which the coefficients for the two thicknesses of the pycnocline have been varied to $t_{1}=3, t_{2}=0.5$, $t_{1}=2, t_{2}=0.5$, $t_{1}=4, t_{2}=1$, and $t_{1}=4, t_{2}=1.5$.}
    \end{figure}
\end{document}

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .