[NTG-context] How to create a more human-readable syntax for displaying workbook activities?

Joel uaru99 at yahoo.com
Tue Apr 19 01:58:39 CEST 2022


I am creating a student workbook. There are ~30 chapters, each containing ~20 activities, called "Activity A", "Activity B", and so on.

The `workbook.tex` itself uses a recurse function, so it prints chapter 1-30. The reason I use this, is if I need to do a fast test of the code, I can compile a specific range of chapters, not the whole workbook.

\define\activityA{}
\define\activityB{}

\dostepwiserecurse{1}{30}{1}{

    \chapter{\recurselevel}
        \activityA
        \activityB
}

\activityA prints the workbook activity "Activity A".
\activityB prints the workbook activity "Activity B".

The problem comes in that some activities have varied versions. Just as an example, "Activity C might be a crossword puzzle in some chapters, but a word search in other chapters. My poor solution has been to use registercyclist:

\define\altCa{print a crossword}
\define[3]\altCb{print a word search}
\registercyclelist{activityClist}{\altCa, \altCb{}{}{}, \altCb{}{}{}}
\define\activityC{%
    \usecyclelist{activityClist}
}

This code works okay, but becomes broken if I try to change the page range in `dostepwiserecurse` when testing my code. The other problem is the syntax is super messy. Within this single line, tones of data is crammed in:

\registercyclelist{activityClist}{\altCa, \altCb{}{}{}, \altCb{}{}{}}
...not only is it not easy to read which chapter gets which activity, I also have to fill in the {}{}{} with data, making it more difficult to read.

How can I create a much cleaner, human-readable syntax for storing this? Is there some simpler way to tell ConTeXt Chapter 1 gets one variant, Chapter 2, 3, and 4 get another, etc.?

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ntg.nl/pipermail/ntg-context/attachments/20220418/4d20905b/attachment.htm>


More information about the ntg-context mailing list