1

I have created a separate appendix file and have some figures in this file. I am trying to reference these figures in the text contained in the same file. However, I get undefined reference in the output file - ?? instead of the figure number. I also made sure that my caption for each figure was defined before the corresponding label. Moreover, it worked properly when I had it all in the main file (before I created a separate appendix). Here is my code - I have removed the content and only kept the formatting.

Main file:

 \documentclass[aps,pra,twocolumn,showpacs,amsmath,amssymb,preprintnumbers,superscriptaddress,10pt]{revtex4-1}

\usepackage{graphicx}
\graphicspath{{figures/}}
\usepackage{hyphenat}
\usepackage{color}
\usepackage{url}
\usepackage[bookmarks=false]{hyperref}
\usepackage[capitalise]{cleveref}
\crefname{section}{Sec.}{Secs.}% APS style uses abbreviations
\Crefname{section}{Section}{Sections}
\usepackage[retainplus]{siunitx}
\usepackage[normalem]{ulem} % for the \sout command. Delete when finalized
\usepackage[titletoc]{appendix}


\begin{document}

\begin{appendices}
    \include{Appendix_A}
\end{appendices}

\end{document}

Appendix file (titled Appendix_A):

\section{Appendix} 
                                                                                       
Figure\ref{fig.PMF} shows something.

\begin{figure}
    \includegraphics[width=0.90\linewidth]{example-image}
    \caption[content 1]{content 2}
\end{figure}\label{fig.PMF}
4
  • 1
    \label has to be inside the figure (unrelated to appendix markup) (although the markup shown would produce the wrong reference rather than undefined reference warning) it is always better to post a complete small document that shows the problem, as it is impossible to debug your fragments of code. Commented May 29, 2019 at 9:34
  • Changed it. The above code reproduces the error. You would need to have a file called "PMF.pdf" in your working directory to run it.
    – Matrix23
    Commented May 29, 2019 at 11:05
  • you can use example-image as the image which is generally available for tests or in this case simply delete the \includegraphics as the reference does not need an image, just a caption. Commented May 29, 2019 at 11:20
  • thanks for the test case, that's weird, looking now... Commented May 29, 2019 at 11:24

1 Answer 1

1

You can simplify the test file to

\documentclass[aps,pra,twocolumn,showpacs,amsmath,amssymb,
           preprintnumbers,superscriptaddress,10pt]{revtex4-1}

\usepackage{graphicx}
\usepackage[titletoc]{appendix}


\begin{document}

\begin{appendices}
    \include{Appendix_A}
\end{appendices}

\end{document}

there seems to be a bad interaction here with revtex and the appendix package which ends up breaking the \include mechanism. If you change that to

\input{Appendix_A}

Then it all works as intended.

1
  • Thanks very much. That worked. I also placed the label inside the figure handle because it showed the wrong reference.
    – Matrix23
    Commented May 29, 2019 at 13:21

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .