How to enter a line break within a Math command argument?

In Writer, I’ve entered the following formula:

Q # "=" # alignl{sum from{"chaque communauté"} ( "connexions observées entre les membres de la communauté" - "connexions attendues si réparties de façon aléatoire" )} ## 
Q # "=" # alignl{sum from{i} ( e_ii - a_i^2 )}

Of course, this looks horrible because “chaque communauté” and the other text strings used as terms are far too long on a single line, so I’d like to wrap them. I know that I have to do this manually in formulas using newline, but that doesn’t seem to work for anything that’s within curly brackets. For example, I can’t do:

{"chaque" newline "communauté"}

In fact, I can’t even create a line break between parentheses. The following does not work either:

( "chaque" newline "communauté" )

But it works fine if it’s not between any other grouping operators, so that the following does work:

"chaque" newline "communauté"

I’ve looked through the documentation to see if there was another way to create line breaks but I couldn’t find anything. Is there some workaround for this? I can’t imagine I’m the first person who’s ever tried to enter a long string of text in a formula.

As you already found, it’s not possible to use newline within other instructions. Try with a couple of strategic stack instructions:

Q # "=" # alignl{sum from{stack{"chaque" # "communauté"}} 
left( stack{"connexions observées" # "entre les membres" # "de la communauté"} ~ - ~ 
stack{"connexions attendues" # "si réparties de façon" # "aléatoire"} right)} ## 
Q # "=" # alignl{sum from{i} ( e_ii - a_i^2 )}

Yes operators and brackets need to be balanced inside one line. But there exist some tricks:

left ( “something” newline “very long” right )
will not work.

But you can use

left( “something”right none newline left none “very long” right).

Want to distribute

2 + “something” = “another thing” + “third thing”

on two lines? The operator + and = as well expect an operand both on the left and on the right side. So you need to introduce dummy operands.

Such are e.g.

  • an empty string “”, which forces the line left align, as all strings are left aligned as default

    2 + “something” newline""= “another thing” + “third thing”

  • or an empty object {}, which produces center alignment, the default alignment for calculations

    2 + “something” newline{}= “another thing” + “third thing”

  • or the space signs ` or ~

    2+“something” newline ~ =“another thing” + “third thing”

[The styling features of the text box here does not allow to show, how it will look.]