Formula alignment and fractions

I read this topic. After trying several ways to bracket “… alignr … alignc … formula …”, I found that, for right alignment, “alignr {} { alignc formula }” works. For example:

matrix{
alignr{}{alignc 3+{2+3x} over 2}# {}={} # a+a+a+a ##
x+x+x+x+x # {}={} # ""{{2a-8}over 3 }
}

Are there simpler alternatives?

I don’t think there is a simpler alternative. However, I think your formula is not correctly structured regarding your alignx directives. You request full right alignment with alignr{} and you immediately cancel it wit alignc. You get what you want but this is clumsy. It does not emphasize that you want the denominator centred relative to the wider numerator (note that you in fact request both to be centred over the fraction bar; so this is not a mistake). The weirdness comes from alignr being applied to “nothing”.

My version would rather be:

matrix{
alignr{ 3+{2+3x} over {alignc 2}}# {}={} # alignl {a+a+a+a} ##
alignr{x+x+x+x+x} # {}={} # alignl{{2a-8} over {alignc 3} }
}

alignl can be omitted.

Tested with 24.8.4.2 under Fedora 41, KDE Plasma desktop.


PS: when asking here, always mention OS name, LO version and save format.

About the weirdness, I don’t get alignx directives. In alignr { { alignc 1 over 2 } }, alignc cancels alignr. However, in alignr { 0 + { alignc 1 over 2} }, alignc applies only to some sort of mini environment. Why is that?
About structuring and clumsiness, in matrix{ formula # <?> ## <?> # <?> } can be emphasized that I want everything within the formula to be centered and its position right aligned?
OS Windows 10. LO 7.4.7.2 (x64). Save format, idk