1

I have a figure that has three subfigures and I want to \ref them. I need them in this following format:

Fig. 1(a)

But when I use the \ref with the label of the subfigure a, it references this way:

Fig. 1a

I'm using the package \subcaption.

Can anyone help me with this problem?

1
\documentclass{book}

\usepackage[labelformat=simple]{subcaption}
\usepackage{graphicx}

\renewcommand\thesubfigure{(\alph{subfigure})}

\begin{document}

    Fig.\ \ref{coffee1}

    \section{Introduction}

    \begin{figure}[h!]
      \centering
      \begin{subfigure}[b]{0.4\linewidth}
        \includegraphics[width=\linewidth]{example-image}
        \caption{One cup of coffee.}
        \label{coffee1}
      \end{subfigure}
      \begin{subfigure}[b]{0.4\linewidth}
        \includegraphics[width=\linewidth]{example-image}
        \caption{fig:More coffee.}
        \label{fig:coffee2}
      \end{subfigure}
      \caption{Coffee.}
      \label{fig:types_of_coffee}
    \end{figure}

  \end{document}

enter image description here

  • @Codewraith My pleasure! – daniel Oct 29 '18 at 17:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.