ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Wolfgang Schuster <schuster.wolfgang@googlemail.com>
To: mailing list for ConTeXt users <ntg-context@ntg.nl>
Subject: Re: Two questions - Cross Referencing (Automated	label generation + Random items)
Date: Wed, 4 Mar 2009 14:26:54 +0100	[thread overview]
Message-ID: <567CE7CB-9D51-4180-9B30-2AE8CFCB9CA2@gmail.com> (raw)
In-Reply-To: <loom.20090304T124518-844@post.gmane.org>


Am 04.03.2009 um 13:54 schrieb Curious Learn:

> Awesome solution. Works great. Thanks very much Wolfgang. I can now  
> use your
> solution. If it is not too difficult to explain, I would appreciate  
> if someone
> could explain why the following does not work. It is not necessary  
> because
> Wolfgang's solution is great but will help me understand it better.
>
> \def\AnsT
>   {\doglobal\increment\choicecounter
>     \startitem[\choicecounter]#1\stopitem}
> \def\eAns{\stopitem}
>
> With these commands if I use
>
> \AnsT This is the CORRECT answer. \eAns
> \startwrongitem Yet another wrong answer.   \stopwrongitem
>
> I get the error "File ended while scanning use of \startitem"

It has to do with the that for randomized items ConTeXt has to know
the text for each item, to do this the normal \item ... is not enough
and \startitem ... \stopitem is needed.

Each \startitem ... \stopitem pair collects the text between it and
add it to a list. The collecting works in the way that \startitem grab
everything untill it sees a \stopitem command.

If you want to write your own command you need a similiar mechanism
where your \AnsT grab everything till \eAns but this did not work in
the way you defined the command yourself.

The low level way to do this is:

\def\AnsT#1\eAns
   {\doglobal\increment\choicecounter
    \startitem[\choicecounter]#1\stopitem}


Another way to do this with a few ConTeXt commands is:

\define[1]\Rightitem
   {\doglobal\increment\choicecounter
    \startitem[\choicecounter]#1\stopitem}

\define\AnsT
   {\grabuntil{eAns}\Rightitem}

Wolfgang

___________________________________________________________________________________
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  : https://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


  reply	other threads:[~2009-03-04 13:26 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-03-03 13:17 Curious Learn
2009-03-03 23:37 ` Wolfgang Schuster
2009-03-04 12:54   ` Curious Learn
2009-03-04 13:26     ` Wolfgang Schuster [this message]
2009-03-04 15:53       ` Curious Learn
2009-03-04 16:04         ` Mikael Persson
2009-03-04 16:23           ` pst-labo a pstricks module batela
2009-03-07  9:44             ` Wolfgang Schuster
2009-03-04 17:10           ` Two questions - Cross Referencing (Automated label generation + Random items) Curious Learn
2009-03-04 14:01     ` 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=567CE7CB-9D51-4180-9B30-2AE8CFCB9CA2@gmail.com \
    --to=schuster.wolfgang@googlemail.com \
    --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).