Hello!
I basically have the same problem as this post.
My question is: how do I create a show rule that replaces lr
by \( content \)
, only in math equations that are not in block mode, so that the parentheses don’t scale, and exponents and subscripts are on the same level in nested expressions?
Thanks!
I guess you could try
#show math.equation.where(block: false): it => {
show math.lr: it => it.body
it
}
Hey, thanks for answering! I hadn’t thought of nesting show rules. It almost works. Unfortunately, if I use your version, the parentheses don’t scale, as if I’d done
#set math.lr(size: 1em)
It’s partly what I want, but it doesn’t help for the alignment of the superscripts and subscripts. But what I want is to replace the parentheses with \(
and \)
, and doing
#show math.equation.where(block: false): it => {
show math.lr: it => [\( #it.body \)]
it
}
duplicates the parentheses as body
already includes the parentheses.
I’m open to other ideas.
Ah yes. Maybe there’s a way to fix this with a show rule on attach
, but I’m not sure it can be done correctly for the general case. Example:
#show math.equation.where(block: false): it => {
show math.attach: it => it.base + super(it.t)
it
}
$((...((x - 2)^2 - 2)^2... - 2)^2)$
but this is wrong in many ways (it works only for this case, and uses wrong superscripts). To fix it you’d have to take apart the arguments of attach
in the show rule. I’m not sure this can or should be done, but maybe yes? I think touying for example does something similar.
Maybe something like this can fix it:
#show math.equation.where(block: false): eq => {
show math.lr: it => it.body
show math.attach: it => {
if it.base.func() != math.lr {
return it
}
let fields = it.fields()
let right = math.attach(none, t: fields.t, b: fields.b)
let left = if fields.tl != none or fields.bl != none {
math.attach(none, tl: fields.tl, bl: fields.bl)
}
left + it.base + right
}
eq
}
This removes the automatic lr
and then also moves the attachments of the original lr
outside so that they are attached to nothing instead. Note that this won’t work properly when using limits
, but that doesn’t really make sense with lr
anyway.
It looks like this works for me. Thanks!