TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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




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

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
\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 need seems to be similar to the purpose of the package cleveref. I personally think these references here and there so simple and good for testing and feeling.

For example:

\crefname{equation}{Eq. S}{equations}

Standard equation reference (\textbackslash ref): \ref{eqn:1}\\
Cleveref equation reference (\textbackslash cref): \cref{eqn:1}
\begin{figure}[ht]\centering\rule{0.5\linewidth}{0.1\linewidth}\caption{First figure}\label{fig:1}\end{figure}
\displaystyle \int 1 = x + C\\
\displaystyle \int x = \frac{x^2}{2} + C \\
\displaystyle \int x^2 = \frac{x^3}{3} + C
Standard figure reference (\textbackslash ref): \ref{fig:1}\\
Cleveref figure reference (\textbackslash cref): \cref{fig:1}\\
And here is the reference using cleveref: \cref{eq:xdef}

The output compiled this example is as below: Illustration of \cref of package cleveref

  • There are two forms of a reference instruction \cref and \Cref for adding lowercase and capital case respectively.
  • I customized the prefix Equation into Eq. S in the preamble section.
share|improve this answer

Your Answer


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.