Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I am having a problem with \subcaption labeling subfigures (c) and (d) instead (a) and (b).

I don't know where the problem originates from. I have many figures that contain two subfigures and most of them are labelled correctly, i.e. (a) and (b). But for some particular locations within the code, the labels come out as (c) and (d), no matter which figures how I use. I tried reverting to using \subfigure instead but the labels also come out as (c) and (d) instead of (a) and (b) at those particular locations within the code.

Below is the block of code that I use to have two figures placed next to each other with subcaptions.

Many thanks for your help.

\usepackage[bf]{caption}
\usepackage[hypcap=true]{subcaption}

\begin{figure}[h] 
    \centering
    \subcaptionbox{Figure a\label{fig:a}}
        {\includegraphics[width=0.45\textwidth]{figure-a}}
    \subcaptionbox{Figure b\label{fig:b}}
        {\includegraphics[width=0.45\textwidth]{figure-b}}
    \caption{Figure a and b}
    \label{fig:figure}
\end{figure}

EDIT: The following code is the shortest reproduction of the problem I could achieve. I cut down my original document.

\documentclass[12pt,a4paper]{report}
%Declaring packages for use
\usepackage[utf8]{inputenc}
\usepackage{graphicx}
\usepackage[bf]{caption} %Bold equation and figure captions
\usepackage[hypcap=true]{subcaption}


\begin{document}
\chapter{Intro}
\section{The first chapter}

If we remove this big figure then no bad labeling

\begin{figure}[tbhp]
    \centering
    \Large K
    \caption{big figure}
    \label{fig:big}
\end{figure}

\section{MIS}
If we remove this than no bad labeling

\begin{figure}
    \begin{minipage}[b]{.5\linewidth}
        \centering\large A
        \subcaption{A subfigure}\label{fig:1a}
    \end{minipage}%
    \begin{minipage}[b]{.5\linewidth}
        \centering\large B
        \subcaption{Another subfigure}\label{fig:1b}
    \end{minipage}
    \caption{A figure}\label{fig:1}
\end{figure}



\chapter{Some chapter}
\section{Some Section}
Some section

\subsection{Transfer}
If we remove this then no bad labeling

\begin{figure}[tbhp]
    \centering
    \Large K
    \caption{big figure}
    \label{fig:big}
\end{figure}

\subsection{BAD LABELING HAPPENS HERE}

Here is the bad labeling

\begin{figure}
    \begin{minipage}[b]{.5\linewidth}
        \centering\large A
        \subcaption{A subfigure}\label{fig:1abad}
    \end{minipage}%
    \begin{minipage}[b]{.5\linewidth}
        \centering\large B
        \subcaption{Another subfigure}\label{fig:1bbad}
    \end{minipage}
    \caption{A figure}\label{fig:bad}
\end{figure}


\end{document}
share|improve this question
1  
I couldn't reproduce the odd behaviour mentioned. Can you please post a complete, minimal and compilable version of code allowing to reproduce the problem? –  Gonzalo Medina Mar 24 '11 at 18:29
    
A reproduction has been made. Thanks for looking into my problem. –  ld_pvl Mar 24 '11 at 19:46
2  
The code you posted works OK in my system; I had no problems with the subfigue numbering. Perhaps you are using an outdated version of the subcaption package? –  Gonzalo Medina Mar 24 '11 at 19:52
    
You're right. Updated my caption and subcaption sty files and that solved my problem. Many thanks to you Gonzalo Medina. –  ld_pvl Mar 24 '11 at 20:49
    
Since the problem was due to the use of an outdated version, should we close this as "too localized", or should @Gonzalo first post his comment as an answer? –  Hendrik Vogt Mar 24 '11 at 21:48

1 Answer 1

up vote 2 down vote accepted

As pointed out by Gonzalo Medina in a comment, the problem is due to an outdated version of the subcaption package. Updating the caption and subcaption sty files solves the problem.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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