# [NTG-context] How to increment a counter

Otared Kavian otared at gmail.com
Thu Feb 5 17:19:11 CET 2015

```Hi all,

I have a counter in an itemize environment which I need to increment by using
\incrementcounter[NameOfTheCounter]

However this does not work in the following example, maybe due to the use of blocks, or some other reason.
I define two blocks, one for exercises, one for the solutions.
Then in each exercise I have a certain number of questions, presented with an itemgroup named Questions.
Analogously I have an itemgroup named Answers, which appear in the solution to an exercise. Now my problem is that some questions don’t have an answer included (for instance they are too easy…) and I need to increment the counter by saying

But this does not work, for an unknown reason. (See below)

Best regards: OK

\defineblock[Exoblock]
\defineblock[Solblock]

\defineenumeration[exo]
[alternative=hanging,
width=fit,
text=Exercise,
stopper={.},
before=,
after=\blank]

\defineenumeration[solution]
[alternative=hanging,
width=fit,
text=Solution of exercise,
stopper={.},
before=,
after=\blank]

\defineitemgroup[Questions]

\defineconversion[Questions][\numbers]

\setupitemgroup[Questions][style=bold,
width=1.5em,
packed,
alternative=hanging,
stopper=,
right=)]
\setupitemgroup[Questions][n]

width=1.5em,
packed,
alternative=hanging,
stopper=,
right=)]

\hideblocks[Exoblock]
\hideblocks[Solblock]

\starttext

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\beginExoblock
\startexo Solve the following problems.
\startQuestions

\startitem This is Question 1 of exercise 1. \stopitem

\startitem
This is Question 2 of exercise 1.
\stopitem

\startitem This is Question 3 of exercise 1. An easy question, without answer\dots \stopitem

\stopQuestions
\stopexo
\endExoblock

\beginSolblock
\startsolution We give only solutions to non trivial questions\dots

\startitem This is Answer 1 of exercise 1. \stopitem

\startitem This is Answer 2 of exercise 1. \stopitem

\stopsolution
\endSolblock
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\beginExoblock
\startexo Solve the following problems.
\startQuestions

\startitem This is Question 1 of exercise 2. \stopitem

\startitem
This is Question 2 of exercise 2. An easy question, without answer\dots
\stopitem

\startitem This is Question 3 of exercise 2. \stopitem

\stopQuestions
\stopexo
\endExoblock

\beginSolblock
\startsolution We give only solutions to non trivial questions\dots

\startitem This is Answer 1 of exercise 2. \stopitem

\incrementcounter[Answers] % <———— This does not have any effect
\startitem This is Answer 3 of exercise 2. \stopitem

\stopsolution
\endSolblock
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\chapter{List of Exercises}

\useblocks[Exoblock]

\chapter{List of Solutions}

\useblocks[Solblock]

\stoptext