How to write a `where` field selector with value range / value predicate?

Is it possible to write a where field selector which matches a field if its value is in a certain range respectively fulfills a certain predicate (specified as function)?

For example, let’s say only headings with level <= 3 should be numbered. So ideally you would write something like:

#show heading.where(level: <= 3): set heading(numbering: "1.1.")

(the <= 3 here is not valid syntax)

It seems the only solution is to

  • or together multiple selectors, e.g.
    selector.or(
      heading.where(level: 1),
      heading.where(level: 2)
    )
    
  • OR, to write a regular show rule instead of a show set but then you have to use it.body because doing set heading(numbering: ...) inside a show heading seems to have no effect?

Hello, this seems to be a duplicate of Is there a way to select headings for a non-finite range of levels? where the suggestion is to use sela – Typst Universe for now.

1 Like

Yes, thanks that seems to be the same issue, even linking to related GitHub feature requests.

Apparently my search terms (“where selector” and similar) were too general and I overlooked the existing question, sorry.

1 Like