Competing show-set rules with outline

I’ve seen post about the order of precedence of show-set rules, but here all show rules act on the same element.
I do not understand what happens in the following case:

#show heading.where(level: 1): set heading(numbering: "A.")
#show outline: set heading(numbering: "(i)")
#outline()

In this case (at least in typst v0.15.1) the outline title header will be numbered like “A.”
minimal

And the ordering of show-set rules seem to not matter, i.e.

#show outline: set heading(numbering: "(i)")
#show heading.where(level: 1): set heading(numbering: "A.")
#outline()

has the same result.
So it appears to me that the heading.where(level: 1) show-set rule always applies last.

Is this the intended behaviour? If so how would one set the heading numbering for the outline title is level 1 heading have already been set?

I’m not sure my mental model aligns with the source code, but so far it has held up to reality.
I think of:

#show heading.where(level: 1): set heading(numbering: "A.")
#show outline: set heading(numbering: "(i)")

as simply inserting or changing an existing set rule inside of outline, something to this pseudocode:

// outline element: 
[
  // default set rules for the outline 
  ...
  #set heading(numbering: "(i)") // <- show outline: set heading(...)

  #heading([Contents]) // <- show heading.where(level: 1): set heading(...)
  // the rest of the outline content
  ...
]

set heading(numbering: "(i)") is a general set rule nested inside outline. The show-set rule on heading takes precedence as it acts directly on the heading element.

IMO this is intended behaviour. You can set the heading numbering inside of outline with:

#show outline: it => {
  show heading.where(level: 1): set heading(numbering: "(i)")
  it
}

(I hope my mental model description is understandable :smile:)

5 Likes

Sorry for the late reaction. You mental model makes perfect sense, thank you! A very helpful way to think about it.