3

I have two subfigures and I need to refer them in text such as Fig. 1.1(a) and Fig. 1.1(a) using Fig. \ref{fig1.1a:chap1} and Fig. \ref{fig1.1b:chap1}. The output is not coming. Instead, a double question mark (Fig. ??) appears. How to resolve this?

\documentclass[12pt, a4paper, oneside]{Thesis}
\usepackage{amsmath}
\usepackage{graphicx}
\usepackage{caption}
\usepackage{subfigure}

\begin{document}
\begin{figure}
    \centering
    \begin{tabular}{@{}c@{}}
        \includegraphics[width=\linewidth,height=125pt]{enrollment} \label{fig1.1a:chap1} \\[\abovecaptionskip]
        \small (a) Enrollment phase 
    \end{tabular}
    \vspace{\floatsep}
    \begin{tabular}{@{}c@{}}
        \includegraphics[width=\linewidth,height=125pt]{verification} \label{fig1.1b:chap1} \\[\abovecaptionskip]
        \small (b) Verification phase 
    \end{tabular}
    \caption{Mode of operations in a biometric authentication system}\label{fig1.1:chap1}%
\end{figure}
\end{document}
5
  • Please add a full MWE, starting with \documentclass and ending with \end{document}, with the needed packages.
    – NBur
    Oct 12, 2018 at 6:34
  • @NBur Suggestions done. Oct 12, 2018 at 6:37
  • package subfigure is obsolete. use subfig` insteadit or subcaption (which is more powerful). it load is not suficient, you should use its macro in table composition and than compile document at least twice.
    – Zarko
    Oct 12, 2018 at 6:40
  • @Zarko I am getting everything from it except the correct reference. ?? appears when I use \label and \ref. Oct 12, 2018 at 6:42
  • @rudreshdwivedi, see my answer below. with your code you can't obtain what you expect.
    – Zarko
    Oct 12, 2018 at 6:59

1 Answer 1

4

your approach to show two sub figures is at least unusual, frankly said wrong:

  • you load obsolete package subfigure but than not use it. loading it is not sufficient, you should use its environment in figure composition and than compile document at least twice
  • package subfigure is deprecated. use subfig instead it or subcaption (which is more powerful).
  • references work on labels, which follows captions. that is not a case in your code example
  • it is not clear, what is purpose of tables used in your images
  • see if the following example works for you (i didn't use thesis document class, since i don't know which one you use. but this not influence on obtained result). after two compilation you will obtain working references

    \documentclass{report} % <--- instead of "thesis" which i haven't
    \usepackage{amsmath}
    \usepackage{graphicx}
    \usepackage{caption}
    \usepackage{subcaption} % <--- it is not compatible with "subfigure"
                            % with it you had to replace "subfigure"
    
    \usepackage{lipsum}     % <--- for dummy text
    
    \begin{document}
    \lipsum[1]
    \begin{figure}[htb]     % <---
        \centering
        \begin{subfigure}[b]{0.6\linewidth}     % <---
            \includegraphics[width=\linewidth]{example-image-duck}
            \caption{Enrollment phase}          % <---
            \label{fig1.1a:chap1}
        \end{subfigure}                         % <---
    
        \begin{subfigure}[b]{0.6\linewidth}     % <---
            \includegraphics[width=\linewidth]{example-image-duck}
            \caption{Verification phase}        % <---
            \label{fig1.1b:chap1}
        \end{subfigure}                         % <---
        \caption{Mode of operations in a biometric authentication system}
        \label{fig1.1:chap1}%
    \end{figure}
    Test of references: see subfigures \ref{fig1.1a:chap1}  and \ref{fig1.1b:chap1} in figure \ref{fig1.1:chap1}.
    \end{document}
    

enter image description here

with % <--- are indicated changes in comparison to your document example. if you like to have wide images, than change width of subfigure to desired width.

addendum:

you may be lucky and will can use subfigure package ... :-) :

    \documentclass{report}
    \usepackage{amsmath}
    \usepackage{graphicx}
    \usepackage{caption}
    \usepackage{subfigure} % <---

    \usepackage{lipsum}

    \begin{document}
    \lipsum[1]
    \begin{figure}[htb]     % <---
        \centering
        \subfigure[Enrollment phase \label{fig1.1a:chap1}]%
        {
        \includegraphics[width=0.6\linewidth]{example-image-duck}
        } 

        \subfigure[Verification phase \label{fig1.1b:chap1}]%
        {
        \includegraphics[width=0.6\linewidth]{example-image-duck}
        }
        \caption{Mode of operations in a biometric authentication system}
        \label{fig1.1:chap1}%
    \end{figure}
    Test of references: see subfigures \ref{fig1.1a:chap1}  and \ref{fig1.1b:chap1} in figure \ref{fig1.1:chap1}.
    \end{document}

result is similar as before, however you may experienced new problems with it.

enter image description here

9
  • Error: Package subcaption Error: This package can't be used in cooperation(subcaption) with the subfigure package. \subcaption@CheckCompatibility Oct 12, 2018 at 7:02
  • when you use subcaption in document, you need to delete subfigure from preamble!
    – Zarko
    Oct 12, 2018 at 7:04
  • how to delete that from preamble?? Oct 12, 2018 at 7:05
  • you could help from this \documentclass which I am using: sharelatex.com/templates/thesis/… Oct 12, 2018 at 7:24
  • 1
    @rudreshdwivedi, do you test my mwe as it is? if it work, please than try again with thesis instead report. if with thesis will not work, than you can consider ˙thesis` as obsolete and you need to find more up-to-date document class or you try a luck and use subfigure environments from subfigure package. see addendum to my answer will appear asap)
    – Zarko
    Oct 12, 2018 at 10:21

You must log in to answer this question.

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