[NTG-context] Defining commands in \start ... \stop

Wolfgang Schuster schuster.wolfgang at gmail.com
Sun Mar 30 19:29:49 CEST 2014


Am 30.03.2014 um 19:28 schrieb Xan <dxpublica at telefonica.net>:

> This:
> 
> \defineblock[question]
> \defineblock[answer]
> 
> \defineenumeration[question][text={Question}]
> \defineenumeration[answer]  [text={Answer}]
> 
> \keepblocks[question]
> \hideblocks[answer]
> 
> 
> \def\mynewcommand{\dosingleempty\doMyNewCommand}
> \def\doMyNewCommand[#1]#2{%
> \iffirstargument
>     \beginquestion
>       \startquestion #2%
>       \stopquestion
>     \endquestion
>       \beginanswer \startanswer #1%
>       \stopanswer \endanswer
> \else
>     \beginquestion
>       \startquestion #2%
>       \stopquestion
>     \endquestion
>       \incrementcounter[answer]
> \fi
> }
> 
> 
> \starttext
> 
> \chapter{Question}
> 
> \beginquestion
> 	\startquestion
> 		Question 1.
> 	\stopquestion
> \endquestion
> 
> \beginanswer
> 	\startanswer
> 		Answer 1.
> 	\stopanswer
> \endanswer
> 
> \beginquestion
> 	\startquestion
> 		Question 2.
> 	\stopquestion
> \endquestion
> 
> \beginanswer
> 	\incrementcounter[answer]
> \endanswer
> 
> \beginquestion
> 	\startquestion
> 		Question 3.
> 	\stopquestion
> \endquestion
> 
> \beginanswer
> 	\startanswer
> 		Answer 3.
> 	\stopanswer
> \endanswer
> 
> \mynewcommand{Question 5}
> 
> \mynewcommand[Resposta 6]{Question 6}
> 
> \chapter{Answers}
> 
> \useblocks[answer]
> 
> \stoptext
> 
> does not work

The block commands use a buffer to store the content and buffers can’t be used in commands.

Wolfgang



More information about the ntg-context mailing list