[Tex/LaTex] Weird figure numbering in RevTeX article

cross-referencingfloats

Having some issues with the figure numbering in a paper! Most of the figures are numbered just fine, but there are two who are BOTH being called "figure III", and being numbered with roman numerals, while all the rest are numbered differently and have the correct numbers.

I am compiling online on the latest version of Overleaf (not sure what they use).

Here is a minimal example of what I have:

\documentclass[preprint,amsmath,amssymb,aps]{revtex4-1}

\usepackage{graphicx}% Include figure files
\usepackage{dcolumn, tikz}% Align table columns on decimal point
\usepackage{array, float}
\newcolumntype{C}[1]{>{\centering\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}

\usepackage{multirow}


\usetikzlibrary{positioning}

\renewcommand{\thefigure}{\arabic{figure}}

\begin{document}

\noindent There is stuff shown in Fig. \ref{Fig:A} and Fig. \ref{Fig:B}. You can see interesting points in Fig. \ref{Fig:A}, and Fig \ref{Fig:B} shows other stuff.\\

\begin{figure}[H]
\begin{center}
\includegraphics[width=0.7\textwidth]{picture.png}
\caption{A picture showing stuff.}
\end{center}
\label{Fig:A}
\end{figure}


\begin{figure}[H]
\begin{center}
\includegraphics[width=0.7\textwidth]{picture-2.png}
\caption{A picture showing other stuff.}
\end{center}
\label{Fig:B}

\end{figure}

\end{document}

Any help would be much appreciated, as I am going wild trying to fix it so I can submit the article 🙂

Best Answer

Seems that when you have the \caption inside and the \label outside the center environment, the \label doesn't "see" the \caption, and instead attaches itself to something else, likely a \section. But it's recommended to use \centering instead of the center environment anyways (see Should I use center or centering for figures and tables?), so do that and it works fine. Or put the label inside the environment.

\documentclass[preprint,amsmath,amssymb,aps]{revtex4-1}

\usepackage[demo]{graphicx}% Include figure files
\usepackage{float}

\renewcommand{\thefigure}{\arabic{figure}}

\begin{document}
\section{ABC}

There is stuff shown in Fig.~\ref{Fig:A} and Fig.~\ref{Fig:B}.
You can see interesting points in Fig.~\ref{Fig:A}, and Fig.~\ref{Fig:B} shows other stuff.

% this will work
\begin{figure}[H]
\centering
\includegraphics[width=0.7\textwidth]{picture.png}
\caption{A picture showing stuff.}
\label{Fig:A}
\end{figure}

% this will not work    
\begin{figure}[H]
\begin{center}
\includegraphics[width=0.7\textwidth]{picture-2.png}
\caption{A picture showing other stuff.}
\end{center}
\label{Fig:B}
\end{figure}
\end{document}
Related Question