Latex figures; when ploting four part figure, one (b) floats higher then the other and I can't find any reason why

Viewed 1647

enter image description here

I'm writing an article in latex and for some reason, one of my figures is mysteriously floating around. I was trying to make one figure of four (a,b,c,d), and the b figure is just floating above where it should be. I have checked the figure size and any extra signs after defining the figure, but can't seem to find an issue.

Does anyone see what is the issue?

\documentclass[11pt]{article}
\usepackage[left=25mm, right=25mm, top=25mm, bottom=25mm, includehead=true, includefoot=true]{geometry}

\usepackage{graphicx}
\usepackage{subcaption}
\usepackage[table,xcdraw]{xcolor}
\usepackage{hyperref}
\usepackage{mathtools}
%\usepackage[caption=false]{subfig}
\usepackage{amsmath}
\usepackage{multirow}
\graphicspath{ {./images/} }
\usepackage{url}
\usepackage{caption}
\usepackage[round]{natbib} % For referencing
\usepackage{authblk} % For author lists
\usepackage[parfill]{parskip} % Line between paragraphs
\usepackage[normalem]{ulem}
\usepackage{multicol}
\pagenumbering{gobble} % Turn off page numbers



% Make all headings the same size (11pt):
\usepackage{sectsty}
\sectionfont{\normalsize}
\subsectionfont{\normalsize}
\subsubsectionfont{\normalsize}
\paragraphfont{\normalsize}

\begin{document}

    
\begin{figure}
\centering
\begin{subfigure}[a]{0.45\linewidth}
\includegraphics[width=\linewidth]{6_5_model_building_90_0} 
\caption{}
\label{fig:3a}
\end{subfigure}\hfill    
\begin{subfigure}[b]{0.45\linewidth}
\includegraphics[width=\linewidth]{6_5_model_building_87_0}
\caption{}
\label{fig:3b}
\end{subfigure}
%add desired spacing between images, e. g. ~, \quad, \qquad, \hfill etc. 
%(or a blank line to force the subfigure onto a new line)
\begin{subfigure}[c]{0.5\linewidth}
\includegraphics[width=\linewidth]{14_5_fisrt_paper_figures_46_1}
\caption{}
\label{fig:3c}
\end{subfigure}\hfill    
\begin{subfigure}[d]{0.5\linewidth}
\includegraphics[width=\linewidth]{14_5_fisrt_paper_figures_45_0}
\caption{}
\label{fig:3d}
\end{subfigure}
    
\caption{My caption}
\label{fig:3}
\end{figure}
\vfill
\clearpage
\newpage

\bibliographystyle{plainnat}
\bibliography{MyLibrary}
\end{multicols}
\end{document}
1 Answers

The first optional argument of the subfigure environment is for the outer position. By chance b and c are actually allowed values, the others will default to c. Your second image is mis-aligned, because you instruct it to be bottom aligned.

Some other comments:

  • mathtools already loads amsmath

  • load hyperref after the other packages

  • no need for url if you also load hyperref

  • subcaption already loads caption


\documentclass{article}
\usepackage[left=25mm, right=25mm, top=25mm, bottom=25mm, includehead=true, includefoot=true]{geometry}

\usepackage{graphicx}
\usepackage{subcaption}
\usepackage[table,xcdraw]{xcolor}

\usepackage{mathtools}
%\usepackage[caption=false]{subfig}
%\usepackage{amsmath}
\usepackage{multirow}
\graphicspath{ {./images/} }
%\usepackage{url}
%\usepackage{caption}
\usepackage[round]{natbib} % For referencing
\usepackage{authblk} % For author lists
\usepackage[parfill]{parskip} % Line between paragraphs
\usepackage[normalem]{ulem}
\usepackage{multicol}
\pagenumbering{gobble} % Turn off page numbers



% Make all headings the same size (11pt):
\usepackage{sectsty}
\sectionfont{\normalsize}
\subsectionfont{\normalsize}
\subsubsectionfont{\normalsize}
\paragraphfont{\normalsize}

\usepackage{hyperref}

\begin{document}

    
\begin{figure}
\centering
\begin{subfigure}[c]{0.45\linewidth}
\includegraphics[width=\linewidth]{example-image-duck} 
\caption{}
\label{fig:3a}
\end{subfigure}\hfill    
\begin{subfigure}[c]{0.45\linewidth}
\includegraphics[width=\linewidth]{example-image-duck}
\caption{}
\label{fig:3b}
\end{subfigure}
%add desired spacing between images, e. g. ~, \quad, \qquad, \hfill etc. 
%(or a blank line to force the subfigure onto a new line)
\begin{subfigure}[c]{0.5\linewidth}
\includegraphics[width=\linewidth]{example-image-duck}
\caption{}
\label{fig:3c}
\end{subfigure}\hfill    
\begin{subfigure}[c]{0.5\linewidth}
\includegraphics[width=\linewidth]{example-image-duck}
\caption{}
\label{fig:3d}
\end{subfigure}
    
\caption{My caption}
\label{fig:3}
\end{figure}
\vfill
\clearpage
\newpage

\bibliographystyle{plainnat}
\bibliography{MyLibrary}
%\end{multicols}
\end{document}

enter image description here

Related