[Tex/LaTex] 1.a numbering of subfigures within a figure without a caption

captionscross-referencingsubcaption

I am using the subcaption package and write a caption for each of my subfigures. In order to get a reference to "Fig. 1a", I also have to write a "big caption" below all subfigures. But I don't want to write this "big caption" always. Anyway, I want my figure to have the label "Fig. 1a".

Example:

\documentclass[a4paper]{article}
\usepackage{mwe}
\usepackage{subcaption}
\begin{document}
\begin{figure}[tbp]
    \begin{subfigure}[t]{0.48\linewidth}
        \includegraphics[width=1\textwidth]{example-image-a}
        \caption{An Elephant.}
        \label{fig:elephant}
    \end{subfigure}
    \begin{subfigure}[t]{0.48\linewidth}
        \includegraphics[width=1\textwidth]{example-image-b}
        \caption{A Mouse.}
        \label{fig:mouse}
    \end{subfigure}
\caption{"Big caption". How can I avoid this one and get the label "Fig. 1a"?}
\end{figure}
\end{document}

(My question is not about the format of the number (e.g. "1a" or "1.a") but about "how do I get the "1" in my "1a"-reference)

Best Answer

Here is one way of producing the desired output; there may be better ways.

Wherever you want that numbering system for subfigures within a figure that lacks a \caption, use, at the beginning of the figure environment in question, the \nocaption command defined in my code below.

See section 6 of the subcaption manual for more details.

enter image description here

\documentclass[a4paper]{article}

\usepackage[demo]{graphicx}
\usepackage{subcaption}

\makeatletter
\newcommand\nocaption{%
    \renewcommand\p@subfigure{}
    \renewcommand\thesubfigure{\thefigure\alph{subfigure}}
}
\makeatother

\begin{document}

\begin{figure}[tbp]
\nocaption
    \begin{subfigure}[t]{0.48\textwidth}
        \includegraphics{elephant}
        \caption{An Elephant.}
        \label{fig:elephant}
    \end{subfigure}
    \begin{subfigure}[t]{0.48\textwidth}
        \includegraphics{mouse}
        \caption{A Mouse.}
        \label{fig:mouse}
    \end{subfigure} 
%\caption{"Big caption". How can I avoid this one and get the label "Fig. 1a"?}
\end{figure}

Fig.~\ref{fig:elephant} shows an elephant; Fig.~\ref{fig:mouse}, a mouse.

\end{document}
Related Question