# How to labeling subfigures contained in a single image file and reference them in the text?

I'm sure that I've seen this question, but today I didn't found it. I have a document with a previously made figure. This figure already has the subfigures and the (a), (b).. marks. How can I label those subfigures considerating that there is only one image?

Supouse that the example image given in the MWE below is somethin like:

\documentclass[12pt,a4paper]{article}
\usepackage{blindtext}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{subcaption}
\usepackage{graphicx}

\begin{document}
\begin{figure}
\centering
\begin{subfigure}{\linewidth}
\centering
\includegraphics[width=0.8\linewidth]{example-image-a}
\label{image-a}
\end{subfigure}
\begin{subfigure}{0\linewidth}
\label{image-b}
\end{subfigure}
\begin{subfigure}{0\linewidth}
\label{image-c}
\end{subfigure}
\begin{subfigure}{0\linewidth}
\label{image-d}
\end{subfigure}
\caption{Example}
\label{figure-1}
\end{figure}

Te figure \ref{figure-1} is has the subfigures
\ref{image-a}, \ref{image-b}, \ref{image-c} and \ref{image-d}
\end{document}


• Well, how should it work? LaTeX's mechanism needs a \refstepcounter (or something that calls it like \caption) before you label the subfigure. So you need to either move your captions into your document or use a refstepcounter. – TeXnician Sep 29 '17 at 4:26

For the \label to work, you need a \caption for each subfigure. This would produce at least the letter for the subfigure. But this can be changed with \DeclareCaptionLabelFormat and \captionsetup, so that an empty \caption{} will not produce anything. Also, some spurious should be removed to get the figure properly centered.

\documentclass[12pt,a4paper]{article}
\usepackage{blindtext}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{subcaption}
\usepackage{graphicx}

% new empty caption label format
\DeclareCaptionLabelFormat{nocaption}{}

\begin{document}
\hrule % to check, if properly centered

\begin{figure}[h]% parameter just for testing
% enable the empty caption label format locally
\captionsetup[subfigure]{labelformat=nocaption}
\centering
\includegraphics[width=0.8\linewidth]{example-image-a}% <----- get rid of space, for proper centering
\begin{subfigure}{0\linewidth}
\caption{}\label{image-a}
\end{subfigure}% <----- get rid of space, for proper centering
\begin{subfigure}{0\linewidth}
\caption{}\label{image-b}
\end{subfigure}% <----- get rid of space, for proper centering
\begin{subfigure}{0\linewidth}
\caption{}\label{image-c}
\end{subfigure}% <----- get rid of space, for proper centering
\begin{subfigure}{0\linewidth}
\caption{}\label{image-d}
\end{subfigure}
\caption{Example}
\label{figure-1}
\end{figure}

Te figure \ref{figure-1} is has the subfigures
\ref{image-a}, \ref{image-b}, \ref{image-c} and \ref{image-d}
\end{document}