How to create different outline entry styles based on the kind of outline

Hello,

I have different kind of outlines and I would like to have different outline.entry styles based on the kind of outline it is.

#outline(title: "Inhaltsverzeichnis", indent: 2em)

= Abbildungsverzeichnis
#outline(title: none, indent: 2em, target: figure.where(kind: image))

= Tabellenverzeichnis
#outline(title: none, indent: 2em, target: figure.where(kind: table))

If it is the default out line I would like to apply the following, otherwise it should use the default.

#show outline.entry.where(level: 1): it => {
      strong[
        #v(2em, weak: true)
        #it.body
        #h(1fr)
        #it.page
      ]
    }

I tried #show outline.where(kind: heading).entry.where but it doesn’t work. How can I achieve this?

You can’t access the target, but you can access the elements themselves to find out of what kind they are:

#show outline.entry.where(level: 1): it => {
  if it.element.func() != heading {
    // Keep default style if not a heading.
    return it
  }

  v(2em, weak: true)
  strong(it.body + h(1fr) + it.page)
}
1 Like

Thank you very much!

@wulfheart Something else, if you set

#set text(lang: "de")

your outline will automatically have “Inhaltsverzeichnis” as its title, no need to set it manually.

1 Like

It may be more idiomatic to use different rules for those by scoping them with a selector like so:

#show outline.where(target: figure.where(kind: table)): it => {
  show outline.entry: set text(red)
  it
}

Although, it looks a little wordy like this.