Forum How do I...?

PDF outline with chapter/section numbers?

cayhorstmann
I was asked to include chapter and section numbers into the PDF outline for a book. I don't know how that outline is generated. I guess it takes all the h1/h2/h3 contents. Which I style as

h1::before {
  content: counter(h1) ". ";
}
h2::before {
  content: counter(h1) "." counter(h2) ". ";
}
h3::before {
  content: counter(h1) "." counter(h2) "." counter(h3) ". ";
}



But those chapter and section numbers don't make it to the outline. Is there any way to make that happen?
  1. Screenshot_2024-04-11_20-55-28.png419.4 kB
mikeday
You can use the bookmark-label property:
h1 {
  bookmark-label: counter(h1) ". " content()
}
cayhorstmann
That worked perfectly, thanks!