4

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 :-)

4
  • Welcome to TeX.SE.
    – Jan
    Jan 2 '17 at 11:15
  • 1
    The figures are numbered 1 and 2 ... (TL 2016, daily updates, on Linux). Please use \usepackage[demo]{graphicx} to make your code compilable, since not everybody has the graphics files at hand. And the labels are outside of the figure environment...
    – user31729
    Jan 2 '17 at 11:15
  • Ah, Torbjorn answered already
    – user31729
    Jan 2 '17 at 11:20
  • Yes, he is to fast for us :-)
    – Jan
    Jan 2 '17 at 11:29
7

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}
4
  • 3
    Note also that you should in general never end a paragraph with \\ . Jan 2 '17 at 11:18
  • 1
    And note, as Torbjørn already changed in his MWE: use ~ to prevent line wrapping in between the word "Fig." and the following number produced by \ref{Fig:A}.
    – Jan
    Jan 2 '17 at 11:23
  • 2
    I'd also add: you don't need to specify the file extension on \includegraphics. They will be added automatically depending on A) if you use old LaTeX or B) newer compilers like pdfLaTeX. In the first case, it will search for extensions 1) .ps, 2) .eps, 3) .ps.gz, 4) .eps.gz. In the latter case, it will try to append 1) .jpg, 2) .png, 3) .pdf. To create portable documents, you are advised, to not include the extension.
    – Jan
    Jan 2 '17 at 11:29
  • 1
    Thanks to all of you for your awesome comments and help! Especially to Torbjørn for the concise and helpful answer! That fixed my problem perfectly! Kudos. Jan 3 '17 at 10:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.