I am trying to display two figures next to each other with captions using subfigures but it keeps placing one under the other.
Here is my code:
\documentclass{article}
\usepackage{graphicx}
\usepackage{siunitx}
\usepackage{hyperref}
\usepackage{xcolor}
\usepackage{subcaption}
\begin{document}
\begin{figure}
\centering
\begin{subfigure}{0.5\textwidth}
\centering
\includegraphics[width=0.7\linewidth]{apparatus.jpg}
\caption{A photograph of the apparatus used}
\label{fig:capparatus}
\end{subfigure}
\begin{subfigure}{0.5\textwidth}
\centering
\def\svgwidth{0.7\linewidth}
\input{diagram.pdf_tex}
%\includegraphics[width=0.7\linewidth]{diagram.pdf}
\caption{A diagram of the apparatus sited inside the evacuated chamber}
\label{fig:cdiagram}
\end{subfigure}
\caption{A graphical depiction of the setup}
\label{fig:csetup}
\end{figure}
\end{document}
I have tried:
- Changing from pdf_tex to just including the pdf file (generated from inkscape)
- Adding [h] and [b] to the subfigures
- Adding a % after the first and second subfigures
- Changing the sizes of the subfigures and images
but nothing seems to make them display on the same line. Does anyone know how to do this?
Here is my output with pdf_tex:
And with just the pdf:
\end{subfigure}\begin{subfigure}
xx
side by sidex<newline>x
a space between themx<newline><newline>x
two paragraphs and vertically stacked x