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.

  • 1
    @Tiuri: the environment is multline, not multiline – Bernard Jan 25 '18 at 10:35
  • @Tiuri: You can delete and re-post the correct version, so we can delete the superfluous comments. – Bernard Jan 25 '18 at 10:39
  • You probably want to use multline from the amsmath package, see for example here: How can I split an equation over two (or more) lines – Tiuri Jan 25 '18 at 10:40
  • @Tiuri I've now mentioned in the question why that's no solution. – FooBar Jan 25 '18 at 15:08
  • @FooBar: Well, in your original example, there were only two equations with two lines each, and it was not obvious that there is need to have them in the same environment. In case two multlines after each other are not an option for you, you can manually force left- and right-alignment inside multline with the \shoveleft and \shoveright macros. I voted for reopen to add that as a solution. – Tiuri Jan 25 '18 at 15:49
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

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}
  • i can't test, but if i could, i would try nesting the two multlined equations within gather. – barbara beeton Jan 25 '18 at 16:56
  • @barbarabeeton, thank you for tip, i consider it in edited answer. – Zarko Jan 25 '18 at 17:04
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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.