# Spacing in 2x2 images

I'm trying to embed 4 images as a 2x2-grid in my LaTeX-Document. The insertion works so far, here's a minimum working example and it's result:

\documentclass[oneside,12pt,pointednumbers]{scrartcl}
\usepackage[ngerman]{babel} %Deutsche Sprachunterstützung
\usepackage[utf8]{inputenc} %Umlaute
\usepackage{subcaption}
\usepackage{graphicx}

\begin{document}
\begin{figure}
\begin{subfigure}{.5\textwidth}
\centering
\includegraphics[width=.8\linewidth]{res/Schnittmenge}
\caption{\textbf{Schnitt}: $A \cup B$: Element liegt in $A$ \textbf{oder} in $B$.}
\end{subfigure}
\hfill
\begin{subfigure}{.5\textwidth}
\centering
\includegraphics[width=.8\linewidth]{res/Vereinigungsmenge}
\caption{\textbf{Vereinigung}: $A \cap B$: Element liegt in $A$ \textbf{und} in $B$.}
\end{subfigure}
\hfill
\begin{subfigure}{.5\textwidth}
\centering
\includegraphics[width=.8\linewidth]{res/Differenzmenge}
\caption{\textbf{Differenz}: $A \setminus B$: Element liegt in $A$ \textbf{nicht} in $B$. (\textit{A ohne B})}
\end{subfigure}
\begin{subfigure}{.5\textwidth}
\centering

\includegraphics[width=.8\linewidth]{res/Differenzmenge-Symmetrisch}
\caption{\textbf{Symmetrische Differenz}: $A \Delta B$: Element liegt \textbf{entweder} in $A$ oder in $B$.}
\end{subfigure}
\end{figure}

\end{document}


But the captions are wider than the images, I think, because the Image is only .8 times the line width. I want to add some space between the images, so that the captions don't touch each other, but, however, if I change any of the scaling values, the whole thing gets screwed up:

\documentclass[oneside,12pt,pointednumbers]{scrartcl}
\usepackage[ngerman]{babel} %Deutsche Sprachunterstützung
\usepackage[utf8]{inputenc} %Umlaute
\usepackage{subcaption}
\usepackage{graphicx}

\begin{document}
\begin{figure}
\begin{subfigure}{.4\textwidth}
\centering
\includegraphics[width=\linewidth]{res/Schnittmenge}
\caption{\textbf{Schnitt}: $A \cup B$: Element liegt in $A$ \textbf{oder} in $B$.}
\end{subfigure}
\hfill
\begin{subfigure}{.4\textwidth}
\centering
\includegraphics[width=\linewidth]{res/Vereinigungsmenge}
\caption{\textbf{Vereinigung}: $A \cap B$: Element liegt in $A$ \textbf{und} in $B$.}
\end{subfigure}
\hfill
\begin{subfigure}{.4\textwidth}
\centering
\includegraphics[width=\linewidth]{res/Differenzmenge}
\caption{\textbf{Differenz}: $A \setminus B$: Element liegt in $A$ \textbf{nicht} in $B$. (\textit{A ohne B})}
\end{subfigure}
\begin{subfigure}{.4\textwidth}
\centering
\includegraphics[width=\linewidth]{res/Differenzmenge-Symmetrisch}
\caption{\textbf{Symmetrische Differenz}: $A \Delta B$: Element liegt \textbf{entweder} in $A$ oder in $B$.}
\end{subfigure}
\end{figure}
\end{document}


Any ideas what's the cause of this and how to fix it? How can I add some space between the images, but without ruining the layout? Any tips are greatly appreciated!

• ...you actually forgot an \hfill between the last two subfigures in your last example. Jan 7 '16 at 0:08
• Off-topic: If you're going to use the symbol \Delta to denote the symmetric difference of the sets A and B, you should write \matbin{\Delta} in order to get the same spacing as is used around \cup, \cap, and \setminus.
– Mico
Jan 7 '16 at 0:29
• @Werner Thanks, that probably happened in creating the minimum working example, because in my original file it's there. I didn't notice it ;) Jan 7 '16 at 18:31
• @Mico Thanks for the information, didn't know about \mathbin{}. I'm going to use it now, it's a very useful hint! Jan 7 '16 at 18:32

This doesn't have anything to do with the width choice of your images, but rather with the vertical alignment of the subfigures. Use the [t]op-alignment optional argument, since your images all have the same height:

\documentclass{scrartcl}
\usepackage[ngerman]{babel} %Deutsche Sprachunterstützung
\usepackage{subcaption}
\usepackage{graphicx}

\begin{document}

\begin{figure}
\begin{subfigure}[t]{.4\textwidth}
\centering
\includegraphics[width=\linewidth]{example-image-a}
\caption{\textbf{Schnitt}: $A \cup B$: Element liegt in $A$ \textbf{oder} in $B$.}
\end{subfigure}
\hfill
\begin{subfigure}[t]{.4\textwidth}
\centering
\includegraphics[width=\linewidth]{example-image-b}
\caption{\textbf{Vereinigung}: $A \cap B$: Element liegt in $A$ \textbf{und} in $B$.}
\end{subfigure}

\medskip

\begin{subfigure}[t]{.4\textwidth}
\centering
\includegraphics[width=\linewidth]{example-image-c}
\caption{\textbf{Differenz}: $A \setminus B$: Element liegt in $A$ \textbf{nicht} in $B$. (\textit{A ohne B})}
\end{subfigure}
\hfill
\begin{subfigure}[t]{.4\textwidth}
\centering
\includegraphics[width=\linewidth]{example-image-a}
\caption{\textbf{Symmetrische Differenz}: $A \Delta B$: Element liegt \textbf{entweder} in $A$ oder in $B$.}
\end{subfigure}
\end{figure}

\end{document}


I've used \medskip between the two subfigure sets to make the vertical spacing a little more attractive.

• Thanks! That works like a charm! The [t]-vertical alignment really does the trick! I didn't even know that it's possible to give alignment preferences to subfigure-enviroment! Jan 7 '16 at 18:33