The failure has a technical reason that's hinted at in texdoc technote
, section 6.
I suggest something like
\iftrue
\newenvironment{myeq}{\equation}{\endequation}
\else
\newenvironment{\myeq}
{\def\eqbreak{\\}\multline}
{\endmultline}
\fi
\newcommand{\eqbreak}{}
with \eqbreak
rather than \\
(that's not really ignored inside equation
) inside myeq
.
Change \iftrue
into \iffalse
if you want multline
for two column documents.
A possibly better implementation:
\documentclass[
% twocolumn
]{article}
\usepackage{amsmath,amssymb}
\makeatletter
\newenvironment{multiequation}
{%
\if@twocolumn
\def\eqbreak{\\}%
\expandafter\multline
\else
\def\eqbreak{}%
\expandafter\equation
\fi
}
{%
\if@twocolumn
\expandafter\endmultline
\else
\expandafter\endequation
\fi
}
\makeatother
\begin{document}
Some text before the equation to see what happens
and embed the equation into a real paragraph
which should break nicely into a few lines
\begin{multiequation}
\biggl(\int_{-\infty}^{\infty}e^{-x^{2}}\,dx\biggr)^{\!2}
\eqbreak
=\biggl(\int_{-\infty}^{\infty}e^{-x^{2}}\,dx\biggr)
\biggl(\int_{-\infty}^{\infty}e^{-y^{2}}\,dy\biggr)
\eqbreak
=\int\limits_{\mathbb{R}^{2}}e^{-x^{2}-y^{2}}\,dx\,dy
\end{multiequation}
and some text after the equation to see what happens
and embed the equation into a real paragraph
which should break nicely into a few lines
\end{document}
Output with twocolumn
commented out
Output with twocolumn
active
Other than for this application, multline
should never be used for single line displays. Maybe gather
, with
\newenvironment{myeq}{\gather}{\endgather}
but you risk something like the following:
\documentclass{article}
\usepackage{amsmath}
\begin{document}
A paragraph that ends with a short line preceding a display,
let's see if we can
\begin{equation}
(a+b)^2=a^2+2ab+b^2
\end{equation}
A paragraph that ends with a short line preceding a display,
let's see if we can
\begin{gather}
(a+b)^2=a^2+2ab+b^2
\end{gather}
A paragraph that ends with a short line preceding a display,
let's see if we can
\end{document}
No doubt the second one is ugly.
\newenvironment{myeq}{\multiline}{\endmultiline}
multline
should never be used with a single line equation; perhaps you mean to usegather
. It should be\newenvironment{myeq}{\gather}{\endgather}
. Don't do it.equation
equation
environment simply ignores the newline (`\`) commands, I was wondering if I can use that behavior to keep a single copy of each equation in the main text, and control the 2-column vs 1-column spacing differences by means of a flag in the preamble.