Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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?

share|improve this question
    
Why thank you!! –  David P May 6 '13 at 22:06

2 Answers 2

up vote 5 down vote accepted

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 :)

\documentclass{article}

\usepackage{xr}
\externaldocument[S]{myotherfile}

\usepackage{prettyref}
\newrefformat{Seq}{Eq.~S\ref{#1}}

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

Contents of myotherfile.tex:

\documentclass{article}
\begin{document}
\begin{equation}
    a=b \label{eq:myequation}
\end{equation}
\end{document}

Output of the main file:

enter image description here

share|improve this answer
    
Thanks! If I also had \begin{algorithm} ... \label{alg:myalg} \end{algorithm} in myotherfile.tex and wanted to reference that, could I do \prettyref{Seq:myalg}, or do I have to preface everything with eq: in myotherfile.tex? –  David P May 6 '13 at 22:05
    
You have to prefix all references coming from myotherfile.tex by an S. You could add \newrefformat{Salg}{Algorithm~S\ref{#1}} in the main file and then use \prettyref{Salg:myagl}. –  Jubobs May 6 '13 at 22:06
\newcount\suppl
\suppl0
\def\Ref#1{\ifnum\suppl<1 \ref{#1} \else S\ref{#1}\fi}

And at the beginning of the supplement you should write \suppl1. Of course, you should write Eq.~\Ref{eqn:first} instead of Eq.~\ref{eqn:first}.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.