2

I am writing up my thesis and I have some subfigures. When I typeset the code, the subfigures are labelled (a) and (b), however when I refer to the subfigures in the text, I get Figure 4.1.1 and 4.1.2 instead of 4.1(a) and 4.1(b). How do I change the code to get 4.1(a) instead of 4.1.1 in the text? The code I am using for the figures is shown below:

\begin{figure}[!htbp]

  \begin{subfigure}{\textwidth}
  \begin{center}
    \includegraphics[width=0.8\textwidth,valign=t]{figures/chapter4/1.pdf}
    \phantomcaption
    \label{fig:1}
    \end{center}
  \end{subfigure}


  \begin{subfigure}{\textwidth}
   \begin{center}
    \includegraphics[width=0.8\textwidth, valign=t]{figures/chapter4/2.pdf}
   \phantomcaption
    \label{fig:2}
      \end{center}
  \end{subfigure}


\caption{Graphs showing..}  
\label{fig:Demand}
\end{figure}

Thanks

Mensch
  • 65,388
James
  • 21

1 Answers1

2

Since you're using \phantomcaption statements, not "real" \caption statements, inside the subfigure environments, all you should need to do is issue the directive

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

in the preamble. (If you did use \caption statements, you'd also have to provide the directive \captionsetup[subcaption]{labelformat=simple}.)

A separate comment: You also ought to simplify and streamline the code in the figure environment, e.g., by having a single \centering statement and setting up the subfigure environments to occupy widths equal to 0.8\textwidth. The following shows how this might be done.

enter image description here

\documentclass{book} % is this right?
\usepackage[demo]{graphicx} % remove 'demo' option in real document
\usepackage{subcaption}
%\captionsetup[subcaption]{labelformat=simple} % not needed here
\renewcommand\thesubfigure{(\alph{subfigure})}

\begin{document}
\setcounter{chapter}{4} % just for this example

\begin{figure}[!htbp]
\centering
  \begin{subfigure}{0.8\textwidth}
    \includegraphics[width=\linewidth%,valign=t
      ]{figures/chapter4/1.pdf}
    \phantomcaption
    \label{fig:1}
  \end{subfigure}

  \medskip
  \begin{subfigure}{0.8\textwidth}
    \includegraphics[width=\linewidth%, valign=t
      ]{figures/chapter4/2.pdf}
    \phantomcaption
    \label{fig:2}
  \end{subfigure}

\caption{Graphs showing \dots}  
\label{fig:Demand}
\end{figure}

Cross-references to subfigures \ref{fig:1} and \ref{fig:2}.
\end{document}
Mico
  • 506,678