In Chapter 7 of my document which begins
\documentclass[pagesize=auto,bibliography=totocnumbered]{scrbook}
I include a figure (the first in chapter 7) using the code
\begin{figure}[h]
\label{fig:Z1}
\centering
\includegraphics*[width=0.8\textwidth]{images/Z.eps}
\caption{Probability of membership in Cluster 1}
\end{figure}
Figure \ref{fig:Z1} contains a plot of the first column of \verb|Z|.
Now the figure is captioned as Figure 7.1, as I would expect. However in the text following \end{figure} the reference \ref{fig:Z1} gives rise to 7.2.4, which is the number of the subsection in which the figure occurs.
What is going on?
figureandtableenvironments, the\labeldirective must come after, not before, the\captiondirective in order for LaTeX to be able to make the correct association between the label and the object (afigureortable) that's to be cross-referenced elsewhere in the document via\refand similar commands. – Mico Nov 02 '22 at 05:06\label-\refsystem works, please see the query Understanding how references and labels work? – Mico Nov 02 '22 at 05:10