ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Aditya Mahajan <adityam@umich.edu>
Subject: Re: counter in ConTeXt
Date: Fri, 15 Dec 2006 03:42:54 -0500 (EST)	[thread overview]
Message-ID: <Pine.WNT.4.63.0612150340171.2916@nqvgln> (raw)
In-Reply-To: <ahodq6gxlf.fsf@bass.biostat.umn.edu>

On Thu, 14 Dec 2006, Michael wrote:

>
> How do I use counter in ConTeXt?
>
> Specifically, I use this to define '\startproblem\stopproblem'.
>
> \defineenumeration[problem][location=top,text=Problem,%
>        between=\blank,before=\blank,after=\page]
>
> I want to say \totalnumberofproblems, in the beginning of the exam, like
> \totalnumberofpages.  How do I do that?

You need to have a two pass mechanism for this. Save the number of 
problems in the tui/tuo file in the first run and read the 
corresponding values from the file in the second run. Here is a simple 
example

\defineenumeration[problem][location=top,text=Problem,%
          between=\blank,before=\blank]

\def\nofproblems{0}

\definetwopasslist  {problems}

\def\checkproblems
   {\gettwopassdata{problems}
   \iftwopassdatafound
     \xdef \nofproblems {\twopassdata}
   \fi
   \global\let\checkproblems\relax}

\starttext

\checkproblems

This paper has \nofproblems\ Problems.

\dorecurse{10}
{\startproblem test \stopproblem}

\savetwopassdata  {problems}  {\nofproblems} {\getnumber[problem]}

\stoptext



HTH,
Aditya

      reply	other threads:[~2006-12-15  8:42 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-12-14 18:07 Michael
2006-12-15  8:42 ` Aditya Mahajan [this message]

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=Pine.WNT.4.63.0612150340171.2916@nqvgln \
    --to=adityam@umich.edu \
    --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).