25

For equations in my document, I use the facilities of the amsmath 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:

comparison of default and desired output

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 enter image description here

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

Mico
  • 506,678
diabonas
  • 25,784
  • 1
    The timely juxtaposition of this and http://tex.stackexchange.com/q/28894/86 makes me ponder the potentiality of a package here ... – Andrew Stacey Sep 19 '11 at 12:31

1 Answers1

21

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:

ams tags changed

(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!)

Andrew Stacey
  • 153,724
  • 43
  • 389
  • 751