I have 2 figure side by side in LaTeX using the recommended package subcaption
.
\begin{figure}
\centering
\begin{subfigure}[b]{0.48\textwidth}
\includegraphics[width=\textwidth]{events/pad_p2}
\label{fig:pad_p2}
\end{subfigure}
~
\begin{subfigure}[b]{0.48\textwidth}
\includegraphics[width=\textwidth]{events/pad_p8}
\label{fig:pad_p8}
\end{subfigure}
\caption{Pads.}
\end{figure}
Then I try to reference them in the text using:
Look at figure~\ref{fig:pad_p8}
But I get an error when compiling the document that the reference doesn't exist.
If instead I put a caption in each subfigure then the error goes away, but that's not what I really want to do.
How do I solve the problem without adding the caption
for each subfigure?