1. Thank you, this was very useful.

2. Anja

Thank you, this is indeed very useful!

I only have one question:

What should I adjust if I have 3×2 subfigures?

I followed your suggestion with adding an empty line after the third subfigure but I end up with 2 colums and 4 lines instead of 3 colums and 2 lines.

• tom

Hi Anja,

Thanks for your question. The code below produces three columns. The trick is to split the line width into three equal parts instead of assigning a fixed width.

Best, Tom

\documentclass[varwidth, border=10pt]{standalone}
\usepackage{subcaption}
\usepackage{graphicx}

\begin{document}
\begin{figure}
\begin{subfigure}[b]{0.3\linewidth}
\centering\rule{1cm}{1cm}
\caption{Caption text 1}
\end{subfigure}\hfill
\begin{subfigure}[b]{0.3\linewidth}
\centering\rule{1cm}{1cm}
\caption{Caption text 2}
\end{subfigure}\hfill
\begin{subfigure}[b]{0.3\linewidth}
\centering\rule{1cm}{1cm}
\caption{Caption text 3}
\end{subfigure}

\begin{subfigure}[b]{0.3\linewidth}
\centering\rule{1cm}{1cm}
\caption{Caption text 4}
\end{subfigure}\hfill
\begin{subfigure}[b]{0.3\linewidth}
\centering\rule{1cm}{1cm}
\caption{Caption text 5}
\end{subfigure}\hfill
\begin{subfigure}[b]{0.3\linewidth}
\centering\rule{1cm}{1cm}
\caption{Caption text 6}
\end{subfigure}
\end{figure}
\end{document}
3. Ben

Many thanks for these tricks!

4. frank

Doesn’t seem to work.
! LaTeX Error: Not in outer par mode.

• Hi Frank,

Thanks for your feedback. The code above works for me. The error you see typically arises if you place a floating environment (e.g. figure, table) within a non floating environment (e.g. minipage). If that doesn’t help, please provide a minimal working example for me to reproduce the error.

Best, Tom