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 the stackrel command to indicate important steps in the transformation of formulas. E.g. I would write: A\stackrel{(!)}{=}B so that I can later explain in text why exactly A equals B.

I've written a command \refeq{foo} now that will do this for me. So that I can use \eqqref{foo} later in text and it will automatically show the right number for the right equals sing in text (same as using \label{foo} and ref{foo}).

I only have one problem: when I have an equation that I want to label; and within this equation is also an equals sign that I want to reference to, I get the error

Package amsmath Error: Multiple \label's: label 'rom' will be lost.

what should I do to overcome this? I want to be able to ref to an equation and to any equals sign inside this equation.

Here's my working copy:

\documentclass{article}

\usepackage{hyperref}
\usepackage{amsmath}

\def\clap#1{\hbox to 0pt{\hss#1\hss}}
\def\mathllap{\mathpalette\mathllapinternal} \def\mathrlap{\mathpalette\mathrlapinternal} \def\mathclap{\mathpalette\mathclapinternal}
\def\mathllapinternal#1#2{\llap{$\mathsurround=0pt#1{#2}$}}
\def\mathrlapinternal#1#2{\rlap{$\mathsurround=0pt#1{#2}$}}
\def\mathclapinternal#1#2{\clap{$\mathsurround=0pt#1{#2}$}}

\newcounter{qc}
\setcounter{qc}{2}
\usepackage{refcount,makerobust}

\newcommand{\refeq}[1]{%
 \refstepcounter{qc}\label{#1}%
 \stackrel{
  \stackrel{
   {\text{\tiny $\mathclap{\roman{qc}}$}}
  }{\text{$\downarrow$}}
 }{=}%
}


\newcounter{refeqc}
\setcounter{refeqc}{0}

\newcommand{\eqqref}[1]{%
 \setcounterref{refeqc}{#1}%
 $(\roman{refeqc})$
}


\begin{document}



\begin{equation}A\refeq{AB}B\label{romeo} \end{equation}
\begin{equation}R=B\refeq{BC} C\end{equation}

\eqqref{AB} in equation \ref{romeo} is the same as \eqqref{BC}

\end{document}

Any help on what to do would be great!

I've tried using protect and mbox, but nothing works!

share|improve this question

1 Answer 1

up vote 8 down vote accepted

I've tried using protect and mbox, but nothing works!

Neither will help because they have nothing to do with the references.

The mathmode \label in your document is defined in the following way (most likely by amsmath):

\ifx \df@label \@empty \else \@amsmath@err {Multiple \string \label 's: label
 '\df@label ' will be lost}\@eha \fi \gdef \df@label

i.e., it simply stores the label in \df@label but checks first if it is still empty. Then later, at the end of the equation, it is finally used.

What you need for your extra labels is IMHO the textmode \label. The following code seems to work. Note that I saved away the \label to \textlabel and use a group to keep the change to \@currentlabel local. (Do not use { } or \bgroup \egroup for this because they create a new math atom in mathmode.) Without the group both actually independent labels will interact which each other, i.e. in your example the romeo label will be also have the number 3, not 1.

\let\textlabel\label
\newcommand{\refeq}[1]{%
 \begingroup
 \refstepcounter{qc}\textlabel{#1}%
 \stackrel{
  \stackrel{
   {\text{\tiny $\mathclap{\roman{qc}}$}}
  }{\text{$\downarrow$}}
 }{=}%
 \endgroup
}

Just replace your definition of \refeq with this one. You might also have a look on \hyperlink and \hypertarget (IIRC) to manually add hyperlinks.

share|improve this answer
    
thanks! works like a charm. –  romeovs Jan 31 '11 at 22:03

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.