I'm trying to embed 4 images as a 2×2-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!
Best Answer
This doesn't have anything to do with the width choice of your images, but rather with the vertical alignment of the
subfigure
s. Use the[t]
op-alignment optional argument, since your images all have the same height:I've used
\medskip
between the twosubfigure
sets to make the vertical spacing a little more attractive.