I'm trying to reference to subfigures in the main caption of my figure. Unfortunately I'm only getting blanks, not even undefined referencing ??. What's going on?
\documentclass{report}
\usepackage[superscript]{cite}
\usepackage{mathtools}
\usepackage{graphicx}
\usepackage{caption}
\usepackage{subcaption}
\begin{document}
Some text.
\begin{figure}[!h]
\centering
\begin{subfigure}[b]{0.4\textwidth}
\centering
\includegraphics[width=\textwidth]{figure1}
\label{fig:fig1}
\end{subfigure}
\begin{subfigure}[b]{0.4\textwidth}
\centering
\includegraphics[width=\textwidth]{figure2}
\label{fig:fig2}
\end{subfigure}
\caption{\protect\subref{fig:fig1} shows figure 1 and \protect\subref{fig:fig2} shows figure 2.}
\end{figure}
\end{document}

subfigures actually have a caption. Use\caption{\label{fig:fig1}}and\caption{\label{fig:fig2}}in bothsubfigures. – Werner Aug 28 '13 at 14:08subfiguresaway on purpose. I thought that captions weren't necessary to label subfigures? – Robert Aug 28 '13 at 14:18subcaptiondocumentation for an example very similar to yours. – Werner Aug 28 '13 at 14:21(a), it is not nice to link toa. The lector wouln't know, what you mean. In this case you should write:The above shows figure 1 (left) and figure 2 (right)– LaRiFaRi Aug 28 '13 at 14:25(a)if there isn't any. However, the figures themselves already have those labels, so that's why I left the subcaptions out on purpose. – Robert Aug 28 '13 at 14:37\caption{(a)~shows Figure~1 and~(b) shows Figure~2}. Because if you wish to switch thesubfigures, you'd have to change the "hard-coded" image captions as well. As you now know, LaTeX can handle this without the "hard-coding". – Werner Aug 28 '13 at 14:50hyperref. For that reason thesubcaptionpackage offers\phantomsubcaption, see also section "Referencing sub-figures without sub-captions" of thesubcaptiondocumentation. – Aug 30 '13 at 08:28