I am making a book, with chapters titled "Week 1", "Week 2", "Week 3", etc., and sections titled "Activity 1", "Activity 2", "Activity 3", etc., and other sections titled "Presentation 1", "Presentation 2", "Presentation 3", etc.
- The preceding numbers, e.g. "1.1 Activity 1", are not used.
- No other text, e.g. "Week 1 Topic" appears in the text.
- The numbers for sections never reset.
Here is a sample table of contents, showing how I hope it will appear:
______________________
| |
| Contents |
| |
| Week 1 |
| Activity 1 |
| Activity 2 |
| Presentation 1 |
| Week 2 |
| Activity 3 |
| Activity 4 |
| Presentation 2 |
|______________________|
The document occassionally has other orginary chapter and section titles as well. These should get the same font formatting, but otherwise, not be modified, and appear without any number, e.g., using chapter titles "Forward", "Conclusion", and a section title called "Notes":
______________________
| |
| Contents |
| |
| Forward |
| Week 1 |
| Activity 1 |
| Activity 2 |
| Presentation 1 |
| Week 2 |
| Activity 3 |
| Notes |
| Conclusion |
|______________________|
I have tried my own solution, by removing the preceding numbers using \setuphead[chapter][number=no]
, creating counters, e.g. \definenumber[weekcount]
, then defining custom macros which call for chapter titles to use these counters, however, my solution does not work:
\definenumber[weekcount]
\definenumber[activitycount]
\definenumber[presentationcount]
\setnumber[weekcount]{1}
\setnumber[activitycount]{1}
\setnumber[presentationcount]{1}
\define\week{\chapter{Week~\getnumber[weekcount]}\incrementnumber[weekcount]}
\define\activity{\section{Activity~\getnumber[activitycount]}\incrementnumber[activitycount]}
\define\presentation{\section{Presentation~\getnumber[presentationcount]}\incrementnumber[presentationcount]}
\setuphead[chapter][number=no]
\setuphead[section][number=no]
\starttext
\week
\activity
This is some text.
\activity
This is some text.
\presentation
This is some text.
\week
\activity
This is some more text.
\activity
This is some more text.
\presentation
This is some more text.
\stoptext
This results in this:
______________________
| |
| Contents |
| |
| Week |
| Activity |
| Activity 1 |
| Presentation |
| Week |
| Activity |
| Activity 1 |
| Presentation |
|______________________|
If you remove \setuphead[chapter][number=no]
, results are also unusual:
______________________
| |
| Contents |
| |
| 1. Week 1. |
| 1.1 Activity 1. |
| 1.2 Activity 1.1 |
| 1.2 Presentation 1. |
| 2. Week 2. |
| 2.1 Activity 2 |
| 2.2 Activity 2.1 |
| 2.3 Presentation 2. |
|______________________|
- Why is the numbering of the counters appear in this manner, when used inside section titles?
- How can I create custom chapter titles using a "Week " format, and similarly formatted section titles?
Best Answer
I agree with you that exploiting the document structure is a convenient choice for this end: it offers a high degree of configurability and comes with neat extras like list (read: table of contents) building by default. So the following will be a structure based solution, leaving the enumerations based approach to somebody else.
The trick is the ownnumbers key of structure headers. It allows precise control over the counter mechanism for every head. Headers that are defined with
ownnumbers=yes
take a mandatory first argument by means of which their counter value can be set explicitly. Counters created by\definecounter
each have their own way key that allows fine-grained control of the reset, or disabling it as required by this question (way=text
).Once the counters are in place, all that’s left is to suppress placement of the structure title element. This is done in two parts: First, all headers are defined to be accessed only implicitly. The user level macros
\week
,\activity
and\presentation
are wrappers that at the same time pass the headers their “ownnumbers” and an empty title string. Second, placement method\activityhead
is defined that chooses the display string from a mapping of labels, ignoring the structure title altogether.(Coding style is mkiv for consistency as
\defineheadplacement
does not support named arguments.)