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 want to edit the \eqref command so that \eqref will produce Eq. (1), for example, instead of (1). Of course, I could define


but then I lose my editor's ability to present a list of former labelled equations when encountering the \eqref command (I am using Inlage).

So I was wondering if it's possible to refer to a previous command definition, without re-defining it, and just append the changes. something in the form

\renewcommand{\eqref}{Eq.~[old_\eqref definition]}

Hope it's clear.

share|improve this question
Vaguely related question: tex.stackexchange.com/q/28903/86 – Loop Space Sep 19 '11 at 12:31
up vote 15 down vote accepted

There's a "standard" method:


First of all you save a copy of the command to modify, then redefine it using the saved copy. It would be almost equivalent to say


but this is less efficient, as it reads the argument twice: one for the (new) \eqref and one for the \originaleqref.

There is also the etoolbox method:


that doesn't require to keep a copy of the old command. However, this method will fail for commands that are defined with \DeclareRobustCommand or that take an optional argument, so it needs looking at the command's definition.

With xpatch one could do

share|improve this answer
Great! this is exactly what I wanted. Also thanks for the explanation – PineApple Sep 19 '11 at 10:28

(I know that this isn't what you want to do, but it's very close so that others might find this question hoping to do the following.)

egreg's answer is what to do if you only want to change how the reference is typeset when it is referred to. If you want to change it everywhere, meaning when the label itself is typeset, then you need to change a macro called \tagform@. As far as I can see, amsmath doesn't include a facility for changing this easily so it needs to be redefined. Also, its definition involves a few commands that clearly "do something special" so its overall form should be preserved.

Its original definition is:


so to change it, you would put the following in your preamble:


For an explanation of the surrounding commands, see What do \makeatletter and \makeatother do?

The #1 becomes the equation number. Keep everything inside the \maketag@@@ macro, and keep the stuff surrounding the #1 where it is. Thus to change the format of the equation number (as I did above), you change the opening and closing parentheses and nothing else! (Unless you know what you're doing.)

So if you want your equation numbers to be green with purple spots, you might have:


Where, \GreenWithPurpleSpots is defined in the StrangeAndBizarreColours package[1].

More seriously, if you want square brackets instead of curved, you could put:


Here's an example showing both this reformatting and egreg's redefinition of the \eqref command:





x^2 + y^2 = z^2

We refer to \eqref{aneq}.

And the output:

redefined equation labels

[1]: This is a joke, although I fully expect that package to exist on CTAN within about a week of posting.

share|improve this answer
Thanks. But in which situations besides referring to this equation would I use the label name? – PineApple Sep 19 '11 at 11:27
@PineApple: This changes the format of the label in the equation as well. That's the situation that it didn't seem that you yourself wanted, but which others who found your question might want. – Loop Space Sep 19 '11 at 11:35
Added a screenshot to make it clearer (I hope). – Loop Space Sep 19 '11 at 11:39
Yeah I understand that. But just wondering: in which more situations would I use that different labelling of the equation, so it would matter? Would a label in an equation be important for anything else besides the reference and it's look? – PineApple Sep 19 '11 at 11:40
The mathtools provides a user interface for redefinitions like this. If you load it, you can have square brackets with these commands: \newtagform{brackets}{[}{]}\usetagform{brackets} – diabonas Sep 20 '11 at 11:08

Try this:

\newcommand{\eq}[1]{\hyperref[#1]{Eq. \eqref{#1}}}

Of course, you need the hyperref package. Put this in the preamble:


(the colorlinks option enables you to paint the referencing text)

share|improve this answer
nice, but is there an option to redefine the \eqref command with this package? – PineApple Sep 19 '11 at 13:26

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.