# Redefine standard math environment $...$?

Is it possible to redefine $...$ to be equivalent to \begin{align} ... \end{align}?

(I seldom use anything but the align environment, and $...$ is faster and looks cleaner.)

• What would be a motivation? Aug 1 '16 at 21:59
• (@egreg: See edit.) Aug 1 '16 at 22:03
• You shouldn't substitute equation with align, which should only be used with multiline displays. Aug 1 '16 at 22:04
• @egreg: In this case, this new $...$ could choose automatically... Aug 1 '16 at 22:06

The align environment is special in the sense, that it needs the end tag \end{align} to be present and not hidden inside macros. The environment internally catches the contents of the environment. Then it can measure the widths, before setting the equations. Therefore the following redefinition only redefines $ and uses $ to limit the parameter with the contents and passes it to \begin{align} and \end{align}:

\def$#1${%
\begin{align}#1\end{align}%
}


(\long\def would be needed, when it can happen that there are empty lines in the parameter #1. However, environment align does not like long arguments, thus the definition without \long is better here, see user66081's comment.)

Example file:

\documentclass{article}
\usepackage{amsmath}
\def$#1${\begin{align}#1\end{align}}
\begin{document}
$a &= b\\ c &= d$
\end{document}


• It won't digest empty lines because align doesn't. It is better w/o \long because the error message (in case of empty lines) makes reference to  instead of align Aug 1 '16 at 22:13 • (This is great.) Aug 1 '16 at 23:32 • @user66081 You are right, the original \[ ...  (without amsmath) allows empty lines, but align of amsmath does not. Aug 1 '16 at 23:43
• Better (IMO) to define \protected\def$#1${\begin{equation*}\begin{split}#1\end{split}\end{equation*}} (or with aligned rather than split may be. Aug 2 '16 at 0:15
• @Manuel My interpretation of the question is that $...$ should be just a shortcut for \begin{align}...\end{align}, because align is the main equation type for the document. Unnumbered equation types still remain available (displaymath, equation*). Aug 2 '16 at 5:03