On Sat, 18 Dec 2010 19:35:53 +0100
Wolfgang Schuster
Am 18.12.2010 um 17:52 schrieb Aditya Mahajan:
I am not sure what you want to do, and why you want to use buffers. Wont a simple token list work?
I can only agree with this, token lists are the easiest solution but the new cld manuals mentions the “context.tobuffer” function which allows one to add content to a buffer.
Wolfgang
Aditya, Wolfgang, thanks for your replies. I didn't want to bore the list with lengthy explanations, but maybe I didn't give enough information. So here comes what I hope are the relevant bits: I'm typesetting sheets with problems and solutions for a class. Those come from an xml database. Unfortunately, there is one catch: depending on the type of the problem, some problems don't have an explicit solution. The problems are typeset as a numbered itemization on page 1; on page 2, I want the solutions, with matching numbers. And since I'm lazy, I don't want to take care of this myself but have context do it for me. So let's begin with the output. I want: PROBLEMS 1. problem without solution 2. problem with solution 3. problem without solution 4. problem with solution and then, on a new page: SOLUTIONS 2. solution to 2 4. solution to 4 So: I have been trying to write a macro that will retrieve problems from the database (successful, with help by Hans), pack them in an itemize list (successful), and store the solution somewhere so it can be typeset on the next page (unsuccessful as yet). I thought buffers were the natural way to go, but I must admit I didn't know about tokenlists. Aditya's suggestion unfortunately doesn't seem to work with itemizations. Test files: This works: \newtoks\mytoks \def\TestMacro#1#2#3% {\color[darkred]{#1} \color[darkblue]{#2}\endgraf \appendtoks \color[darkgreen]{#3} \to\mytoks} \starttext \TestMacro{A}{B}{C} \TestMacro{X}{Y}{Z} \hairline \the\mytoks and this doesn't: \newtoks\mytoks \def\TestMacro#1#2#3% {\item[#1] #2\par \appendtoks \in[#1]: {#3} \to\mytoks} \starttext \startitemize[n] \TestMacro{A}{B}{C} \TestMacro{X}{Y}{Z} \stopitemize \hairline \the\mytoks I have absolutely no preference for buffers or itemizations or whatever, so if there's a better solution, I'm all open. But for the time being, I don't get what I want. I'll look into "context.tobuffer" next... Thanks for any suggestions, and best wishes Thomas