How to use `where` selector on multiple "levels" of an element?

I’d like to make level 1 entries in an outline bold, but only if the outline contains headings, not figures or anything else:

#show outline.where(target: heading.where(outlined: true)).entry.where(level: 1): it => {
  set text(weight: "bold")
}

Unfortunately, this doesn’t seem to be allowed: cannot access fields on type selector

Is there a way to get around this?

Hi, welcome to the Typst forum!

I think normally the solution should be

#show outline.where(target: heading): it => {
  show outline.entry.where(level: 1): set text(weight: "bold")
  it
}

but due to a bug you need to wrap heading in a selector call:

#show outline.where(target: selector(heading)): it => {
  show outline.entry.where(level: 1): set text(weight: "bold")
  it
}
2 Likes

Thank you very much for your quick reply :)

1 Like