14

Using the amsmath environment, I'd like to create a short-cut for

\begin{equation*}
  \begin{split}
    ...
  \end{split}
\end{equation*}

But saying

\newenvironment{eqs}
  {\begin{equation*}\begin{split}}
  {\end{split}\end{equation*}}

and using it with

\begin{eqs}
  ...
\end{eqs}

produces the error

! LaTeX Error: \begin{split} on input line 67 ended by \end{eqs}.

However, using \newcommand works — but \eqs{...} over several lines looks a bit weird:

\newcommand{\eqs}[1]{
  {\begin{equation*}\begin{split}{#1}\end{split}\end{equation*}}}

% ...

\eqs{
  ...
  ...}

Is it possible to get this to work with a new environment, or are there better ways to achieve something equivalent?

Werner
  • 603,163
csl
  • 757

2 Answers2

12

amsmath processes some environments multiple times in order to perform measuring. As such, it captures the environment contents using TeX "parameter text" approach. This requires an explicitly visible \end{<env>} that accompanies a \begin{<env>}. In your case, you want to forgo this using a different shorthand, making \end{<env>} invisible.

One work-around is to capture the body of eqs yourself and passing this to the specified environments. environ provides a means to do this:

\usepackage{environ}

\NewEnviron{eqs}
  {\begin{equation*}
     \begin{split}
       \BODY
     \end{split}
   \end{equation*}}
Werner
  • 603,163
10

I prefer using the original form

\begin{equation*}
  \begin{split}
   <content>
  \end{split}
\end{equation*}

since it is more clear code. However, if you insist, you may use environ package as below.

\documentclass{article}
\usepackage{amsmath}
\usepackage{environ}
\NewEnviron{eqs}{%
\begin{equation*}
  \begin{split}
   \BODY
  \end{split}
\end{equation*}
  }
  \begin{document}
    \begin{eqs}
      x &+ y \\
      a &+ b
    \end{eqs}
  \end{document}