3

I always find myself writing this:

\begin{align}
    once\ &upon \\
     &a\ long\ &time \nonumber \\ % introduce a new mark
     &i\ was\ &time-aligned
\end{align}

and getting this:

enter image description here

Because I actually intended to use this good'ol tabbing logic, where you could add new marks on any line:

\begin{tabbing}
once \=upon \\
\> a long \=time \\ % introduce a new mark
\> i was \> time-aligned
\end{tabbing}

enter image description here

How to enjoy the best of both worlds?
How do I add new alignements marks in subsequent lines in equation mode?

  • See alignat... as in \begin{alignat}{2} once\ &upon \\ &a\ &time \nonumber \\ % introduce a new mark & . &time-aligned \end{alignat} – Steven B. Segletes Apr 16 '18 at 16:07
  • @StevenB.Segletes alignat makes you explicitly define the number of columns, and makes it impossible that columns overlap, right? (like if it was upooooooon in my examples, nothing should be changed in subsequent lines) – iago-lito 'considering leaving Apr 16 '18 at 16:13
  • The way to get "time" to overlap within the "upon" group is to nest the align groups – Steven B. Segletes Apr 16 '18 at 16:21
  • 1
    \begin{alignat}{2} once\ &upon \\& \begin{alignedat}{3} &a\ && time \nonumber \\ % introduce a new mark &.&& time-aligned \end{alignedat} \end{alignat} – Steven B. Segletes Apr 16 '18 at 16:28
  • 1
    Does tex.stackexchange.com/q/110784/15925 help? – Andrew Swann Apr 16 '18 at 17:32
2

In order to retain the numbering ability for each individual line, you will have to stick with alignat rather than adding alignedat nesting, as I had earlier suggested in a comment. However, when a line no longer needs to follow subsequent alignments, you can just put it in a \mathrlap, if that helps your situation.

Here, there is alignment of upon, quite, and i, as well as alignment of time and time.

\documentclass{article}
\usepackage{mathtools}
\begin{document}
\begin{alignat}{3}    once\ &\mathrlap{upon\ (and\ I\ mean\ really\ upon)}&&\\
     &quite\ a\ long\ &&time \nonumber \\ % introduce a new mark
     &i\ was\ &&time-aligned
\end{alignat}
\end{document}

enter image description here

For right-alignment, as shown in one of the OP's examples, just play with the number of & tabs:

\documentclass{article}
\usepackage{mathtools}
\begin{document}
\begin{alignat}{2}    once\ &\mathrlap{upon\ (and\ I\ mean\ really\ upon)}&\\
     &quite\ a\ long\ &time \nonumber \\ % introduce a new mark
     &i\ was\ &time-aligned
\end{alignat}
\end{document}

enter image description here

| improve this answer | |
  • Well, this nails it. It is almost tabbing-logic-like, and it does fullfill all my requirements. Thanks a lot :) (I didn't know about \math*lap..) – iago-lito 'considering leaving Apr 18 '18 at 10:01

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.