Skip to content

Instantly share code, notes, and snippets.

@lilywang1988
Last active May 23, 2018 15:17
Show Gist options
  • Save lilywang1988/2e9c7385779e42b7041c95e20267efe3 to your computer and use it in GitHub Desktop.
Save lilywang1988/2e9c7385779e42b7041c95e20267efe3 to your computer and use it in GitHub Desktop.
This is to introduce how to plot figures in Latex side by side

link

For two independent side-by-side figures, you can use two minipages inside a figure enviroment; for two subfigures, I would recommend the subcaption package with its subfigure environment; here's an example showing both approaches:

\documentclass{article}
  \usepackage[demo]{graphicx}
  \usepackage{caption}
  \usepackage{subcaption}

 \begin{document}

 \begin{figure}
 \centering
 \begin{subfigure}{.5\textwidth}
   \centering
   \includegraphics[width=.4\linewidth]{image1}
   \caption{A subfigure}
   \label{fig:sub1}
 \end{subfigure}%
 \begin{subfigure}{.5\textwidth}
   \centering
   \includegraphics[width=.4\linewidth]{image1}
    \caption{A subfigure}
    \label{fig:sub2}
 \end{subfigure}
  \caption{A figure with two subfigures}
  \label{fig:test}
  \end{figure}

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

@lilywang1988
Copy link
Author

Refer to the link at the beginning for details posted,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment