[Tex/LaTex] Subcaption: wrong subfigure labels

floatssubcaptionsubfloats

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}

Best Answer

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.