ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* counter in ConTeXt
@ 2006-12-14 18:07 Michael
  2006-12-15  8:42 ` Aditya Mahajan
  0 siblings, 1 reply; 2+ messages in thread
From: Michael @ 2006-12-14 18:07 UTC (permalink / raw)



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?

Thanks,

Michael

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: counter in ConTeXt
  2006-12-14 18:07 counter in ConTeXt Michael
@ 2006-12-15  8:42 ` Aditya Mahajan
  0 siblings, 0 replies; 2+ messages in thread
From: Aditya Mahajan @ 2006-12-15  8:42 UTC (permalink / raw)


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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2006-12-15  8:42 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-12-14 18:07 counter in ConTeXt Michael
2006-12-15  8:42 ` Aditya Mahajan

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).