[NTG-context] numbering questions
Wolfgang Schuster
wolfgang.schuster.lists at gmail.com
Sun Jan 1 11:27:26 CET 2023
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