There indeed seems to be an issue with the interaction between the heading’s hanging-indent and the weak spacing that is placed between the numbering and the body of the heading. When setting the hanging indent to zero, it looks the same as in 0.11.1. I have filed an issue here.
However, the numbering parameter is not really the right place for this kind of styling. For example, look what happens when you try to reference a level-2 heading:
A better place way to implement this kind of number layout would be in a show rule for headings. The numbering itself should only represent which kind of numbers should be printed:
#set heading(
hanging-indent: 0pt,
numbering: (..nums) => {
let vals = nums.pos()
let pattern = if vals.len() == 1 { "1." }
else if vals.len() <= 4 { "1.1" }
if pattern != none { numbering(pattern, ..nums) }
}
)
For positioning and coloring, you can then write a show rule for headings. I tried my best to mimic the behaviour of your code:
#show heading: it => {
if it.level == 1 or it.level > 4 {
return it
}
let number = if it.numbering != none {
set text(fill: main-color) if it.level < 4
let num = counter(heading).display(it.numbering)
let width = measure(num).width
let gap = 5mm
place(dx: -width - gap, num)
}
block(number + it.body)
}
When you now try to reference a section, it looks as one would expect: