Which show rule takes precedence?

The short answer is that show rules are wrappers, that can introduce styling issues later down the road (if you need to style the element further). Which is what you see. Therefore, you should always avoid using show rules and instead use set/show-set/set-if/show-set-if rules, i.e., try something else before making show rule. Usually, when you have a single template, it doesn’t matter, since you style everything once, and you know exactly how to style everything.

And yes, the show rule closure is applied to the content of the heading and not to the element in the show rule selector. See Set rule inside show rule (closure) for the same element gets applied for table/grid · Issue #6219 · typst/typst · GitHub. If you know this, you can take advantage of it, like here.

2 Likes