Exam style questions

I’m playing with the nice exam style file and I’ve got some questions related to it.

I search a way to reset the counter of the questions for each new section and/or subsections automatically.
I’ve read in the doc how to reset for example an item counter inside an enumerate environment with:

But for the exam style file I’ve got difficulties to find the counter on which to act.
I’ve looked in the std-edu.ts file and try to modify for example the short-arabic macro <assign|short-arabic|<macro|nr|nr>> by brutally putting it to 1 for each new subsection and of course the counter is not incremented anymore :grin:

So I’ve got basically 2 questions:

  • how to find the name of the counters to act on ?
  • how to do this automatically for each new subsection for example ?

Any help will be of course welcome.

1 Like

Questions use a counter which you can reset by doing <reset-question> (there are more commands to manipulate counters in the help). You can probably insert this into a redefined <subsection> macro to do it in every subsection.

1 Like

Yesss, many thanks it works like a charm !

I use the following macro (perhaps not the best one) where I just add the <reset-question> at the end of the subsection macro inside the macro editor:


Thanks !

I do usually like this myself. Maybe a more robust solution is to use quote and quasi quote to extend the standard definition. Something like (not tested):

1 Like

I just discovered the subsection-clean tag, which is described in the help as

The call-back macro x-clean can be used for cleaning some counters when a new section is started.

This seems like an appropriate place to do this kind of resetting. Your case would give


@jeroen’s solutions is the good one.

Actually, my solution just crashes TeXmacs…

It would like to find out what a robust way is of redefining macros, while re-using the previous definition. I tried with <with|old-subsection|<value|subsection>|...> but that also crashed :frowning:

This is a little less nice, but it works:


Thanks @jeroen and @mgubi for your kind help and great info

You’re welcome! I’ve learned from it as well. Thanks for the interesting quesion.

I’ve managed to combine @mgubi’s approach with mine:


I’m quite happy with this solution :slight_smile:

1 Like