0

I would like to have two figures side by side in my document. I found an example on here with the following code

\begin{figure}
\centering
\begin{minipage}{.5\linewidth}
\centering
\includegraphics[width=.4\linewidth]{image}
\captionof{figure}{A figure}
\label{fig: test1}
\end{minipage}%
\begin{minipage}{.5\linewidth}
\centering
\includegraphics[width=.4\linewidth]{image}
\captionof{figure}{Another figure}
\label{fig: test2}
\end{minipage}
\end{figure}

However when I try to compile it it comes up with the following errors:

template.tex error line 195 Argument of \caption@ydblarg has an extra } \end{figure}

template.tex error line 195 Paragraph ended before \caption @ydblarg was complete \end{figure}

How can I fix this to make it work?

  • Please edit your question so that it includes a complete example that reproduces the problem. I can't see anything wrong in the fragment you have posted. – Ian Thompson Apr 18 '14 at 16:45
  • 1
    That suggests you have a missing { in the caption argument the fragment you posted looks OK but it isnt the code that made that error. Please always post complete small documents that reproduce the problem. – David Carlisle Apr 18 '14 at 16:46
  • I think we've had this question quite a few times before, e.g: LaTeX figures side by side, Two figures side by side – cmhughes Apr 18 '14 at 16:55
1

try to use subfigure instead of minipage.

How about this code :

\usepackage{graphicx}
\usepackage{caption}
\usepackage{subcaption}

\begin{figure}
        \centering
        \begin{subfigure}[b]{0.5\textwidth}
                \includegraphics[width=\textwidth]{pic1}
        \end{subfigure}
        \begin{subfigure}[b]{0.5\textwidth}
                \includegraphics[width=\textwidth]{pic2}
        \end{subfigure}
        \caption{two pictures side by side}
\end{figure}
0

This compiles fine for me:

\documentclass{article}

\usepackage{graphicx}
\usepackage{caption}

\begin{document}

\begin{figure}
\centering
\begin{minipage}{.5\linewidth}
\centering
\includegraphics[width=.4\linewidth]{image}
\captionof{figure}{A figure}
\label{fig: test1}
\end{minipage}%
\begin{minipage}{.5\linewidth}
\centering
\includegraphics[width=.4\linewidth]{image}
\captionof{figure}{Another figure}
\label{fig: test2}
\end{minipage}
\end{figure}

\end{document}
0

You can try my answer and the examples provided here:

side by side minipage figures

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.