I would like to create automatic numbering of equations in LyX. when I entered
\renewcommand\[{\begin{equation}}
\renewcommand\]{\end{equation}}
for the "equation" environment it worked. However, when trying to make the align* environment numbering
\renewcommand{\begin{align*}}{\begin{align}}
\renewcommand{\end{align*}}{\end{align}}
it produces errors, such as "LaTeX Error: \begin{align*}undefined".
how can I overcome this?
Best Answer
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: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\usepackage{amsmath}
the Document --> Settings --> LaTeX preamble, orA better option, in my opinion
Instead of redefining
align*
toalign
, you can add a keyboard shortcut to add a numberedalign
. 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 typeas 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
withequation
in the function above, making itCtrl+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.