# Define a custom align, and align* environment

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

-
We still need to work out how to handle this, as the LaTeX2e approach treats the star as part of the name, whereas it is really part of the arguments. As Herbert observes, at present you'll have to create Ealign* independently of Ealign. – Joseph Wright Aug 5 '11 at 8:21
Using aligned is the way to go: Vertical alignment of align* in enumerate – Peter Grill Mar 21 '13 at 2:22

I cannot see the sense of a hardcoded vertical space. However, without xparse try:

\documentclass{article}
\usepackage[fleqn]{amsmath}
\usepackage[shortlabels]{enumitem}
\makeatletter
\newenvironment{Ealign}
{\par\vspace{-8.6ex} \align}
{\endalign}
\newenvironment{Ealign*}
{\par\vspace{-8.6ex}
\start@align\@ne\st@rredtrue\m@ne }
{\endalign }
\makeatother
\begin{document}
...

-
Thanks, this works great. The hard coded vertical space was because I did not know how to determine how much to unskip. But I have adapted your solution here to use the \md and \mi macros as described in vertical alignment in enumerate to eliminate the hard coded amount. – Peter Grill Aug 5 '11 at 8:46