No, there isn't such a "do-it-all" environment. Each one of equation
, multline
, align
and gather
(you forgot about this one) solves a different problem caused by different sets of math mode material to display.
Breaking math mode material requires judgment that a machine can't have.
There are packages such as nath and breqn that try to automatize this process, but my opinion is that there's no easy algorithm to do breaking properly, because it requires to look at the result.
However, here it is a working doitall
environment:
\documentclass[a4paper]{article}
\usepackage{amsmath,environ,xstring}
\newif\iflabel
\newif\ifdbs
\newif\ifamp
\NewEnviron{doitall}{%
\noexpandarg
\expandafter\IfSubStr\expandafter{\BODY}{\label}{\labeltrue}{\labelfalse}%
\expandafter\IfSubStr\expandafter{\BODY}{\\}{\dbstrue}{\dbsfalse}%
\expandafter\IfSubStr\expandafter{\BODY}{&}{\amptrue}{\ampfalse}%
\iflabel\def\doitallstar{}\else\def\doitallstar{*}\fi
\ifdbs
\ifamp
\def\doitallname{align}%
\else
\def\doitallname{multline}%
\fi
\else
\def\doitallname{equation}
\fi
\begingroup\edef\x{\endgroup
\noexpand\begin{\doitallname\doitallstar}%
\noexpand\BODY
\noexpand\end{\doitallname\doitallstar}%
}\x
}
\begin{document}
Numbered
\begin{doitall}
a=b\label{1}
\end{doitall}
\begin{doitall}
a\\b\label{2}
\end{doitall}
\begin{doitall}
a&=b\label{3}\\
c&=dxxxxx
\end{doitall}
Now no numbers
\begin{doitall}
a=b
\end{doitall}
\begin{doitall}
a\\b
\end{doitall}
\begin{doitall}
a&=b\\
c&=dxxxxx
\end{doitall}
\end{document}
I can understand your desire of a do-it-all environment; but you're losing information.
If you want to use \[
and \]
as delimiters, just say
\def\[#1\]{\begin{doitall}#1\end{doitall}}
in the preamble. Switching the meaning of \[...\]
back and forth is completely useless, of course.
Limitations
You can't use aligned
or gathered
environments inside the doitall
environment, as these have &
and \\
inside them. It's of course impossible to use also the split
environment.
\BODY
to the appropriate environment, at least for simple cases. But that is beyond my skill set.