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:
<assign|item-nr|0>.

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.

2 Likes

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.

2 Likes

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:

<assign|subsection|<macro|title|<assign|subsection-numbered|<compound|subsection-display-numbers>><assign|subsection-prefix|<macro|<compound|the-subsection>.>><compound|next-subsection><compound|subsection-clean><compound|subsection-header|<arg|title>><compound|subsection-toc|<arg|title>><if|<value|subsection-numbered>|<compound|subsection-numbered-title|<arg|title>>|<compound|subsection-unnumbered-title|<arg|title>>><reset-question>>>

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):

<quasi|<assign|subsection|<macro|title|<compound|<unquote|subsection>|<arg|title>><reset-question>>>>
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

<assign|subsection-clean|<macro|<reset-question><reset-subsubsection><subsubsection-clean>>>
3 Likes

@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:

<assign|old-subsection-clean|<value|subsection-clean>>
<assign|subsection-clean|<macro|<reset-question><old-subsection-clean>>>

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:

<assign|subsection-clean|<quasiquote|<macro|<reset-question><unquote|<subsection-clean>>>>>

I’m quite happy with this solution :slight_smile:

1 Like