#Special numbering of heading

7 messages · Page 1 of 1 (latest)

tacit wave
#

Hello,
I would to numerate my heading instead of 1.1.1.1 in the format that it would correspond like the following:

  1. -> Chapter 1
    1.1. -> Subchapter 1
  2. -> Chapter 2
    2.1. -> Subchapter 1
    2.2. -> Subchapter 2

I have the following but it does not work properly:

#set heading(numbering: "1.1.1")
#show heading.where(level: 1): it => block(width:100%)[
  #set text(20pt, fill: rgb(119, 184, 0), weight: "bold")
  #block[
    Top #counter(heading.where(level: 1)).display(): #it.body
  ]
  
]

#show heading.where(level: 2): it => block(width:100%)[
  #set text(15pt, fill: rgb(119, 184, 0), style: "normal")
  #locate(loc => {
     let chapter = counter(heading.where(level: 2)).at(loc).first()

  })
  #block[
    #counter(heading.where(level:2)).display() #it.body
  ]
]
civic wyvern
#

i think you're looking for supplements:

#

?r

#set page(paper: "a7")

#set heading(
  numbering: "1.1",
  supplement: it => ([Chapter], [Subchapter]).at(it.level - 1, default: [Section])
)

#show heading: it => block(width:100%)[
  #block[
    #it.supplement #counter(heading).at(it.location()).last(): #it.body
  ]
]

= chap1
== subchap1
= chap2
== subchap2
== subchap3
tacit wave
#

@civic wyvern Thanks. And how can I paint the chapters in a different color than the subchapters?

civic wyvern
#

You already kind of did this, right? Either separate show rules with show heading.where(level: <thing>), or you finagle it in here:

#

?r

#set page(paper: "a7")
#set heading(
  numbering: "1.1",
  supplement: it => ([Chapter], [Subchapter]).at(it.level - 1, default: [Section])
)
#show heading: it => {
  set text(fill: (red, blue, green).at(it.level, default: purple))
  block(width: 100%)[
    #it.supplement #counter(heading).at(it.location()).last(): #it.body
  ]
}

= chap1
== subchap1
= chap2
== subchap2
== subchap3
=== black