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
!)
As LyX normally loads amsmath
automatically if you use one of its environments, I just had to redefine the environment, by adding the following to the preamble:
\renewenvironment{align*}{\align}{\endalign}
Example of result, having added a simple align
environment from the LyX menus:
I used the "command forms" \align
and \endalign
as I think I read somewhere on this site that those are recommended in definitions of environments. Please comment if I'm wrong.
If you still get the error message, try loading amsmath
explicitly, by either
- adding
\usepackage{amsmath}
the Document --> Settings --> LaTeX preamble, or
- going to Document --> Settings --> Math options, unchecking the box by "Use AMS math package automatically" and checking the box below, for "Use AMS math package".
A better option, in my opinion
Instead of redefining align*
to align
, you can add a keyboard shortcut to add a numbered align
. This is done in Tools --> Preferences --> Editing --> Shortcuts (see my answer on Shortcuts for Lemma, Claim, Theorem etc for some more detail, should that be needed). Add a new shortcut, and type
command-sequence math-mode on; math-mutate align;math-number-toggle
as the function. You could for example use Ctrl+Alt+Shift+A as the shortcut, in which case the dialog would look as follows:
Having done this, just hit the specified shortcut, and you have a numbered align
environment.
Similarly you can create a keyboard shortcut for a numbered equation. Just replace align
with equation
in the function above, making it
command-sequence math-mode on; math-mutate equation;math-number-toggle
Ctrl+Alt+Shift+M is free (unless you've defined it yourself), so then only the Alt is the difference between a numbered and an unnumbered. You could of course change these around, making Ctrl+Shift+M create a numbered equation.
Best Answer
The »mathtools« package provides the macros
\newtagform
and\usetagform
which allow to do this quite comfortable.Works of course also with the numbering scheme for equations in
report
andbook
.