1

I searched a lot, but cannot figure out the following problem: I am trying to reference another document using the xr package. I also tried out zref but it does not matter regarding the error message.

Set up In the a4paper document "Formelsammlung_StatistikI+II" I have:

\input{chapter/chap1}
\input{chapter/chap2}

And in chap2 is the equation I want to reference in the other document "Statistik":

\begin{equation}\label{random}
random = random
\end{equation}

In the beamer document "Statistik", I have:

\usepackage{xr-hyper}
\usepackage{hyperref}
\externaldocument[f:]{Formelsammlung_StatistikI+II}

\begin{document}
\input{chap1}
\end{document}

And I want to put the reference in chapter one of "Statistik":

Also see \ref{f:random}.

Folder structure In the main folder are Statistik.tex and Formelsammlung_StatistikI+II.tex as well as the chapters of Statistik.tex, which are included in Statistik.tex with input(chap1). In a subfolder are the chapters of Formelsammlung_StatistikI+II.tex, which are also included in Formelsammlung_StatistikI+II.tex with input(chapter/chap1). The referenced part is in chap2.

The error Every time I run Typeset on TeXShop (latest Mac Version) I get the following error:

(./xr-hyper.sty Package xr-hyper Warning: Load package hyperref' afterxr-hyper'. ) ./Statistik.tex:171: Missing \endcsname inserted. \protect l.171

The errors are the same when using the package zref-xr and zexternaldocument, but instead of xr-hyper.sty it laments zref-xr.sty and zref-base.sty. However all mentioned .sty files are put in the folder and in the library texmf/tex/... folder.

I would very much appreciate your help. It is my first post, so I hope I did not forget something. If so, please let me know.

Regards, Nic

  • I assume that 'Formelsammlung.....tex` is a real compilable document? I tried your example and get no error (not using zref, however). I don't think that you need zref here at all – user31729 Nov 17 '15 at 18:39
  • Thanks for your reply. Yeah all documents are compilable without the added xr package. I just gave extracts of the code to keep it simple. – Nic Nov 17 '15 at 18:50
  • I forgot to mention, that the equation I want to reference, is in one of the chapters of "Formelsammlung....tex". I edited my question to clarify that. – Nic Nov 17 '15 at 18:58
  • Yes, but what's inside chap1.tex? We don't have this stuff here available. – user31729 Nov 17 '15 at 19:07
  • Just more content. There actually more chapters, but the relevant one is chap2 where the to be referenced equation is. – Nic Nov 17 '15 at 19:10
0

I solved the issue. The problem laid in the labels of the document to be referenced. There are no problems referencing labels with tab space or special characters within the same document, but when referencing between documents, no tab space or special characters are allowed in the labels. For example:

\label{eq:equation} % in document to be referenced
\ref{f-eq:equation} % in document that puts the reference

works properly.

But...

\label{eq: equation one in chapter 2.1}
\label{f-eq: equation one in chapter 2.1}

will lead to the error I described above.

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.