TransWikia.com

{}edef Hy@tempb {cite.XR@prefix error when citing same bibtex entry in externaldocument

TeX - LaTeX Asked by grobber on June 25, 2021

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.

One Answer

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.

Answered by Ulrike Fischer on June 25, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP