# Uneven horizontal spacing for 3 subfigures

I am tryining to show 2 rows of subfigures where each row contains 3 subfigures. However, the horizontal spacing between the subfigures is unequal and also it seems to be different between the two rows? How can I get centered and equally spaced subfigures in the figure with little spacing between the subfigures?

My code:

\begin{figure}[ht]
\centering
\begin{subfigure}[b]{0.32\textwidth}
\centering
\includegraphics[width=\textwidth]{testImage}
\label{fig7:a}
\vspace{1ex}
\end{subfigure}%%
\hfill
\begin{subfigure}[b]{0.32\textwidth}
\centering
\includegraphics[width=\textwidth]{testImage}
\label{fig7:b}
\vspace{1ex}
\end{subfigure}
\hfill
\begin{subfigure}[b]{0.32\textwidth}
\centering
\includegraphics[width=\textwidth]{testImage}
\label{fig7:c}
\vspace{1ex}
\end{subfigure}
\begin{subfigure}[b]{0.32\textwidth}
\centering
\includegraphics[width=\textwidth]{testImage}
\label{fig7:d}
\end{subfigure}%%
\hfill
\begin{subfigure}[b]{0.32\textwidth}
\centering
\includegraphics[width=\textwidth]{testImage}
\label{fig7:e}
\end{subfigure}
\hfill
\begin{subfigure}[b]{0.32\textwidth}
\centering
\includegraphics[width=\textwidth]{testImage}
\label{fig7:f}
\end{subfigure}
\label{fig7}
\end{figure}


The result image:

• you have just \hfill in the narrow spaces and wide spaces have one inter-word space and \hfill, as in some cases you have a space from the line end after \end{subfigure} and in others you have commented that space out – David Carlisle Oct 9 '18 at 11:06
• Thank you that is correct and solved my problem! – Marcel_marcel1991 Oct 9 '18 at 12:04

like this:

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

\begin{document}
\begin{figure}[ht]
\begin{subfigure}[b]{0.32\textwidth}
\includegraphics[width=\textwidth]{testImage}
\label{fig7:a}
\end{subfigure}%
\hfill
\begin{subfigure}[b]{0.32\textwidth}
\includegraphics[width=\textwidth]{testImage}
\label{fig7:b}
\end{subfigure}%
\hfill
\begin{subfigure}[b]{0.32\textwidth}
\includegraphics[width=\textwidth]{testImage}
\label{fig7:c}
\end{subfigure}%

\vspace{-0.5\baselineskip}
\begin{subfigure}[b]{0.32\textwidth}
\includegraphics[width=\textwidth]{testImage}
\label{fig7:d}
\end{subfigure}%
\hfill
\begin{subfigure}[b]{0.32\textwidth}
\includegraphics[width=\textwidth]{testImage}
\label{fig7:e}
\end{subfigure}%
\hfill
\begin{subfigure}[b]{0.32\textwidth}
\includegraphics[width=\textwidth]{testImage}
\label{fig7:f}
\end{subfigure}%
\caption{my figures}
\label{fig7}
\end{figure}
\end{document}


i only remove all necessary \centering and \vspace{1ex} inside environments subfigure, changes presence of % after subfigure environment (now is one after each subfigure) and insert empty line after third image (and with it start new line).

• Hm this still does give no equally spaced images for me. Does this also work for you if the images do not have a square format? – Marcel_marcel1991 Oct 9 '18 at 10:46
• it works for any format of images. demo images are not square, but rectangle (their widths are is little bit larger than their heights). i edit my answer now, changed are only vertical space between images rows. – Zarko Oct 9 '18 at 11:04
• Okay I did overlook that you changed the comment symbol (%) after every subfigure. Now it works for me! Maybe you change your answer that you also changed the % symbols in comparison to my code. – Marcel_marcel1991 Oct 9 '18 at 12:03
• @Marcel_marcel1991, done! – Zarko Oct 9 '18 at 13:38