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.
You can introduce a new counter mysub
\newcounter{mysub}
\setcounter{mysub}{0}
\renewcommand{\themysub}{def\arabic{mysub}}
and use this one instead of \theequation
inside the subequations
.
If you also want this counter to be reset after the end of the subequations
, also add the following lines
\usepackage{etoolbox}
\AtEndEnvironment{subequations}{\setcounter{mysub}{0}}
MWE:
\documentclass[10pt]{article}
% for fancy math
\usepackage{amsmath}
% rank operator
\DeclareMathOperator*{\rank}{rank}
% Matrix transpose
\newcommand{\trans}[1]{\ensuremath{{#1}^\top}}
% for extra space at the end of abbreviation
\usepackage{xspace}
% positive semi-definite
\newcommand{\psd}{\textsc{psd}\xspace}
% boldface uppercase letters for matrices
\newcommand{\Abf}{\ensuremath{\mathbf A}}
\newcommand{\Bbf}{\ensuremath{\mathbf B}}
% boldface lowercase letters for vectors
\newcommand{\xbf}{\ensuremath{\mathbf x}}
% for math blackboard font
\usepackage{amssymb}
% set of real numbers
\newcommand{\Rbb}{\ensuremath{\mathbb R}}
\usepackage{palatino}
\usepackage[sc]{mathpazo}
\usepackage{etoolbox}
\AtEndEnvironment{subequations}{\setcounter{mysub}{0}}
\newcounter{mysub}
\setcounter{mysub}{0}
\renewcommand{\themysub}{def\arabic{mysub}}
\begin{document}
\noindent
For any real symmetric matrcies $\Abf$ such that $\rank(\Abf_{n\times n})=r$,
the following statements are equivalent
and any one of them can serve as the definition of
\emph{positive semi-definite} (\psd) matrices.
\begin{subequations}\label{eq:1}
\begin{itemize}
\item $\trans\xbf \Abf\xbf \geq 0$ for any non-zero vector
$\xbf\in\Rbb^{n\times 1}$.
\hfill\refstepcounter{mysub}\textup{(\themysub)}\label{eq:1a}%
\item All the $n$ eigenvalues of $\Abf$ are non-negative.
\hfill\refstepcounter{mysub}\textup{(\themysub)}%
\item $\Abf=\trans\Bbf \Bbf$ for some $\Bbf$ with $\rank(\Bbf)=r$.
\hfill\refstepcounter{mysub}\textup{(\themysub)}%
\end{itemize}
\end{subequations}
\noindent
We refer to the global equation \eqref{eq:1} and to subequation \eqref{eq:1a}
\end{document}
Output:
Best Answer
I'd define a new environment, to which you give the desired label as argument.