1

I have the following .tex file in a folder

main.tex
---
\documentclass[11pt]{article}
\usepackage{hyperref}

\title{}
\author{}

\begin{document}

\maketitle

\cite{entry}

\bibliography{bib}{}
\bibliographystyle{plain}


\end{document}

In the same folder, I have another file that uses the main one as an \externaldocument, also citing the same entry entry from the same bib file:

secondary.tex
---
\documentclass[11pt]{article}

\usepackage{hyperref}

\usepackage{xr}
\externaldocument{main}

\title{}
\author{}

\begin{document}

\maketitle

\cite{entry}

\bibliography{bib}{}
\bibliographystyle{plain}


\end{document}

The problem is that when I compile secondary.tex I get the following error, pointing to the citation:

--- TeX said ---
<argument> ... {}\edef \Hy@tempb {cite.\XR@prefix
                                                  entry\@extra@b@citeb }\ifx...l.15 \cite{entry}

Other symptoms:

  • no error if I remove hyperref
  • no error if I turn off \externaldocument
  • no error if entry is only cited in one of the documents
  • even with the error, if I persist and run bibtex and then pdflatex a couple more times the document actually compiles fine, bibliography and everything. So the error just gets ploughed over.
0

1 Answer 1

2

I get the error only when the aux-file doesn't contain the bibentry command (so the compilation order is crucial).

You can avoid the error by using the xr-hyper package:

\usepackage{xr-hyper}

\usepackage{hyperref}

But this doesn't prevent that you get multiply defined labels, so using a prefix for the external document should be done too.

1
  • Hmm.. I think I'll settle for just adding a plain prefix, since that seems to resolve the matter. But I'm curious now: what would be the compilation order that obviates the error without the prefix? I thought that for the references in main to get recognized in secondary you need to compile main first and then secondary, which is what I was doing to begin with..
    – grobber
    Jan 10, 2020 at 20:36

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.