10

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?

  • 1
    Isn't it as simple to use the align*environment? – Bernard Oct 7 '15 at 23:42
  • For this particular problem, you're absolutely right! But I was interested in the general solution anyway. Thanks! – csl Oct 7 '15 at 23:49
8

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*}}
9

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}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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