3

I have two really long equations that don't fit into one line. I would like to display them as

first_eq LHS, super super super super long =
                                        first_eq RHS, aligned right, also not short
second_eq LHS, not as long as first eq = 
             second_eq RHS, aligned right, pretty loooooooooooooooooooooooooong too

Note that all lines are aligned to a side, either left or right. How can I achieve this within latex? I'm somewhat familiar with align, so if I wouldn't have to learn new packages that'd be great, but not a deal breaker.

I'm not sure whether the two equation signs should be vertically aligned, that could potentially look neat.

Neither of the solutions in the closed-as question work here. For example,

\begin{multline}
(\rho + \delta  + (1-\beta)f(m(a, \bar u, l))J(a, \bar u, l) = \\
\left((1 - \beta)(p(a, \bar u, l) - b) + dJ(a, \bar u, l)\mathbf z(a, \bar u, l)\right)\\
\rho U (a, \bar u, l) = \\
b + f(m(a, \bar u, l))\frac{\beta}{1-\beta}J(m(a, \bar u, l))  + \eta \underbar U + dU(a, \bar u, l)\mathbf z(a, \bar u, l) \\
 \perp \underbar U \leq U(a, \bar u, l) \leq \bar U(a, \bar u, l)
\end{multline}

does not align them as I want to but equations rather hover weirdly in the center. Wrapping it around in dmath has no impact whatsoever.

FooBar
  • 983

3 Answers3

3

You may use multlined from mathtools:

\documentclass{article}
\usepackage{mathtools}

\begin{document}

\begin{gather}
\begin{multlined}[c][\dimexpr\textwidth-4em]
\shoveleft{
(\rho + \delta  + (1-\beta)f(m(a, \bar u, l))J(a, \bar u, l) =\hfill} \\
\bigl((1 - \beta)(p(a, \bar u, l) - b) + dJ(a, \bar u, l)\mathbf z(a, \bar u, l)\bigr)
\end{multlined}
\\
\begin{multlined}[c][\dimexpr\textwidth-4em]
\shoveleft{\rho U (a, \bar u, l) =\hfill} \\
b + f(m(a, \bar u, l))\frac{\beta}{1-\beta}J(m(a, \bar u, l))  + \eta \underbar U + dU(a, \bar u, l)\mathbf z(a, \bar u, l) \\
 \perp \underbar U \leq U(a, \bar u, l) \leq \bar U(a, \bar u, l)
\end{multlined}
\end{gather}

\end{document}

enter image description here

egreg
  • 1,121,712
1

enter image description here

written as two multlined equations:

\documentclass{article}
\usepackage{mathtools}
%-------------------------------- show page layout, only for test
\usepackage{showframe}
\renewcommand\ShowFrameLinethickness{0.15pt}
\renewcommand*\ShowFrameColor{\color{red}}
%---------------------------------------------------------------%

\begin{document}
\begin{gather*}
\begin{multlined}[\linewidth]
(\rho + \delta  + (1-\beta)f(m(a, \bar u, l))J(a, \bar u, l) = \\
\mbox{}\hfill\left((1 - \beta)(p(a, \bar u, l) - b) + dJ(a, \bar u, l)\mathbf z(a, \bar u, l)\right)
\end{multlined}\\
 %
\begin{multlined}[\linewidth]
\rho U (a, \bar u, l) = \\
b + f(m(a, \bar u, l))\frac{\beta}{1-\beta}J(m(a, \bar u, l))  + \eta \underbar U + dU(a, \bar u, l)\mathbf z(a, \bar u, l) \\
 \perp \underbar U \leq U(a, \bar u, l) \leq \bar U(a, \bar u, l)
\end{multlined}
\end{gather*}
\end{document}
Zarko
  • 296,517
1

In amsmath's multline environment, one can force a specific line to be left- or right-aligned by invoking the \shoveleft or \shoveright macros:

\documentclass{article}
\usepackage{amsmath}
\usepackage{showframe}

\begin{document}

\begin{multline}
(\rho + \delta  + (1-\beta)f(m(a, \bar u, l))J(a, \bar u, l) = \\
\shoveright{\left((1 - \beta)(p(a, \bar u, l) - b) + dJ(a, \bar u, l)\mathbf z(a, \bar u, l)\right)} \\
\shoveleft{\rho U (a, \bar u, l)} = \\
b + f(m(a, \bar u, l))\frac{\beta}{1-\beta}J(m(a, \bar u, l))  + \eta \underbar U + dU(a, \bar u, l)\mathbf z(a, \bar u, l) \\
\perp \underbar U \leq U(a, \bar u, l) \leq \bar U(a, \bar u, l)
\end{multline}

\end{document}

enter image description here

Tiuri
  • 7,749