I'm trying to put two jpegs side by side using the subcaption package, but the images are consistently stacking on top of each other rather than side by side. All the solutions I've found simply state that the pictures have to be small enough to actually be side by side but I've tried making them smaller, too small even and they stay stacked. My code looks like this:
\begin{figure}[H]
\centering
\begin{subfigure}{0.5\textwidth}
\centering
\includegraphics[width=0.3\linewidth]{inclusion.jpg}
\caption{inclusions}
\label{fig:inclu}
\end{subfigure}
\begin{subfigure}{0.5\textwidth}
\centering
\includegraphics[width=0.3\linewidth]{deform}
\caption{grain deformation}
\label{fig:deform}
\end{subfigure}
\caption{filler text}
\label{fig:manmade}
\end{figure}
Help would be greatly appreciated.
Best Answer
Don't leave blank lines in between (a blank line tantamounts to
\par
, so the nextsubfigure
starts a new paragraph), and remove spurious blank spaces (see the%
after the first\end{subfigure}
):A complete example:
The
demo
option forgraphicx
simply replaces actual figures with black rectangles; do not use that option in your actual document.