Suppose I have an equation which is too long for one line and I would like to split it over two lines. However, I would like the first line to be left-aligned and the second to be right-aligned w.r.t. the \textwidth
. I tried the following versions:
\documentclass{article}
\usepackage{amsmath}
\newcommand{\shortterm}{\mathit{somestrangefunction}(x,y,z)}
\newcommand{\longdefinition}{x+y+z+x^2+xy+xz+y^2+yz+z^2+x^3+y^3+z^3}
\begin{document}
\[
\begin{array}{lcr}
\multicolumn{2}{l}{\shortterm = {}} & \\
& \multicolumn{2}{r}{\longdefinition}
\end{array}
\]
\begin{flalign*}
& \shortterm = {} &
\end{flalign*}
\begin{flalign*}
& & \longdefinition
\end{flalign*}
\begin{flalign*}
& \shortterm = {} &
\end{flalign*}
\vspace*{-7ex}
\begin{flalign*}
& & \longdefinition
\end{flalign*}
\end{document}
This yields the following output:
The first version does not fill the \textwidth
completely while the second adds a lot of vertical space between the two lines. I can compensate this vertical space with negative \vspace
in the third version and obtain more or less the output that I want to have. However, this code is, well, clumsy (and probably both imprecise and not robust w.r.t. achieving the same vertical space between lines). Is there a more elegant solution to this problem that avoids things like adjusting vertical space manually?