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
?
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
!)
\tagform@
is used for two 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 \eqtagform@
and \reftagform@
would help class and package writers. - egreg
\newenvironment
? - azetina
eqnarray
is not always the best choice: “Avoid eqnarray!” by Lars Madsen gives some more reasons. (Should this be required reading?) - brian-ammon