ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: "Thomas Schmitz" <tschmit1@uni-bonn.de>
To: mailing list for ConTeXt users <ntg-context@ntg.nl>
Subject: Re: mkiv: append to buffer
Date: Sun, 19 Dec 2010 12:28:58 +0100	[thread overview]
Message-ID: <web-6056380@be2.uni-bonn.de> (raw)
In-Reply-To: <0458BC42-65A5-439F-9562-3724C924A585@gmail.com>

On Sat, 18 Dec 2010 19:35:53 +0100
  Wolfgang Schuster <schuster.wolfgang@googlemail.com> 
wrote:
> 
> 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
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


  reply	other threads:[~2010-12-19 11:28 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-12-18 15:51 Thomas Schmitz
2010-12-18 16:52 ` Aditya Mahajan
2010-12-18 18:35   ` Wolfgang Schuster
2010-12-19 11:28     ` Thomas Schmitz [this message]
2010-12-19 12:21       ` Peter Münster
2010-12-19 12:47         ` Thomas Schmitz
2010-12-19 14:19           ` Thomas Schmitz
2010-12-20  7:11           ` Peter Münster
2010-12-19 21:30       ` Hans Hagen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=web-6056380@be2.uni-bonn.de \
    --to=tschmit1@uni-bonn.de \
    --cc=ntg-context@ntg.nl \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).