Am 27.09.2025 um 04:15 schrieb jbf:
Author considering a novel with a dramatic plot that counts down from 10
to 0.
Challenge: Can I get ConTeXt to do this for him by ensuring that we get
either Parts to decrement 10 to 0 or Chapter numbers to do it instead?
Right out of my depth here but I thought of trying to at least play
around with one idea (defining a ChapterStartNumber and a
ReverseChapterNumber).
I get 10 for every Chapter if I do something like
\def\ChapterStartNumber{10}
\define[1]\ReverseChapterNumber{%
\number\numexpr \ChapterStartNumber - \rawcountervalue[chapter] \relax
}
\setuphead[chapter][number=yes,numbercommand=\ReverseChapterNumber]
\starttext
\chapter{First chapter}
Some text.
\chapter{Second chapter}
\stoptext
So I wondered if I tried to do something different with the \setuphead:
\setuphead[chapter][before={%
\advance\ChapterStartNumber by -1 % decrement before each chapter
}]
But that won't compile.
Then I guess there is the problem that he wants the last chapter to be 0
not 1.
Any thoughts?
You need the headnumber commands to get access to the counter of sections.
%%%% begin example
\define[1]\ReverseChapterNumber
{\the\numexpression{\somenamedheadnumber{chapter}{last}-\somenamedheadnumber{chapter}{current}}}
% \define[1]\ReverseChapterNumber
%
{\convertnumber{number}{\numexpression{\somenamedheadnumber{chapter}{last}-\somenamedheadnumber{chapter}{current}}}}
\setuphead
[chapter]
[numbercommand=\ReverseChapterNumber,conversion=A]
\starttext
\dorecurse{11}{\chapter{Chapter \VerboseNumber{#1}}}
\stoptext
%%%% end example
Wolfgang
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the
Wiki!
maillist : [email protected] /
https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive : https://github.com/contextgarden/context
wiki : https://wiki.contextgarden.net
___________________________________________________________________________________