I was recently searching for a way to place subfigures into one overall figure. As I found out, today we should make use of the subcaption package rather than usig subfig or something else.
However, as googling I found two approaches which seems for me to do the same. For this here is my complete MWE:
\documentclass[]{article}
\usepackage{mwe}
\usepackage{subcaption}
\begin{document}
\blindtext
%%%SUBCAPTIONBOX->
\begin{figure}[h!]
\centering
\subcaptionbox{$n = 10$ steps\label{cw_10}}{%
\includegraphics[width=.48\linewidth]{example-image-a}%
}\hfill
\subcaptionbox{$n = 25$ steps\label{cw_25}}{%
\includegraphics[width=.48\linewidth]{example-image-a}%
}
\caption{A figure with two subfigures using SUBCAPTION}
\label{TS}
\end{figure}
%%%<-SUBCAPTIONBOX
%%%SUBFIGURE->
\begin{figure}[h!]
\begin{subfigure}[b]{.45\linewidth}
\centering
\includegraphics[width=1\linewidth]{example-image-a}%
\caption{$n = 10$ steps}
\label{cw_10}
\end{subfigure}%
\hfill
\begin{subfigure}[b]{.45\linewidth}
\centering
\includegraphics[width=1\linewidth]{example-image-a}%
\subcaption{$n = 25$ steps}
\label{cw_25}
\end{subfigure}
\caption{A figure with two subfigures using SUBFIGURE}
\label{TS}
\end{figure}
%%%<-SUBFIGURE
\blindtext
\end{document}
First, I am using a method with subcaptionbox, then with subfigure-environment. Which one is better or is some Approach 'wrong'?
My Code result in this Picture, I did not see any difference:
subcaption
manual contains the following statement: "A different way of setting sub-figures is offered by the\subcaptionbox
command [...]" So I'd say both methods can be used equally. A difference between the two however is, that withsubfigure
you secify two widths, the width of thesubfigure
and the width of the image, whilesubcaptionbox
only needs the width of the image.