0

I have a very simple MWE which demonstrates the problem:

\documentclass{book}
\usepackage{graphicx}
\usepackage{subcaption}

\begin{document}
\begin{figure}
\centering
\begin{subfigure}[b]{0.20\linewidth}
\includegraphics[width=\linewidth]{example-image-a}
\caption{}\label{fig:1a}
\end{subfigure}%
\begin{subfigure}[b]{0.20\linewidth}
\includegraphics[width=\linewidth]{example-image-b}
\caption{}\label{fig:1b}
\end{subfigure}
\begin{subfigure}[b]{0.20\linewidth}
\includegraphics[width=\linewidth]{example-image-c}
\caption{}\label{fig:1b}
\end{subfigure}
\begin{subfigure}[b]{0.20\linewidth}
\includegraphics[width=\linewidth]{example-image-a}
\caption{}\label{fig:1b}
\end{subfigure}
\caption{A figure}\label{fig:1}
\end{figure}
\end{document}

Which outputs: Latex output

Why is there no spacing between A and B, but there is between B,C and A?

Neil
  • 415

1 Answers1

1

Beware of spaces at the end of lines between environments/commands! The hint is that you have a comment character at the end of your first subfigure. If you change all of these lines so that they look like

\end{subfigure}%

Then all is well:

enter image description here