[NTG-context] Get "right" numbers using blocks and enumerations

Wolfgang Schuster schuster.wolfgang at gmail.com
Tue Sep 6 21:29:53 CEST 2016


> Mikael P. Sundqvist <mailto:mickep at gmail.com>
> 1. September 2016 um 21:18
> Hi,
>
> I'm trying to use blocks for answers in a text, but cannot get the
> numbering to work as I want. I have read about \processblocks at the
> wiki (http://wiki.contextgarden.net/Command/processblocks), but I'm
> not sure that is my cure. I probably miss something easy...
>
> The problem is probably easiest shown by an example:
>
> %%%
> \defineblock[A]
> \hideblocks[A]
>
> \defineenumeration[A][
> text=A,
> prefix=yes,
> prefixsegments=chapter,
> way=bychapter,
> ]
>
> \starttext
>
> \chapter{First chapter}
>
> \beginA
> \startA
> My first answer in the first chapter.
> \stopA
> \endA
>
> \beginA
> \startA
> My second answer in the first chapter.
> \stopA
> \endA
>
>
> \chapter{Second chapter}
>
> \beginA
> \startA
> My first answer in the second chapter.
> \stopA
> \endA
>
> \beginA
> \startA
> My second answer in the second chapter.
> \stopA
> \endA
>
> \chapter{Answers}
> \useblocks[A]
> \stoptext
> %%%
>
> I get, in the Answer chapter
>
> A 3.1, A 3.2, A 3.3 and A 3.4.
>
> What I want to have in the answer chapter is
>
> A 1.1, A 1.2, A 2.1 and A 2.2.
>
> (to follow the numbering in the chapters where the blocks were defined).
>
> Is it possible? What have I missed?
Blocks only store their content without expanding counters etc. and when
you flush them you have the same result as putting them into the appendices
by hand.
> Related: Is there a better way to set answers to questions? (Perhaps
> not having to write both the \begin... \start... \stop... \end... for
> every question?
\setupblock[A][before=\startA,after=\stopA]

but you can’t use the optional argument for a enumerations anymore (e.g. 
to set a title) with this method.

Wolfgang
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ntg.nl/pipermail/ntg-context/attachments/20160906/e2eca239/attachment-0001.html>


More information about the ntg-context mailing list