23

I have copy+pasted a portion of my latex source here. I'd like to add a caption at the bottom of each of the images load_8.png, load_9.png, load_1.png and load_1.1.png, but can't find an easy way to do this. I've also attached the output of processing this latex code.

output from pdflatex. Can someone please show me the way?

\documentclass{article}
\usepackage{graphicx} % Required for including images
\usepackage[font=small,labelfont=bf]{caption} % Required for specifying captions to tables and figures
\begin{document}
\begin{center}
\includegraphics[width=0.49\linewidth]{fig/load_8.png}
\includegraphics[width=0.49\linewidth]{fig/load_9.png}
\captionof{figure}{Probability distribution with loading level of a): 0.8 ; b) 0.9}
\end{center}
\begin{center}
\includegraphics[width=0.49\linewidth]{fig/load_1.png}
\includegraphics[width=0.49\linewidth]{fig/load_1_1.png}
\captionof{figure}{Probability distribution with loading level of a) 1.0 b) 1.1 }
\end{center}
\end{document}
0

2 Answers 2

16

You can use a minipage too.

\documentclass{article}
\usepackage[demo]{graphicx} % Required for including images
\usepackage[font=small,labelfont=bf]{caption} % Required for specifying captions to tables and figures
\begin{document}
\begin{center}
\begin{minipage}{0.48\linewidth}
\includegraphics[width=\linewidth]{fig/load_8.png}
\captionof{figure}{Some here}
\end{minipage}%
\hfill
\begin{minipage}{0.49\linewidth}
\includegraphics[width=\linewidth]{fig/load_9.png}
\captionof{figure}{some more}
\end{minipage}
\captionof{figure}{Probability distribution with loading level of a): 0.8 ; b) 0.9}
\end{center}
\begin{center}
\begin{minipage}{0.49\linewidth}
\includegraphics[width=\linewidth]{fig/load_1.png}
\captionof{figure}{some more}
\end{minipage}
\hfill
\begin{minipage}{0.49\linewidth}
\includegraphics[width=\linewidth]{fig/load_1_1.png}
\captionof{figure}{some more}
\end{minipage}
\captionof{figure}{Probability distribution with loading level of a) 1.0 b) 1.1 }
\end{center}
\end{document}

enter image description here

If you don't want Figure 1. for those captions, use \captionof* instead of \captionof

15

With your code, the easiest option would be to use a tabular and manually label each figure inside it.

\documentclass{article}
\usepackage{graphicx} % Required for including images
\usepackage[font=small,labelfont=bf]{caption} % Required for specifying captions to tables and figures
\begin{document}
\begin{center}
\begin{tabular}{cc}
\includegraphics[width=0.49\linewidth]{example-image-a} &
\includegraphics[width=0.49\linewidth]{example-image-b} \\
 a) & b)\\
 \end{tabular}
\captionof{figure}{Probability distribution with loading level of a): 0.8 ; b) 0.9}
\end{center}
\begin{center}
\begin{tabular}{cc}
\includegraphics[width=0.49\linewidth]{example-image-a} &
\includegraphics[width=0.49\linewidth]{example-image-b} \\
 a) & b)\\
 \end{tabular}
\captionof{figure}{Probability distribution with loading level of a): 1.0 ; b) 1.1}
\end{center}
\end{document}

enter image description here

Although I think it's better to use subfigure environments from subcation package. They help to manage automatic references and better align subfigures and captions.

\documentclass{article}
\usepackage{graphicx} % Required for including images
\usepackage[font=small,labelfont=bf]{caption} % Required for specifying captions to tables and figures
\usepackage[subrefformat=parens]{subcaption}

\begin{document}

\begin{figure}
\begin{subfigure}[b]{.49\linewidth}
\centering
\includegraphics[width=\linewidth]{example-image-a}
\caption{First}\label{fig1a}
\end{subfigure}\hfill
\begin{subfigure}[b]{.49\linewidth}
\centering
\includegraphics[width=\linewidth]{example-image-b}
\caption{Second}\label{fig1b}
\end{subfigure}%
\caption{Probability distribution with loading level of \subref{fig1a}: 0.8 and \subref{fig1b}: 0.9}
\end{figure}

\begin{figure}
\begin{subfigure}[b]{.49\linewidth}
\centering
\includegraphics[width=\linewidth]{example-image-b}
\caption{First}\label{fig2a}
\end{subfigure}\hfill
\begin{subfigure}[b]{.49\linewidth}
\centering
\includegraphics[width=\linewidth]{example-image-a}
\caption{Second}\label{fig2b}
\end{subfigure}%
\caption{Probability distribution with loading level of \subref{fig1a}: 1.0 and \subref{fig1b}: 1.1}
\end{figure}
\end{document}

enter image description here

Not the answer you're looking for? Browse other questions tagged .