# [NTG-context] Fwd: Question and Answer Iteration

Jeroen contextntg at gmail.com
Wed Mar 13 13:37:09 CET 2019

```This worked very well, thanks. I now want at the end of each chapter some
questions with the chapter number in the follow-up number, and then at the
end of the document a separate chapter with the answers with matching
numbers. In general for a single QA section this works, but now I start
distributing it over a number of chapters, the question and answer
numbering seems to be an issue. Would the define require a change?

\define[1]\QuestionTextCommand
{\doglobal\increment\QuestionCounter
\pagereference[question:\QuestionCounter]%
{#1}}

{#1}}

\defineenumeration
[question]
[text={\black Question},
titledistance=2em,
width=fit,
distance=0.5em,
number=yes,
prefix=yes,
prefixsegments=chapter,
alternative=serried,

\defineenumeration
width=fit,
distance=0.5em,
number=yes,
prefix=yes,
prefixsegments=chapter,
alternative=serried,

% END SETUP

\starttext

\chapter{Chap1}

\section{End of Chapter Questions}

\startquestion Question 1 \stopquestion
\startquestion Question 2 \stopquestion

\chapter{Chap2}

\section{End of Chapter Questions}

\startquestion Question 1 \stopquestion
\startquestion Question 2 \stopquestion

\stoptext

I have it working with a single chapter:

\define[1]\QuestionTextCommand
{\doglobal\increment\QuestionCounter
\pagereference[question:\QuestionCounter]%
{#1}}

{#1}}

\defineenumeration
[question]
[text={\black Question},
titledistance=2em,
width=fit,
distance=0.5em,
number=yes,
prefix=yes,
prefixsegments=chapter,
alternative=serried,

\defineenumeration
width=fit,
distance=0.5em,
number=yes,
prefix=yes,
prefixsegments=chapter,
alternative=serried,

% END SETUP

\starttext

\chapter{Chap1}

\section{End of Chapter Questions}

\startquestion Question 1 \stopquestion