As a Latex user I’ve always thought of & as being attached to the next symbol (this symbol serving as the alignment point), and it’s never been very clear to me how the “alternative right and left alignment” works, so I just doubled the symbol (writing &&) where necessary based on memory or by trial and error.
Now checking the typst documentation I see it says
this creates blocks of alternatingly right- and left-aligned columns
which I find very helpful: thinking of alignment in columns is much easier, more concrete. Then logically the most readable way to arrange the source code must be to show the actual columns, ideally with the correct alignment already in the source. Taking the example from Math – Typst Documentation this gives
$
(3x + y) / 7 & = 9 & & "given" \
3x + y & = 63 & "multiply by 7" \
3x & = 63 - y & & "subtract y" \
x & = 21 - y/3 & "divide by 3"
$
I’m not sure it’s the most readable but it does help understanding how the alignments work. Also it’s a chore to align the source like that manually so I’ll wait for a plugin in my text editor to do it for me
Thanks! This shows that in my previous post things look very simple because I don’t consider in which column the spaces (e.g. between 7 and =) should land. Reality is more complicated…