#How do I reset the heading counter?

29 messages · Page 1 of 1 (latest)

calm onyx
#

I want my appendix to start with A.1.1.

#counter(heading).update(1)

= Topic name Appendix A
= Subtopic name Appendix A.1
= Topic name Appendix B

The problem is that Appendix A is called B and not A.
Its also not possible pass 0 to the update function.

#

?render

#set heading(numbering: "1.1")
= Intro
= Other One

#set heading(numbering: "A.1")
#counter(heading).update(1)

= Topic name Appendix A
== Subtopic name Appendix A.1
= Topic name Appendix B
mental pasture
#

this sure looks like a bug

#

gh issue maybe?

calm onyx
#

Ok found a solution:

#

?render

#set heading(numbering: "1.1")
= Intro
= Other One

#set heading(numbering: (..args) => {
    let nums = args.pos()
    if nums.len() == 0 { return [] }
    nums.first() = nums.first() - 1 
    numbering("A.1", ..nums)
})

#counter(heading).update(1)

= Topic name Appendix A
== Subtopic name Appendix A.1
= Topic name Appendix B
mental pasture
#

that’s terrifying

calm onyx
#

@warm moat Is this intended?

mental pasture
#

(no)

calm onyx
#

Probably not but I can see why it currently works this way

mental pasture
#

I can’t?

#

Consider this, without the updating of the heading

#

?render

#set heading(numbering: "1.1")
= Intro
= Other One

#set heading(numbering: "A.1")

= Topic name Appendix A
== Subtopic name Appendix A.1
= Topic name Appendix B
mental pasture
#

it goes 1 2 3 4, right

#

makes sense (though I personally think that whenever you update the heading numbering it should default to resetting the counter, but whatever)

calm onyx
#

You set the value to 1 via update and the next heading uses step on it. This is how you get a 2

mental pasture
#

so there’s no way to reset the heading to the first element

#

that’s definitely unintended behavior

calm onyx
#

Yep

merry phoenix
#

?render

#set heading(numbering: "1.1")
= Intro
= Other One

#set heading(numbering: "A.1")
#counter(heading).update(())

= Topic name Appendix A
== Subtopic name Appendix A.1
= Topic name Appendix B
merry phoenix
#

@calm onyx like this?

#

it's not documented unfortunately

calm onyx
merry phoenix
#

wdym, isn't that what you wanted to achieve?

calm onyx
#

Oh sorry I completely missed the example