ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Aditya Mahajan <adityam@umich.edu>
Subject: Re: store counter or variable and reread again
Date: Sun, 31 Dec 2006 12:52:07 -0500 (EST)	[thread overview]
Message-ID: <alpine.WNT.0.81.0612311248120.3728@nqvgln> (raw)
In-Reply-To: <459772F9.8070501@gmx.net>

On Sun, 31 Dec 2006, Thomas Engel wrote:

> Aditya Mahajan wrote:
> 
> > \unprotect
> > \def\addtocounter#1#2% #1 name #2 value
> >
> {\@EA\xdef\csname#1\endcsname{\the\numexpr\csname#1\endcsname+#2\relax}}
> > \protect
> >
> > % To Hans and Taco: Should the above macro be added to syst-ext?
> >
> > % Now lets define everything in terms of ConTeXt's counter macros
> >
> > \makecounter{Points}
> >
> > % %   show the points on the right side
> > \def\showP[#1]{\inright{\hskip 10mm \framed{#1} }}
> >
> > \def\pkt[#1]%
> >      {\showP[#1]%
> >       \addtocounter{Points}{#1}}
> > %
> >
> > \def\nofPoints{0} % Number of points from previous run
> >
> > \def\savenofPoints
> >    {\savecurrentvalue\nofPoints{\countervalue{Points}}}
> >
> > % It is a bit boring to type \savenofPoints everytime
> >
> > \appendtoks \savenofPoints \to \everystoptext
> >
> Thanks for your help. It's great!
> 
> What I recognized is when I put this on layer for better placement of
> the header it doesn't work.
> Here is an example:
> 
> \def\Schulaufgabekopf%
>   {\bf \tfa
>       \setupTABLE[option=stretch]
>       \setupTABLE[frame=off]
>       \setupTABLE[column][1][width=0.7\textwidth]
>       \setupTABLE[column][2][width=0.3\textwidth]
> 
> \setupTABLE[row][2,3,4][background=color,backgroundcolor=gray,frame=off]
>       \setupTABLE[row][5][height=1cm]
>       \bTABLE
>       \bTR \bTD \strut \eTD \bTD \strut \eTD \eTR
>       \bTR \bTD \AAnr \eTD \bTD Date: \eTD \eTR
>       \bTR \bTD  Name:    \eTD \bTD Points: \hfill of \nofPoints \eTD\eTR
>       \bTR \bTD  Form: \Klnr   \eTD \bTD Mark: \eTD \eTR
>       \bTR \bTD [nc=3, align=low] \tfxx   Unterschrift eines
> Erziehungsberechtigten: \thinrule \eTD \eTR
>       \eTABLE}
> 
> \definelayer[kopf][width=\paperwidth, height=\paperheight]
> 
> %Klassenarbeiten Kopf
> \def\AAnr{2. Schulaufgabe Englisch 2006/2007}
> \def\Klnr{10 \hfill}
> %\definelogo[SAK] [top][left][command=\Schulaufgabekopf]
> %\placelogos[SAK]
> 
> 
> \setlayer[kopf][x=1.9cm, y=1cm]{\Schulaufgabekopf}

Change this line to

\appendtoks \setlayer[kopf][x=1.9cm, y=1cm]{\Schulaufgabekopf} \to 
\everystarttext

or

\appendtoks \setlayer[kopf][x=1.9cm, y=1cm]{\Schulaufgabekopf} \to 
\everyafterutilityread

> \setupbackgrounds[page][background=kopf]
> \starttext
> 
> % Lets set 10 problems with different points
> \dorecurse{10}
>    {\pkt[\recurselevel] \input tufte \endgraf}
> 
> \stoptext
> 
> What's going wrong?

The layer kopf is being set before the tui file is read. So, the value 
of \nofPoints is still 0. You need to set this layer after the 
utility file is read by appending the code to \everyafterutilityread 
or to \everystarttext (which happens after reading utility file).

Aditya

  reply	other threads:[~2006-12-31 17:52 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <45941026$0$4168$ba624c82@nntp02.dk.telia.net>
2006-12-30 14:00 ` Week number Taco Hoekwater
2006-12-30 15:51   ` store counter or variable and reread again Thomas Engel
2006-12-30 16:56     ` Aditya Mahajan
2006-12-30 19:19       ` Peter Münster
2006-12-30 21:30         ` Aditya Mahajan
2006-12-30 22:35           ` Hans Hagen
2006-12-30 23:19             ` Aditya Mahajan
2006-12-30 23:51               ` Aditya Mahajan
2006-12-31  8:21                 ` Thomas Engel
2006-12-31 17:52                   ` Aditya Mahajan [this message]
2007-01-01 22:28                 ` Hans Hagen
2007-01-01  8:11               ` Peter Münster
2007-01-01 11:17                 ` Aditya Mahajan
2007-01-01 15:35                   ` Peter Münster
2007-01-01 22:14                     ` Hans Hagen
2007-01-02 18:38                       ` Peter Münster
2007-01-04 16:43                         ` Hans Hagen
2006-12-30 21:34   ` Week number Aditya Mahajan
2006-12-30 22:28     ` 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=alpine.WNT.0.81.0612311248120.3728@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).