#show math.equation.where(block: true): set block(spacing: 1.3em)
$
x=y
$<eq:somemath>
I currently use the line above to adjust spacing around equation blocks.
However, I would like to differentiate between equation blocks with one line vs. more than one line of formulas, where also the set up subnumbering with equate looks entirely different. In the multi-line case, I would like to increase the spacing to 2em.
I’m trying to understand how to use a where query or a selector to apply something similar to the following rule only for multi-line equations:
#show math.equation.where(block: true, ...?): set block(spacing: 2em)
$
x &= y \
y &= z \
$<eq:someothermath>
I feel like I cannot use a label such as <multiline-eq> since I need unique labels for document referencing. I would like to avoid wrapping multiline formulas inside a function in the markup.
I think that solving this using just queries or selectors is currently not possible, but i’d love to be proven wrong. The way i’d solve this instead would be to check if the equation contains a linebreak, like so:
#show math.equation.where(block: true): it => {
if linebreak() in it.body.children {
set block(spacing: 2em)
it
}
else {
set block(spacing: 1.3em)
it
}
}
I noticed that I can make it work when using escaped \{\} but I don’t understand why. Am I missing something regarding the use of {} or should I report this as a bug? Maybe @Eric can tell.
I don’t think there is a more simple solution. But this one can be simplified like this:
#show math.equation.where(block: true): it => {
let is-multiline = linebreak() in it.body.children
set block(spacing: 2em) if is-multiline
set block(spacing: 1.3em) if not is-multiline
it
}
The package splits the equation element into many parts, so it’s not straightforward to adapt the show rule to that. At least if you don’t know how it works under the hood.
The body of an equation doesn’t necessarily have to be a sequence, so you should first check that before accessing the children field, as it may not exist.
as @Eric mentioned, the fix is just checking if the equation body is a sequence or not:
#show math.equation.where(block: true): it => {
if it.body.func() == [].func() and linebreak() in it.body.children {
set block(spacing: 5em)
it
}
else {
set block(spacing: 1.3em)
it
}
}