From: Wolfgang Schuster <wolfgang.schuster.lists@gmail.com>
To: Simon Collier <simon.collier1988@protonmail.com>,
mailing list for ConTeXt users <ntg-context@ntg.nl>
Subject: Re: Omitting part number in chapter numbers
Date: Wed, 20 Feb 2019 17:27:45 +0100 [thread overview]
Message-ID: <76d1ecd2-eb8b-c799-ce95-4543d13cbd94@gmail.com> (raw)
In-Reply-To: <yejbaImNoxb7MUgEP9YIEwF4mUYyU-3EQvn6SSEHXzw5f_KLFZXkBe04d9OXxFmhPJs1pDwvBB1f8x1DfYcLB4MMwAStdUHgOaD1fQPFN-Q=@protonmail.com>
Simon Collier schrieb am 20.02.19 um 02:01:
> 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
> \setuphead[sectionresetset=default]
>
> \setuphead[part]
> [placehead=yes,
> number=yes,]
> \setuplist [part]
> [number=yes,]
>
> \setuphead [chapter]
> [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:
> numbercommand={\determineheadnumber[chapter]\currentheadnumber\gobbleoneargument}]
> 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.
You have to use the “sectionsegemnts” key.
\setuphead
[part]
[placehead=yes]
\setuphead
[chapter]
[sectionsegments=chapter]
\starttext
\completecontent
\part{Part 1}
\chapter{Chapter 1}
\chapter{Chapter 2}
\part{Part 2}
\chapter{Chapter 3}
\stoptext
Wolfgang
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage : http://www.pragma-ade.nl / http://context.aanhet.net
archive : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___________________________________________________________________________________
prev parent reply other threads:[~2019-02-20 16:27 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-02-20 1:01 Simon Collier
2019-02-20 16:27 ` Wolfgang Schuster [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=76d1ecd2-eb8b-c799-ce95-4543d13cbd94@gmail.com \
--to=wolfgang.schuster.lists@gmail.com \
--cc=ntg-context@ntg.nl \
--cc=simon.collier1988@protonmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).