3

following the chat messages of yesterday I open a question on the main site.

So I need to write long equations, and for readability I prefer to use multline and multlined over align. The equations are of the form

function = VeryLongExpression1+AnotherVeryLongExpression2+...

I would like to indent it in the following way

function = VeryLongExpression1
                      +AnotherVeryLongExpression2
                 +StillAnotherVeryLongExpression3
                                             +...

All lines, except the first one of course, should be aligned to the right, not overlapping with the equation number (which I don't use anyway).

At the moment I'm using the multlined environment as

\begin{equation*}
function=
\begin{multlined}[t]
\shoveright{VeryLongExpression1}\\
\shoveright{+AnotherVeryLongExpression2}\\
\shoveright{+StillAnotherVeryLongExpression3}\\
\shoveright{+...}
\end{multlined}
\end{equation*}

but \shoveright does not work on the last line, as reported also on the doc of mathtools.

Is there any way to achieve the desired result?

1 Answer 1

5

A combination of multline* and aligned seems to do the job.

enter image description here

No need for \shoveleft or \shoveright directives.

\documentclass{article} % or some other suitable document class
\usepackage{amsmath} % for 'multline*' and 'aligned' environments

\begin{document}

\begin{multline*}
\text{function} =\text{AVeryVeryVeryLongExpression1}\\
\begin{aligned}
{}+\text{AnotherVeryVeryVeryLongExpression2}      \\
{}+\text{StillAnotherVeryVeryVeryLongExpression3} \\
{}+\dotsb
\end{aligned}
\end{multline*}

\end{document}

Addendum to address the OP's follow-up comments and claims: I'm afraid I am unable to replicate the issue the OP says they are experiencing if the flowfram package is loaded and a multline* environment is employed. As the following screenshot shows, the framelines do not encroach on the sample text above the multline* environment. I can only guess that the OP's issue is caused by some coding choices which haven't been revealed so far and which I am unable to divine on my own -- possibly because my divination skills are simply worthless.

enter image description here

\documentclass{article} % or some other suitable document class
\usepackage{amsmath} % for 'multline*' and 'aligned' environments
\usepackage{lipsum}  % <-- new
\usepackage[draft]{flowfram} % <-- new
\begin{document}
\noindent
\lipsum[1][1-3] % generate two lines of filler text
\begin{multline*}
\text{function} =\text{AVeryVeryVeryLongExpression1}\\
\begin{aligned}
{}+\text{AnotherVeryVeryVeryLongExpression2}      \\
{}+\text{StillAnotherVeryVeryVeryLongExpression3} \\
{}+\dotsb
\end{aligned}
\end{multline*}
\end{document}
8
  • this works very well, but the environment multline causes overlflow(content exits its frame box, see pics imgur.com/a/nD8QhBb), while multlined inside equation do not
    – john
    Dec 4, 2022 at 14:15
  • @john - I'm afraid I don't understand your comment. The image in the link you provided does not appear to substantiate your claim, and neither does the image I posted above. I can only assume that the issue you've encountered is related to information not contained in your posting, such as the fact that your actual equations could be longer than the string StillAnotherVeryVeryVeryLongExpression3. Unfortunately, my divination and mind-reading skills are pretty much worthless. If you want me to provide usable advice on a real issue, it would help if you provided more relevant information.
    – Mico
    Dec 4, 2022 at 14:56
  • You're right, my english is not very good, I'll try to be more clear. I'm compiling in draft mode, using a package that draw boxes around frames (the name of the package is 'flowframe' using the 'draft' option), which are the light grey lines you see. Here you can see better imgur.com/a/jhJ0Ocd . As you can see, the text above the equation exit the boxes. This happen with 'multline', while when I use 'multlined' inside 'equation' this do not happen.
    – john
    Dec 4, 2022 at 15:16
  • @john - Please see the addendum I posted. I am simply unable to replicate the issue you say you're encountering. I am pretty confident in my view, though, that using a multline* environment does not cause the running text to overflow the edges of the text block.
    – Mico
    Dec 4, 2022 at 16:08
  • Thank you for your patience and your addendum. The issue is still not resolved, but, as you said, I guess at this point it has to do with the fact that I'm not using a default class, but rather a custom template with narrow margins. I'll try to look into that. Thanks again. Can I ask you why the '{}' at the start of each line are needed?
    – john
    Dec 4, 2022 at 18:00

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .