Changing the apperance of equation numbers with amsmath

[+19] [1]
diabonas

[2011-09-19 12:05:03]

[
equations
cross-referencing
formatting
amsmath
]

[ http://tex.stackexchange.com/questions/28903/changing-the-apperance-of-equation-numbers-with-amsmath ]

For equations in my document, I use the facilities of the
```
amsmath
```

^{[1]} package. In order to make the equation numbers more eye-catching, I want them to be in boldface and a little bit indented to the right, i.e. like this:

I've already tried redefining the internal `amsmath`

macros `\maketag@@@`

or `\tagform@`

. But both

```
\def\maketag@@@#1{\hbox{\m@th\bfseries#1\hspace{3mm}}}
```

and

```
\def\tagform@#1{\maketag@@@{\bfseries(\ignorespaces#1\unskip\@@italiccorr)}\hspace{3mm}}
```

also change the references produced by `\eqref`

, as this macro internally uses `\tagform@`

to produce its output. These references should keep their default appearance, however, as I don't need the prominent formatting in the running text.

The most promising approach I've tried so far is to redefine `\print@eqnum`

:

```
\def\mytagform#1{\maketag@@@{\bfseries(\ignorespaces#1\unskip\@@italiccorr)}\hspace{3mm}}
\def\print@eqnum{\mytagform\theequation}
```

This redefinition doesn't affect the `\eqref`

references. Sadly though, it seems to work only with `align`

environments, the tags of `equation`

environments aren't changed:

```
\documentclass{article}
\usepackage{amsmath}
\makeatletter
% \maketag@@@ and \tagform@ also influence \eqref
% \def\maketag@@@#1{\hbox{\m@th\bfseries#1\hspace{3mm}}}
% \def\tagform@#1{\maketag@@@{\bfseries(\ignorespaces#1\unskip\@@italiccorr)}\hspace{3mm}}
% \print@eqnum looks promising, but applies only to align environments
\def\mytagform#1{\maketag@@@{\bfseries(\ignorespaces#1\unskip\@@italiccorr)}\hspace{3mm}}
\def\print@eqnum{\mytagform\theequation}
\makeatother
\begin{document}
\begin{equation}
1+1=2\label{equation}
\end{equation}
\begin{align}
1+1 &= 2\label{align}
\end{align}
\eqref{equation}, \eqref{align}
\end{document}
```

outputs

**How can I change the appearance of equation numbers without affecting references produced by \eqref?**

[1] http://ctan.org/pkg/amsmath

[+17]
[2011-09-19 12:30:21]
Loop Space
[ACCEPTED]

Looking at the code, I can see lots of places where `\tagform@`

is used and presumably the code for `equation`

uses one explicitly instead of `\print@eqnum`

. Guessing completely here, I would say that `\print@eqnum`

is used when amsmath has to read in the whole equation and typeset it out again carefully (to get the alignment right). Since `equation`

doesn't involve any fancy alignment, it can be processed directly and as a consequence the tag is written using `\tagform@`

directly.

How about going for the opposite direction? Modify `\tagform@`

to be what you want it to be and then change `\eqref`

so that it uses the original.

```
\documentclass{article}
\usepackage{amsmath}
\makeatletter
\let\mytagform@=\tagform@
\def\tagform@#1{\maketag@@@{\bfseries(\ignorespaces#1\unskip\@@italiccorr)}\hspace{3mm}}
\renewcommand{\eqref}[1]{\textup{\mytagform@{\ref{#1}}}}
\makeatother
\begin{document}
\begin{equation}
1+1=2\label{equation}
\end{equation}
\begin{align}
1+1 &= 2\label{align}
\end{align}
\eqref{equation}, \eqref{align}
\end{document}
```

Result:

(Note added in edit: Barbara Beeton has asked me to add a comment to the effect that the AMS redefinition of the `equation`

environment is meant to keep it looking as the original but with a check for if the `\qed`

symbol should be added. Also, `eqnarray`

appears to be a bit of a minefield in its definition so Things May Go Wrong if you use `eqnarray`

!)

(1)
This shows a weakness of **amsmath**: the same command *distinct* purposes; it's true that frequently the appearance of the equation number is the same, but this can't be taken for granted. Maybe splitting it into ** egreg**

`\tagform@`

is used for two `\eqtagform@`

and `\reftagform@`

would help class and package writers. -
Is there a way to restore to the default setting, let us say outside a ** azetina**

`\newenvironment`

? -
@egreg Is it possible to restore to the default setting, let us say outside a \newenvironment or after some point in the document? - ** azetina**

@azetina Yes, of course, but it's quite difficult to understand what you have in mind. - ** egreg**

@egreg I will post it as a new question? - ** azetina**

@azetina It's probably better - ** egreg**

@egreg see Adjust equation numbering relative to a \newenvironment. - ** azetina**

(1)
Only slightly related, but as @Andrew Stacey pointed out, *Lars Madsen* gives some more reasons. (Should this be required reading?) - ** brian-ammon**

`eqnarray`

is not always the best choice: “Avoid eqnarray!” by 1

Loop Space