# Displaying three graphics on one line

I am trying to display 3 graphics on one line (3 cycle graphs each with a caption underneath). How can I do this? Currently I have:

\begin{figure}[h]
\includegraphics[width =3cm]{c3.jpg}
\caption{$C_3$}
\end{figure}

\begin{figure}[h]
\includegraphics[width=3cm]{c4.jpg}
\caption{$C_4$}
\end{figure}

\begin{figure}[h]
\includegraphics[width=3cm]{c5.jpg}
\caption{$C_5$}
\end{figure}


The above displays my three graphs going down vertically on the side of the page with the captions centered (definitely not what I am trying to do).

How can I get these three graphs on one line with their respective caption underneath them?

-
Do you need a "global caption" or not? –  egreg Oct 7 '12 at 17:54

For three independent figures (i.e., not to be treated as three subfigures of one figure), there's no need to use additional packages; you can use three minipages:

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

\begin{document}

\begin{figure}
\centering
\begin{minipage}{.3\textwidth}
\centering
\includegraphics[width=\linewidth]{image1}
\caption{Caption for figure 1}
\label{fig:test1}
\end{minipage}\hfill
\begin{minipage}{.3\textwidth}
\centering
\includegraphics[width=\linewidth]{image2}
\caption{Caption for figure 2}
\label{fig:test2}
\end{minipage}\hfill
\begin{minipage}{.3\textwidth}
\centering
\includegraphics[width=\linewidth]{image3}
\caption{Caption for figure 3}
\label{fig:test3}
\end{minipage}
\end{figure}

\end{document}


For three subfigures of a figure, you can use the subfig package:

\documentclass{article}
\usepackage[demo]{graphicx}
\usepackage{subfig}

\begin{document}

\begin{figure}
\subfloat[Caption for subfigure 1\label{fig:test1}]
{\includegraphics[width=.3\linewidth]{image1}}\hfill
\subfloat[Caption for subfigure 2\label{fig:test2}]
{\includegraphics[width=.3\linewidth]{image2}}\hfill
\subfloat[Caption for subfigure 3\label{fig:test3}]
{\includegraphics[width=.3\linewidth]{image3}}
\caption{A figure with three subfigures}
\end{figure}

\end{document}


The demo option for graphicx simply replaces actual figures with black rectangles; do not use that option in your actual document.

-

Consider using subfigure environment. That's what you need.

demo parameter for graphicx used to create a placeholder instead of an image.

Example:

\documentclass[float,preview]{standalone}
\usepackage[demo]{graphicx}
\usepackage{caption}
\usepackage{subcaption}

\begin{document}
\begin{figure}
\centering
\begin{subfigure}[b]{0.3\textwidth}
\centering
\includegraphics[height=20pt,width=\textwidth]{test.png}
\caption{First}\label{fig:f}
\end{subfigure}
\begin{subfigure}[b]{0.3\textwidth}
\centering
\includegraphics[height=20pt,width=\textwidth]{test.png}
\caption{Second}\label{fig:s}
\end{subfigure}
\begin{subfigure}[b]{0.3\textwidth}
\centering
\includegraphics[height=20pt,width=\textwidth]{test.png}
\caption{Third}\label{fig:t}
\end{subfigure}
\caption{Total caption}\label{fig:total}
\end{figure}
\end{document}


Result:

-
It compiled fine, added the result. –  m0nhawk Oct 7 '12 at 17:59
Thank you for the MWE. –  percusse Oct 7 '12 at 18:17