I would like to redefine both the align
and \align*
environments such that the first line is shifted up to line up with the list identifier. I attempted to adapt the solution provided at Starred equivalent in newenvironment, along with \NewDocumentEnvironment
from xparse
but am unable to get the Ealign*
environment to work. Commenting out the last \item
in the list yields: LaTeX Error: Environment Ealign* undefined..
\documentclass{article}
\usepackage[fleqn]{amsmath}
\usepackage[shortlabels]{enumitem}
\usepackage{xparse}
\NewDocumentEnvironment{Ealign}{s}{%
\IfBooleanTF {#1}{%
\csname align*\endcsname\\[-8.6ex]%
}{%
\csname align\endcsname\notag\\[-8.6ex]%
}%
}{%
\IfBooleanTF {#1}{%
\csname endalign*\endcsname%
}{%
\csname endalign\endcsname%
}%
}%
\begin{document}
\begin{enumerate}[(a)]
\item
\begin{align}
a &= b\\
c &= d
\end{align}
%
\item
\begin{Ealign}
a &= b\\
c &= d
\end{Ealign}
\hrule%--------------------------
\item
\begin{align*}
a &= b\\
c &= d
\end{align*}
% Following yields: ! LaTeX Error: Environment Ealign* undefined.
%\item
%\begin{Ealign*}
% a &= b\\
% c &= d
%\end{Ealign*}
\end{enumerate}
\end{document}
As an aside not, this question about Vertical alignment of align* in enumerate is directly related to the issue I am trying to solve here. While that one provides what seems to be a pretty complicated, but automated method of correcting the alignment, it does not address defining a new enviroment for both the \align*
and \align
. I will probably try to incorporate this into the Ealign
environment and eliminate my hackish solution of using \\[-8.6ex]
, which does not work when the align
contains things such as fractions (so would require manually specifying the space value).
Ealign*
independently ofEalign
.aligned
is the way to go: Vertical alignment of align* in enumerate