[NTG-context] start/stop executed conditionally on mode ?

Fabrice L fabrice.alpha at gmail.com
Tue Jun 9 18:35:54 CEST 2020



> Le 9 juin 2020 à 03:37, Hans Hagen <j.hagen at xs4all.nl> a écrit :
> 
> On 6/8/2020 9:53 PM, Fabrice L wrote:
>>> Le 7 juin 2020 à 23:19, Aditya Mahajan <adityam at umich.edu <mailto:adityam at umich.edu>> a écrit :
>>> 
>>> On Sun, 7 Jun 2020, Fabrice L wrote:
>>> 
>>>> Dear List,
>>>> 
>>>> I would like to insert a page using (ideally) start/stop instructions. The problem is that this page should be inserted only in a certain mode. Consulting the mailing list, I thought the following code was working, but it’s not ! The code is executed in the mode as expected, but the following instructions ("Some other text... » in the exemple) is not typeset.
>>>> 
>>>> Here is a minimal (not working!) example:
>>>> 
>>>> % ————————————————————————————————————
>>>> \unexpanded\def\StartQuestionsList{
>>>> \startmode[ClassRoom]  \page[yes] Here are some questions: \blank
>>>> }
>>>> \unexpanded\def\StopQuestionsList{
>>>> \page[yes] \stopmode
>>>> }
>>>> \definestartstop[Questions][
>>>> before=\StartQuestionsList,
>>>> after=\StopQuestionsList
>>>> ]
>>>> 
>>>> 
>>>> \startQuestions
>>>> Question A….
>>>> Question B….
>>>> \stopQuestions
>>>> 
>>>> Some other text...
>>>> % ————————————————————————————————————
> One of the oldest mechanism available ... blocks:
> 
> \enablemode[classroom] % comment this
> 
> \defineblock[Question]
> 
> \doifmode {classroom} {
>    \keepblocks[Question]
> }
> 
> \starttext
> 
>    Text A
> 
>    \beginQuestion
>        Question A….
>    \endQuestion
> 
>    Text B
> 
>    \beginQuestion
>        Question B….
>    \endQuestion
> 
>    \page
> 
>    \doifnotmode {classroom} {
>        \useblocks[Question]
>    }
> 
> \stoptext

You are right of course... In fact I already use blocks, for another purpose, but I did not think about this solution because I needed a lot of formatting (these blocks should occupy whole page, different background color…), but blocks can adapt to my current need (I have try this morning) using the \setupblock[][before=..,after=…] command. And there is a bonus; I can « collect » these blocks and put them all together at the end of my courses notes, this is perfect.




More information about the ntg-context mailing list