[NTG-context] Omitting part number in chapter numbers

Simon Collier simon.collier1988 at protonmail.com
Wed Feb 20 02:01:49 CET 2019

Dear list.

I would like to have a TOC that looks basically as follows when stripped down to the essentials:

1 Part1
1 Chapter1
2 Chapter2

2 Part2
3 Chapter3

I don't want the part number to be "part" of the chapter number (no 2.1, just 1, for example).
This behaviour should apply both to the titles in the text and in the TOC..

With the code:

\definestructureresetset[default][1,0,1][1] % reset part and section, but not chapter, from wiki

number=yes,]
\setuplist [part]
[number=yes,]

[number=yes,]
\setuplist [chapter]
[number=yes,]

\starttext
\completecontent

\startpart[title={Part1}]
\startchapter[title={Chapter3}]
\input knuth
\stopchapter
\startchapter[title={Chapter2}]
\input tufte
\stopchapter
\stoppart

\startpart[title={Part2}]
\startchapter[title={Chapter3}]
\input knuth
\stopchapter
\stoppart

\stoptext

I can make chapter numbers flow independently of parts, which is nice.
But the numbering for chapters is like 1.1, 1.2, and 2.3, which is a good default, but not what I want.
Is there any way to omit part number and get only the chapter number displayed?

In wiki there is something that is almost suitable, namely setting:
But this does not work for TOC, returning just zeros (and seems like also an extra zero is spilled on TOC, overall pretty hackish solution).

When nothing seemed to work, I also tried to use an ugly macro that uses lua to format the argument #1 in the numbercommand nicely with the help of string functions,
but it turned out the actual parameter #1 in numbercommand is something other than just a string with numbers and dots.
If someone knows what it is, or how to find out, please point me to the right direction to better understand the system. Currently I'm unable to even print it to the terminal in order to see what actual characters are there, the following code outputting the length (seems to be 19 at least for me) works just fine as well as printing the string itself to the document.

\startluacode

userdata = userdata or

{

}

function userdata.numberfun

(

str

)

context

(

tostring(#str)

)

end

\stopluacode

\def

\mync

#1

%

{

\ctxlua

{

userdata.numberfun

(

[

==

[

#1

]

==

]

)

}

}

The idea seemed pretty standard and is used in many books, so maybe I've just completely missed the right way to approach this.

Regards,
Simon Collier
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ntg.nl/pipermail/ntg-context/attachments/20190220/81df1c45/attachment.html>