#Error when customising `outline.entry` on `level: 1` headers

14 messages · Page 1 of 1 (latest)

clear jackal
#

i found this weird one when customizing my outline:

#let template(body) = {
  set heading(numbering: "1.")

  let outline-style(it, style: none) = {
    numbering(it.element.numbering,
    ..counter(heading).at(it.element.location()))
    h(0.5em)
    link(it.element.location())[#style[#it.element.body]#h(0.5em) #it.page]
  }

  show outline.entry.where(level: 1): it => outline-style(it, style: smallcaps)
  show outline.entry.where(level: 2): it => outline-style(it, style: strong)

  set outline(indent: auto, fill: "")
  body
}

#show: template.with()

#outline()

= Title

== Subtitle

#bibliography("refs.yml", style: "ieee")
#

refs.yml being:

dns-encryption:
  type: Reference
  title: Secret Key Transaction Authentication for DNS
  serial-number: RFC 2845
  author: Internet Engineering Task Force
  date: 2000
#

commenting out #bibliography or the level: 1 outline entry gets rid of the err

#

?r theme=light

#let template(body) = {
  set heading(numbering: "1.")

  let outline-style(it, style: none) = {
    numbering(it.element.numbering,
    ..counter(heading).at(it.element.location()))
    h(0.5em)
    link(it.element.location())[#style[#it.element.body]#h(0.5em) #it.page]
  }

  show outline.entry.where(level: 1): it => outline-style(it, style: smallcaps)
  show outline.entry.where(level: 2): it => outline-style(it, style: strong)

  set outline(indent: auto, fill: "")
  body
}

#show: template.with()

#outline()

= Title

== Subtitle

// #bibliography("refs.yml", style: "ieee")
clear jackal
#

help appreciated typstguy

wintry parrot
#

The bibliography also counts as a heading but it does not have the key "numbering".

clear jackal
#

i suspect it's bc bibliography's heading doesn't like being customized by the outline

clear jackal
#

i should do some conditional code

#

?

wintry parrot
#

Are you using the web app? In that case you can hover over the it.element in the outline-style() to actually check the content. You can see that for the bibliography it just says numbering: none.

wintry parrot
# clear jackal i should do some conditional code

Yes, you can just wrap the numbering (and horizontal space) in an if-condition:

let outline-style(it, style: none) = {
  if it.element.numbering != none {
    numbering(it.element.numbering,
    ..counter(heading).at(it.element.location()))
    h(0.5em)
  }
  link(it.element.location())[
    #style[#it.element.body]#h(0.5em)#it.page
  ]
}
clear jackal