# How to use \def to redefine \end{split}?

When I use \def to redefine \end{split}, there is an error.

\documentclass{article}
\usepackage{amsmath}

\begin{document}
\def\be{$$} \def\ee{$$}
\def\bs{\begin{split}}
\def\es{\end{split}}

\be
\bs
a\\
b
\es
\ee

\end{document}


The error is:

Runaway argument?

a\ b \es \ee

! Paragraph ended before \split was complete.

However, if I don't use \def\es{\end{split}} and just modify the code to be

\documentclass{article}
\usepackage{amsmath}

\begin{document}
\def\be{$$} \def\ee{$$}
\def\bs{\begin{split}}
\def\es{\end{split}}

\be
\bs
a\\
b
\end{split}
\ee

\end{document}


it's OK. What's the problem? Thank you!

Welcome to TeX-SE! The issue is the same as here: LaTeX wants to see an explicit \end{split}. So you could use

\documentclass{article}
\usepackage{amsmath}

\begin{document}
\def\be{$$} \def\ee{$$}
\def\bs#1\es{\begin{split}#1\end{split}}

\be
\bs
a\\
b
\es
\ee

\end{document}


So far for the LaTeXnical aspects of your question.

However, I would like to convince you not to use these abbreviations. At the very moment you collaborate with others, this will be extremely cumbersome; everyone comes with their own abbreviations. And in this millennium there is also no need for that, every editor has shortcuts.

• +1 for the last three lines! – user156344 Feb 24 at 3:35