3

Is it possible to have aligned equations which one can split up if they are too long, but such that they are still aligned? I mean a single environment that combines align (equations remain aligned) and multline (if they are too long they may be split in a nice way)

If there is some math counterpart of the \hfill it will be great!

In the following the two vertical bars denote the default width of the math mode, and the minus signs denote empty space

the following is bad

|------------------------------------|

|aaa-=-bbbbbbbbbbbbbbbbbbbbbbbbbbbbbb|

|---=-cccccccccccccccc-+-dddddddddddddddd

It must be somehow turned into

|------------------------------------|

|aaa-=-bbbbbbbbbbbbbbbbbbbbbbbbbbbbbb|

|----=-cccccccccccccccc--------------|

|------------------+-dddddddddddddddd|

that is the second line when broken its other part must be

  1. set in the third line but pushed to the right end and

  2. that end is the farthest end of all lines (on the left) and

  3. the equal signs are still aligned,

Physor
  • 431

2 Answers2

1

enter image description here

\documentclass{article}
\usepackage{mathtools}

\begin{document} \begin{align} aaa & = bbbbbbbb \ & = \begin{multlined}[t] cccccccccccccccc \ + dddddddddddddddd \end{multlined} \end{align} \end{document}

and one more example

\documentclass{article}
\usepackage{mathtools}
%---------------- show page layout. don't use in a real document!
\usepackage{showframe}
\renewcommand\ShowFrameLinethickness{0.15pt}
\renewcommand*\ShowFrameColor{\color{red}}
%---------------------------------------------------------------%

\begin{document} \begin{align} aaa & = bbbbbbbb \ & \begin{multlined}[b][0.35\linewidth] = cccccccccccccccc \ + dddddddddddddddd \end{multlined} \end{align} \end{document}

enter image description here

(red lines show borders of text)

Zarko
  • 296,517
1

I think the first form, using a fixed indent such as \qquad is most common, but the second form, using multlined is closest to what you ask for.

enter image description here

\documentclass{article}

\usepackage{mathtools}

\begin{document}

with qquad \begin{align} aaa&=bbb\ &=cccc\ &\qquad + ddddd \end{align}

with multlined \begin{align} aaa&=bbb\ &=\begin{multlined}[t] ccc\ {}+ ddd \end{multlined} \end{align} \end{document}

David Carlisle
  • 757,742
  • @Physor as you see code in comments doesn't display well. every question really should have a complete test document as in this answer that shows the problem, but I'll add your code and see what it does..... – David Carlisle Jan 22 '21 at 22:22
  • @Physor impossible to say anything about that it has undefined commands and so produces no output. Please edit your question to add a usable test and I'll have a look. – David Carlisle Jan 22 '21 at 22:24
  • I'm sorry it depends on other commands that are defined by me, so it want work if you try it – Physor Jan 22 '21 at 22:24
  • I'll edit my question later and I let you know, thanks a lot! and I'm sorry for any trouble – Physor Jan 22 '21 at 22:25
  • @Physor I can't run it but I would guess V_\tx{eff}^{ll'} is in error and should be V_{\tx{eff}^{ll'}} – David Carlisle Jan 22 '21 at 22:38
  • As I mentioned, the code I provided relies heavily one predefined commands, so it will not work by any one else. It was my mistake forgeting that. But the multilined doesn't push the splitted part to the right end, it can still end before any sufficiently long line (which is not splitted) – Physor Jan 22 '21 at 22:46
  • @Physor sure but an unbraced subscript is almost always wrong (and that one gave an error if i defined all the undefined commands to work like \log (oh I guess \tx may have been short for \text which would sort of work) yes multlined only works locally to work within its own space it can not see the total display. Personally I'd use \qquad – David Carlisle Jan 22 '21 at 23:01