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.

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?

share|improve this question
1  
The timely juxtaposition of this and tex.stackexchange.com/q/28894/86 makes me ponder the potentiality of a package here ... –  Loop Space Sep 19 '11 at 12:31
add comment

1 Answer 1

up vote 16 down vote 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:

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

share|improve this answer
1  
This shows a weakness of amsmath: the same command \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 Sep 20 '11 at 9:47
    
Is there a way to restore to the default setting, let us say outside a \newenvironment? –  azetina May 26 '12 at 17:53
    
@egreg Is it possible to restore to the default setting, let us say outside a \newenvironment or after some point in the document? –  azetina May 26 '12 at 18:10
    
@azetina Yes, of course, but it's quite difficult to understand what you have in mind. –  egreg May 26 '12 at 18:12
1  
Only slightly related, but as @Andrew Stacey pointed out, eqnarray is not always the best choice: “Avoid eqnarray!” by Lars Madsen gives some more reasons. (Should this be required reading?) –  brian-ammon Jun 7 '12 at 15:36
show 3 more comments

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.