[Tex/LaTex] Automatically add prefix to references from another document


I'm using xr to reference equations in supplemental material to a paper. I'd like equations from the supplement referenced in the paper to automatically be prefixed with "S", so that Eq.~\ref{eqn:first} appears in the text as Eq. S1. Ideally this would be true in the supplemental document as well. How do I do this?

Best Answer

Here is a solution combining the xr and prettyref packages. The downside is that it forces you to use \prettyref instead of \ref, but you might benefit from the kind of automation provided by the prettyref package anyway :)




You can find more about \prettyref{Seq:myequation} in my other paper.

Contents of myotherfile.tex:

    a=b \label{eq:myequation}

Output of the main file:

enter image description here