Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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

share|improve this question
2  
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

1 Answer 1

up vote 6 down vote accepted

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}
...
share|improve this answer
    
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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.