Subfigures in LaTeX


In \LaTeX documents we refer to figures by using “label” and “\ref” commands. If a figure is comprised of many subfigures, declare label to each subfigure and then we can refer to the subfigure labels. The main figure is referred using the label defined outside the subfigure environment.

In the following example, the figure is comprised of four subfigures. Each subfigure is defined with a label. After all the subfigures, a label is given to entire figure. Now we can refer to entire figure or each subfigure as shown in the following example.

\documentclass[a4paper,10pt]{article}
\usepackage{graphicx}
\usepackage{subfigure}
 
\begin{document}
\begin{figure}[!ht]
\centering
% -------------- SUBFIGURE -1 -------------- %
\begin{subfigure}[Figure-1]{
\includegraphics[width=.45\linewidth] {./rand}   
\label{fig:subfig1} }
\end{subfigure}
\hfill
% -------------- SUBFIGURE -2 -------------- %
\begin{subfigure}[Figure-2]{
\includegraphics[width=.45\linewidth] {./rand}
\label{fig:subfig2} }%
\end{subfigure}
\hfill
% -------------- SUBFIGURE -3 -------------- %
\begin{subfigure}[Figure-3]{
\includegraphics[width=.45\linewidth] {./power}
\label{fig:subfig3} }%
\end{subfigure}%
\hfill
% --------------SUBFIGURE -4 -------------- %
\begin{subfigure}[Figure-4]{
\includegraphics[width=.45\linewidth] {./power}
\label{fig:subfig4} }%
\end{subfigure}%
 
\label{myfigure}                            % label to the whole figure
\caption{This is main figure caption }
\end{figure}
Now you can refer to subfigures as follows 
Fig.~\ref{fig:subfig1}, Fig.~\ref{fig:subfig2}, Fig.~\ref{fig:subfig3} and Fig.~\ref{fig:subfig4}. 
\end{document}

subfigure-snap

References

CTAN subfigure document

Leave a Comment