[NTG-context] numbering questions

Henning Hraban Ramm texml at fiee.net
Sun Jan 1 14:13:48 CET 2023


Thank you, Wolfgang!
I _knew_ ConTeXt would be able to handle my requirements! ;D
It’s wikified now (at \setuphead and \defineconversion).

Hraban

Am 01.01.23 um 11:27 schrieb Wolfgang Schuster:
> Henning Hraban Ramm via ntg-context schrieb am 31.12.2022 um 18:23:
>> A happy new year to everyone!
>>
>> I’m playing with some examples of section numbering.
>>
>> * Is there a setup to influence the order of number segments? I.e. can 
>> I have “section.chapter.part“ instead of “part.chapter.section”?
> 
> You need a new prefix-set to rearrange the order of the sections.
> 
> %%%% begin example
> \defineprefixset [reverse-section]    [section,chapter] []
> \defineprefixset [reverse-subsection] [subsection,section,chapter] []
> 
> \setuphead
>    [section]
>    [sectionset=reverse-section]
> 
> \setuphead
>    [subsection]
>    [sectionset=reverse-subsection]
> 
> \starttext
> 
> \startchapter [title={A}]
> 
> \startsection [title={B}]
> 
> \startsubsection [title={C}] \stopsubsection
> \startsubsection [title={D}] \stopsubsection
> \startsubsection [title={E}] \stopsubsection
> 
> \stopsection
> 
> \startsection [title={F}]
> 
> \startsubsection [title={G}] \stopsubsection
> \startsubsection [title={H}] \stopsubsection
> \startsubsection [title={I}] \stopsubsection
> 
> \stopsection
> 
> \stopchapter
> 
> \stoptext
> %%%% end example
> 
>> * How can I format the segments, e.g. to get two or three digits each 
>> (leading zeros)?
> 
> You can create your own conversion format.
> 
> %%%% begin example
> \startluacode
> interfaces.implement {
>      name      = "FourDigits",
>      public    = true,
>      arguments = "string",
>      actions   = function(s) context("%04d",tonumber(s)) end
> }
> \stopluacode
> 
> \defineconversion [FourDigits] [\FourDigits]
> 
> \setuphead
>    [chapter]
>    [conversion=FourDigits]
> 
> \starttext
> 
> \startchapter [title={Chapter}] \stopchapter
> 
> \stoptext
> %%%% end example
> 
> Wolfgang
> 



More information about the ntg-context mailing list