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?

3

1 Answer 1

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

1
  • @Codewraith My pleasure!
    – daniel
    Oct 29, 2018 at 17:16

You must log in to answer this question.

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