Good evening. How can I include \begin<block> ... \end<block> into a macro? I have defined: \defineblock[question] \defineblock[answer] \defineenumeration[question][location=serried, coupling=answer] \defineenumeration[answer][location=serried, coupling=answer] \hideblocks[answer] I'd like to simplify my code from \beginquestion \startquestion question ... \stopquestion \endquestion \beginanswer \answer answer ... \par \endanswer to \q{question ...}{answer ...} \q begin something like this: \def\q{% \beginquestion \question #1\par \endquestion \beginanswer \answer #2\par \endanswer } But no question/anwer is written into .tub file (only the beginning/end of those blocks). Any hint? Many thanks. Your sincerely Michal Kvasnicka
Michal Kvasnicka wrote:
Good evening.
How can I include \begin<block> ... \end<block> into a macro?
I have defined: \defineblock[question] \defineblock[answer] \defineenumeration[question][location=serried, coupling=answer] \defineenumeration[answer][location=serried, coupling=answer] \hideblocks[answer] I'd like to simplify my code from \beginquestion \startquestion question ... \stopquestion \endquestion \beginanswer \answer answer ... \par \endanswer to \q{question ...}{answer ...} \q begin something like this: \def\q{% \beginquestion \question #1\par \endquestion \beginanswer \answer #2\par \endanswer }
But no question/anwer is written into .tub file (only the beginning/end of those blocks).
you can't do that since buffer and block code works on the main input stream directly (catcode trickery and such) but you can hook things into blocks (before/after keys) \setupblock[question][before=\startquestion,after=\stopquestion] should work (i'm crossing my fingers now) Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com | www.pragma-pod.nl -----------------------------------------------------------------
Good evening. Many thanks for your help. Basicly it works. Problem is that it spoils formatting. Try the following example. The answers defined through block are not serried, while the last one defined directly is. Could it be solved somehow? Many thanks once more. M.K. P.S. Does it mean that blocks cannot be reasonably linked to XML-marks too? % output=pdf \defineenumeration[question] [way=bychapter, coupling=answer, location=serried, text=, distance=0pt, width=broad] \defineenumeration[answer] [way=bychapter, coupling=question, location=serried, text=, distance=0pt, width=broad] \defineblock[question, answer] \hideblocks[answer] \setupblock[question][before=\startquestion,after=\stopquestion] \setupblock[answer][before=\startanswer,after=\stopanswer] \starttext \chapter{Questions} \beginquestion Question one \endquestion \beginanswer Answer one \endanswer \beginquestion Question two \endquestion \beginanswer Answer two \endanswer \chapter{Answers} \reset[question,answer] \useblocks[answer] \startanswer Answer three \stopanswer \stoptext
participants (2)
-
Hans Hagen
-
Michal Kvasnicka