2

I have created a 2x2 subfigure with the following code:

\begin{figure}
\centering
\begin{subfigure}{0.49\textwidth} % width of upper left subfigure
    \centering
    \includegraphics[width=.5\linewidth]{Test2/22_macro.png}
    \caption{Sample 2.1 - \SI{20}{ppm}} % subcaption
\end{subfigure}%
\hfil
\begin{subfigure}{0.49\textwidth} % width of upper right subfigure
    \centering
    \includegraphics[width=.5\linewidth]{Test2/23_macro.png}
    \caption{Sample 2.3 - \SI{50}{ppm}} % subcaption
\end{subfigure}%
\vfill
\begin{subfigure}{0.49\textwidth} % width of lower left subfigure
    \centering
    \includegraphics[width=.5\linewidth]{Test2/26_macro.png}
    \caption{Sample 2.6 - \SI{100}{ppm}} % subcaption
\end{subfigure}%
\hfil
\begin{subfigure}{0.49\textwidth} % width of lower right subfigure
    \centering
    \includegraphics[width=.5\linewidth]{Test2/27_macro.png}
    \caption{Samples 2.7 - \SI{150}{ppm}} % subcaption
\end{subfigure}%
\caption{} % caption for whole figure
\label{}
\end{figure}

enter image description here

But as you can see from the image there is a lot of white space between fig a and b, and fig c and d.

How can I control the horizontal distance between subfigs more effectively?

thanks in advance.

  • Welcome to TeX.SX! Please don't post code fragments. Instead, put your fragments into a complete compilable document that shows the problem. – BambOo Oct 26 '18 at 13:51
  • 1
    Your parametrization leads to 4 subfigures whose width is about half the \textwidth. Then you fill them with images whose width is half the one of the subfigure, hence the blank space. – BambOo Oct 26 '18 at 13:56
2

from your question, subfigure width roughly equals half of \textwidth and image width equals half of subfigure width. So, you can put all four sub-images in one row (first figure), or maybe in two rows (second figure).

Latex code for both cases:

%%%%%%%% first image
\begin{figure}
\begin{subfigure}[b]{0.24\textwidth} % width of upper left subfigure
    \includegraphics[width=\linewidth]{Test2/22_macro.png}
    \caption{Sample 2.1 - \SI{20}{ppm}} % subcaption
\end{subfigure}%
\hfill
\begin{subfigure}[b]{0.24\textwidth} % width of upper right subfigure
    \centering
    \includegraphics[width=\linewidth]{Test2/23_macro.png}
    \caption{Sample 2.3 - \SI{50}{ppm}} % subcaption
\end{subfigure}%
\hfill
\begin{subfigure}[b]{0.24\textwidth} % width of lower left subfigure
    \includegraphics[width=\linewidth]{Test2/26_macro.png}
    \caption{Sample 2.6 - \SI{100}{ppm}} % subcaption
\end{subfigure}%
\hfill
\begin{subfigure}[b]{0.24\textwidth} % width of lower right subfigure
    \includegraphics[width=\linewidth]{Test2/27_macro.png}
    \caption{Samples 2.7 - \SI{150}{ppm}} % subcaption
\end{subfigure}%
    \caption{common caption} % caption for whole figure
\label{fig:foursubfig}
\end{figure}

%%%%%%%% second image
\begin{figure}
\begin{subfigure}[b]{0.49\textwidth} % width of upper left subfigure
    \includegraphics[width=\linewidth]{Test2/22_macro.png}
    \caption{Sample 2.1 - \SI{20}{ppm}} % subcaption
\end{subfigure}%
\hfill
\begin{subfigure}[b]{0.49\textwidth} % width of upper right subfigure
    \centering
    \includegraphics[width=\linewidth]{Test2/23_macro.png}
    \caption{Sample 2.3 - \SI{50}{ppm}} % subcaption
\end{subfigure}

\begin{subfigure}[b]{0.49\textwidth} % width of lower left subfigure
    \includegraphics[width=\linewidth]{Test2/26_macro.png}
    \caption{Sample 2.6 - \SI{100}{ppm}} % subcaption
\end{subfigure}%
\hfill
\begin{subfigure}[b]{0.49\textwidth} % width of lower right subfigure
    \includegraphics[width=\linewidth]{Test2/27_macro.png}
    \caption{Samples 2.7 - \SI{150}{ppm}} % subcaption
\end{subfigure}%
    \caption{common caption} % caption for whole figure
\label{fig:foursubfig}
\end{figure}

%%%%%%%% third image
\begin{figure}
\centering
\begin{subfigure}[b]{0.25\textwidth} % width of upper left subfigure
    \includegraphics[width=\linewidth]{Test2/22_macro.png}
    \caption{Sample 2.1 - \SI{20}{ppm}} % subcaption
\end{subfigure}%
\quad
\begin{subfigure}[b]{0.25\textwidth} % width of upper right subfigure
    \centering
    \includegraphics[width=\linewidth]{Test2/23_macro.png}
    \caption{Sample 2.3 - \SI{50}{ppm}} % subcaption
\end{subfigure}

\begin{subfigure}[b]{0.25\textwidth} % width of lower left subfigure
    \includegraphics[width=\linewidth]{Test2/26_macro.png}
    \caption{Sample 2.6 - \SI{100}{ppm}} % subcaption
\end{subfigure}%
\quad
\begin{subfigure}[b]{0.25\textwidth} % width of lower right subfigure
    \includegraphics[width=\linewidth]{Test2/27_macro.png}
    \caption{Samples 2.7 - \SI{150}{ppm}} % subcaption
\end{subfigure}%
    \caption{common caption} % caption for whole figure
\label{fig:foursubfig}
\end{figure}

enter image description here

Edit: You can also have small images in two rows (third figure).

enter image description here

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.