Graphics, Figures & TablesFigure labeling

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
Amitavo Roy
Posts: 14
Joined: Sat Apr 06, 2013 11:50 am

Figure labeling

Post by Amitavo Roy »

I would like to add two figures (one below the another-named them a and b respectively),
I used

Code: Select all

\begin{figure}[!h]
  \centering
  \includegraphics[width=0.8\linewidth]{52a}
  \includegraphics[width=0.8\linewidth]{52b}
    \caption{(a) Study of convergence..., (b) zoomed picture of the encircled   
             portion of (a).....}
    \label{fig:5.2a}
    \label{fig:5.2b}
\end{figure}
After runing this code line I can ref. only fig. 5.2 in my text...but I want to ref. in some places with fig. 5.2a and in some places with fig. 5.2b.

My question is thus: how can I label my figures with two different labels?
Thanks for your help
Amitavo
Last edited by Stefan Kottwitz on Mon Apr 08, 2013 4:38 pm, edited 1 time in total.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

sommerfee
Posts: 503
Joined: Mon Apr 09, 2007 4:20 pm

Figure labeling

Post by sommerfee »

One option would be using the/my subcaption package. It offers a command called \phantomcaption which does all a regular \caption does (incrementing the figure or sub-figure counter, generating an anchor for \label and \ref, ...) but does not actually typeset a caption text.

For example:

Code: Select all

\documentclass{article}
\usepackage[demo]{graphicx}
\usepackage{subcaption}
\begin{document}
\verb|\ref{fig:5.2a}| gives \ref{fig:5.2a} and
\verb|\ref{fig:5.2b}| gives \ref{fig:5.2b}.
\begin{figure}
  \centering
  \begin{subfigure}{0.8\linewidth}
    \includegraphics[width=\hsize]{52a}
    \phantomcaption
    \label{fig:5.2a}
  \end{subfigure}
  \begin{subfigure}{0.8\linewidth}
    \includegraphics[width=\hsize]{52b}
    \phantomcaption
    \label{fig:5.2b}
  \end{subfigure}
  \caption{(a) Study of convergence..., (b) zoomed picture of the encircled   
             portion of (a).....}
\end{figure}
\end{document}
Amitavo Roy
Posts: 14
Joined: Sat Apr 06, 2013 11:50 am

Re: Figure labeling

Post by Amitavo Roy »

Thanks a lot sommerfee .....
Post Reply