0

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.
3
  • I get no error. Is your system up-to-date? (But I get a warning about multiply defined labels and I think you should better use a prefix for the external document.) – Ulrike Fischer Jan 9 '20 at 13:52
  • It is up to date: it's vanilla TeX Live, which I update with tlmgr update --self --all pretty much daily (and I'm sure I'd done that very recently last night, when I wrote). – grobber Jan 9 '20 at 18:58
  • The error vanishes though if I add a prefix, as you suggested. I'll do some more testing, but I think this does it. – grobber Jan 9 '20 at 19:07
0

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 '20 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.