* Re: Week number
[not found] <45941026$0$4168$ba624c82@nntp02.dk.telia.net>
@ 2006-12-30 14:00 ` Taco Hoekwater
2006-12-30 15:51 ` store counter or variable and reread again Thomas Engel
2006-12-30 21:34 ` Week number Aditya Mahajan
0 siblings, 2 replies; 19+ messages in thread
From: Taco Hoekwater @ 2006-12-30 14:00 UTC (permalink / raw)
Hi all,
I just posted this (the result of a rainy morning in Dordrecht, NL)
to comp.text.tex. Someone here might be interested as well.
Best, Taco
-------------
Mads Munch Hansen wrote:
> Hi all, and merry Christmas :)
>
> Is there a way to have LaTeX print the current week number, like the
> \date command?
I was feeling a bit bored today, so I came up with this. It is a
plain e-TeX input file instead of a LaTeX package, but it should
run without problems.
Watch out: Dec 29 can be week 1 of the next year; and Jan 3 can be
week 53 of the previous year.
Best wishes, Taco
%% calendarweek.tex
%% 2006 (C) Taco Hoekwater, public domain
%%
%% Usage:
%% \calendarweek{30}{12}{2006}
%%
\def\Expr#1{\the\numexpr #1\relax}
\def\Modulonumber#1#2{\Expr{#2-((((#2+(#1/2))/#1)-1)*#1)}}
\def\Divisionnumber#1#2{\Expr{(2*#2-#1)/(2*#1)}}
\def\Mod#1#2{\Modulonumber{\Expr{#2}}{\Expr{#1}}}
\def\Div#1#2{\Divisionnumber{\Expr{#2}}{\Expr{#1}}}
\def\Jday#1#2#3%
{\Expr{#1+\Div{((153*(\Expr{#2+(12*(\Div{14-#2}{12}))-3}))+2)}
{5}+365*(\Expr{#3+4800-(\Div{14-#2}{12})})+
(\Div{\Expr{#3+4800-(\Div{14-#2}{12})}}{4})-
(\Div{\Expr{#3+4800-(\Div{14-#2}{12})}}{100})+
(\Div{\Expr{#3+4800-(\Div{14-#2}{12})}}{400})-32045 }}
\def\cwhlp#1#2#3%
{\Expr{\Mod {\Mod {\Mod {\Expr
{\Jday{#1}{#2}{#3}+31741-\Mod{\Jday{#1}{#2}{#3}}{7}}}%
{146097}}{36524}}{1461}}}
\def\calendarweek#1#2#3%
{\Expr{\Expr{\Div{\Expr{\Mod{\cwhlp{#1}{#2}{#3}-
\Expr{\Div{\cwhlp{#1}{#2}{#3}}{1460}}}{365}+
\Expr{\Div{\cwhlp{#1}{#2}{#3}}{1460}}}}{7} +1}}}
\endinput
^ permalink raw reply [flat|nested] 19+ messages in thread
* store counter or variable and reread again
2006-12-30 14:00 ` Week number Taco Hoekwater
@ 2006-12-30 15:51 ` Thomas Engel
2006-12-30 16:56 ` Aditya Mahajan
2006-12-30 21:34 ` Week number Aditya Mahajan
1 sibling, 1 reply; 19+ messages in thread
From: Thomas Engel @ 2006-12-30 15:51 UTC (permalink / raw)
Hello,
i just playing a little bit with macros.
For adding points to a total sum i use this macros
\global\newcount\summeP \summeP=0
% ad the points of each question
\def\getPunkte[#1]{\global\advance\summeP by \number#1}
% show the points on the right side
\def\showP[#1]{\inright{\hskip 10mm \framed{#1} }}
% handle the points
\def\pkt[#1]%
{\showP[#1]%
\getPunkte[#1] }
this is working well but my problem is I want to use \summeP on the
first page to show the total amount of points for the whole exam.
I know that this needs a second run of texexec, but I don't know how to
store the value at the end of the file and reread this stored value in a
second run the get the right value.
Any hints are welcome!
Thanks and a Happy New Year!
Thomas
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: store counter or variable and reread again
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
0 siblings, 1 reply; 19+ messages in thread
From: Aditya Mahajan @ 2006-12-30 16:56 UTC (permalink / raw)
On Sat, 30 Dec 2006, Thomas Engel wrote:
> Hello,
>
> i just playing a little bit with macros.
> For adding points to a total sum i use this macros
>
> \global\newcount\summeP \summeP=0
> % ad the points of each question
> \def\getPunkte[#1]{\global\advance\summeP by \number#1}
> % show the points on the right side
> \def\showP[#1]{\inright{\hskip 10mm \framed{#1} }}
> % handle the points
> \def\pkt[#1]%
> {\showP[#1]%
> \getPunkte[#1] }
>
> this is working well but my problem is I want to use \summeP on the
> first page to show the total amount of points for the whole exam.
>
> I know that this needs a second run of texexec, but I don't know how to
> store the value at the end of the file and reread this stored value in a
> second run the get the right value.
Here is how to do the second run. I also use ConTeXt macros
(\makecounter etc) instead of plain TeX. Be careful of spurious
linebreaks.
% It may be better to use \setcounter series of macros for managing counters.
% First let us define a general macro for adding arbitrary number to a counter
\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
% \global\newcount\summeP
\makecounter{Points}
% I changed summeP to Points just to be consistent
% \summeP=0
% \makecounter sets the value of counter to 0.
% % ad the points of each question
% \def\getPunkte[#1]{\global\advance\summeP by \number#1}
% This macro is already been defined using numexpr above.
% % show the points on the right side
\def\showP[#1]{\inright{\hskip 10mm \framed{#1} }}
% % handle the points
\def\pkt[#1]%
{\showP[#1]%
% \getPunkte[#1] }
\addtocounter{Points}{#1}}
%
% Now lets set up the two pass mechanism
\def\nofPoints{0} % Number of points from previous run
\definetwopasslist {Points} % variable where two pass data is stored
% Need to execute this at the start of each file
\def\checkPoints
{\gettwopassdata{Points} % Retreive the two pass data
\iftwopassdatafound
\xdef \nofPoints {\twopassdata}
\fi
\global\let\checkproblems\relax}
% An example usage
\starttext
\checkPoints
\title{This exam is of \nofPoints\ Points}
% Lets set 10 problems with different points
\dorecurse{10}
{\pkt[\recurselevel] \input tufte \endgraf}
% Now the rest of the magic to take care of the two pass run
% Basically this says that rerun if \nofPoints !=
% \countervalue{Points}. In the next run we set \nofPoints to the
% previous value of \countervalue{Points} (the \checkPoints macro in
% the beginning), so things should be stable after two runs.
\savetwopassdata {Points} {\nofPoints} {\countervalue{Points}}
\stoptext
HTH,
Aditya
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: store counter or variable and reread again
2006-12-30 16:56 ` Aditya Mahajan
@ 2006-12-30 19:19 ` Peter Münster
2006-12-30 21:30 ` Aditya Mahajan
0 siblings, 1 reply; 19+ messages in thread
From: Peter Münster @ 2006-12-30 19:19 UTC (permalink / raw)
On Sat, 30 Dec 2006, Aditya Mahajan wrote:
> % Now the rest of the magic to take care of the two pass run
> % Basically this says that rerun if \nofPoints !=
> % \countervalue{Points}. In the next run we set \nofPoints to the
> % previous value of \countervalue{Points} (the \checkPoints macro in
> % the beginning), so things should be stable after two runs.
> \savetwopassdata {Points} {\nofPoints} {\countervalue{Points}}
Hello Aditya,
with the following example, I get always 2 runs:
\definetwopasslist{test}
\starttext
bla
\savetwopassdata{test}{1}{2}
\stoptext
Is this normal or a bug?
Cheers, Peter
--
http://pmrb.free.fr/contact/
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: store counter or variable and reread again
2006-12-30 19:19 ` Peter Münster
@ 2006-12-30 21:30 ` Aditya Mahajan
2006-12-30 22:35 ` Hans Hagen
0 siblings, 1 reply; 19+ messages in thread
From: Aditya Mahajan @ 2006-12-30 21:30 UTC (permalink / raw)
On Sat, 30 Dec 2006, Peter Münster wrote:
> On Sat, 30 Dec 2006, Aditya Mahajan wrote:
>
> > % Now the rest of the magic to take care of the two pass run
> > % Basically this says that rerun if \nofPoints !=
> > % \countervalue{Points}. In the next run we set \nofPoints to the
> > % previous value of \countervalue{Points} (the \checkPoints macro in
> > % the beginning), so things should be stable after two runs.
> > \savetwopassdata {Points} {\nofPoints} {\countervalue{Points}}
>
> Hello Aditya,
>
> with the following example, I get always 2 runs:
>
> \definetwopasslist{test}
> \starttext
> bla
> \savetwopassdata{test}{1}{2}
> \stoptext
>
> Is this normal or a bug?
Hmm... I would have guessed that you will keep on getting infinite
runs, but apparently texexec decides that two are enough. I need to
look deeper to see if this is the intended behaviour. I would call it
a bug, since there can be cases which need more than two runs to
converge.
Aditya
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: Week number
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 21:34 ` Aditya Mahajan
2006-12-30 22:28 ` Hans Hagen
1 sibling, 1 reply; 19+ messages in thread
From: Aditya Mahajan @ 2006-12-30 21:34 UTC (permalink / raw)
On Sat, 30 Dec 2006, Taco Hoekwater wrote:
>
> Hi all,
>
>
> I just posted this (the result of a rainy morning in Dordrecht, NL)
> to comp.text.tex. Someone here might be interested as well.
>
> [...]
>
> I was feeling a bit bored today, so I came up with this. It is a
> plain e-TeX input file instead of a LaTeX package, but it should
> run without problems.
If you are still bored, how about adding this to ConTeXt, so that one
can say
Today is \currentdate[weekday] of the \currentdate[week] week of
\currentday[year]
I do not know if someone will find it useful or not, but it seems like
a nice feature to have :)
Aditya
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: Week number
2006-12-30 21:34 ` Week number Aditya Mahajan
@ 2006-12-30 22:28 ` Hans Hagen
0 siblings, 0 replies; 19+ messages in thread
From: Hans Hagen @ 2006-12-30 22:28 UTC (permalink / raw)
Aditya Mahajan wrote:
> On Sat, 30 Dec 2006, Taco Hoekwater wrote:
>
>
>> Hi all,
>>
>>
>> I just posted this (the result of a rainy morning in Dordrecht, NL)
>> to comp.text.tex. Someone here might be interested as well.
>>
>> [...]
>>
>> I was feeling a bit bored today, so I came up with this. It is a
>> plain e-TeX input file instead of a LaTeX package, but it should
>> run without problems.
>>
>
> If you are still bored, how about adding this to ConTeXt, so that one
> can say
>
> Today is \currentdate[weekday] of the \currentdate[week] week of
> \currentday[year]
>
> I do not know if someone will find it useful or not, but it seems like
> a nice feature to have :)
>
see core-con.tex, such things have been there for years now -)
(not sure if it does the same as what taco code does)
Hans
-----------------------------------------------------------------
Hans Hagen | PRAGMA ADE
Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com
| www.pragma-pod.nl
-----------------------------------------------------------------
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: store counter or variable and reread again
2006-12-30 21:30 ` Aditya Mahajan
@ 2006-12-30 22:35 ` Hans Hagen
2006-12-30 23:19 ` Aditya Mahajan
0 siblings, 1 reply; 19+ messages in thread
From: Hans Hagen @ 2006-12-30 22:35 UTC (permalink / raw)
Aditya Mahajan wrote:
> On Sat, 30 Dec 2006, Peter M�nster wrote:
>
>
>> On Sat, 30 Dec 2006, Aditya Mahajan wrote:
>>
>>
>>> % Now the rest of the magic to take care of the two pass run
>>> % Basically this says that rerun if \nofPoints !=
>>> % \countervalue{Points}. In the next run we set \nofPoints to the
>>> % previous value of \countervalue{Points} (the \checkPoints macro in
>>> % the beginning), so things should be stable after two runs.
>>> \savetwopassdata {Points} {\nofPoints} {\countervalue{Points}}
>>>
>> Hello Aditya,
>>
>> with the following example, I get always 2 runs:
>>
>> \definetwopasslist{test}
>> \starttext
>> bla
>> \savetwopassdata{test}{1}{2}
>> \stoptext
>>
>> Is this normal or a bug?
>>
>
> Hmm... I would have guessed that you will keep on getting infinite
> runs, but apparently texexec decides that two are enough. I need to
> look deeper to see if this is the intended behaviour. I would call it
> a bug, since there can be cases which need more than two runs to
> converge.
>
>
how about
\savecurrentvalue\SomeVar{someval}
--
-----------------------------------------------------------------
Hans Hagen | PRAGMA ADE
Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com
| www.pragma-pod.nl
-----------------------------------------------------------------
_______________________________________________
ntg-context mailing list
ntg-context@ntg.nl
http://www.ntg.nl/mailman/listinfo/ntg-context
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: store counter or variable and reread again
2006-12-30 22:35 ` Hans Hagen
@ 2006-12-30 23:19 ` Aditya Mahajan
2006-12-30 23:51 ` Aditya Mahajan
2007-01-01 8:11 ` Peter Münster
0 siblings, 2 replies; 19+ messages in thread
From: Aditya Mahajan @ 2006-12-30 23:19 UTC (permalink / raw)
On Sat, 30 Dec 2006, Hans Hagen wrote:
> Aditya Mahajan wrote:
> > On Sat, 30 Dec 2006, Peter M???nster wrote:
> >
> >
> >> On Sat, 30 Dec 2006, Aditya Mahajan wrote:
> >>
> >>
> >>> % Now the rest of the magic to take care of the two pass run
> >>> % Basically this says that rerun if \nofPoints !=
> >>> % \countervalue{Points}. In the next run we set \nofPoints to the
> >>> % previous value of \countervalue{Points} (the \checkPoints macro in
> >>> % the beginning), so things should be stable after two runs.
> >>> \savetwopassdata {Points} {\nofPoints} {\countervalue{Points}}
> >>>
> >> Hello Aditya,
> >>
> >> with the following example, I get always 2 runs:
> >>
> >> \definetwopasslist{test}
> >> \starttext
> >> bla
> >> \savetwopassdata{test}{1}{2}
> >> \stoptext
> >>
> >> Is this normal or a bug?
> >>
> >
> > Hmm... I would have guessed that you will keep on getting infinite
> > runs, but apparently texexec decides that two are enough. I need to
> > look deeper to see if this is the intended behaviour. I would call it
> > a bug, since there can be cases which need more than two runs to
> > converge.
> >
> >
> how about
>
> \savecurrentvalue\SomeVar{someval}
I was just copying the way it is done with other macros \lastpage,
etc. I will look at \savecurrentvalue also. However, something seems
to be wrong in tex.rb
Change
def processfile
....
while ! stoprunning && (texruns < nofruns) && ok do
....
end
...
end
to
def processfile
....
while ! stoprunning && (texruns < nofruns) && ok do
....
report("stoprunning #{stoprunning}")
report("texruns=#{texruns}, nofruns=#{nofruns}")
report("ok=#{ok}")
report("while=#{! stoprunning && (texruns < nofruns) && ok}")
end
...
end
so that we can see what takes us out of the while loop.
Take Petar's test file and run it through texexec. I get
TeXExec | stoprunning true
TeXExec | texruns=2, nofruns=8
TeXExec | ok=counter.tex
TeXExec | while=counter.tex
Notice that ok=\jobname. Shouldn't ok be a boolean. And the condition
for while is a string rather than a boolean. I am not too sure on what
ruby does for non boolean conditionals, but the present implementation
can break (under some crazy conditions, maybe). How about if in
def runtexutil(...)
there is a return ok in the end, for example
begin
logger = Logger.new('TeXUtil')
if tu = TeXUtil::Converter.new(logger) and tu.loaded(fname) then
ok = tu.processed && tu.saved && tu.finalized
end
rescue
Kpse.runscript('texutil',fname,options)
else
return ok #<--------- added.
end
Back to Peter's question, I gave a wrong explaination earlier. texexec
just checks if the tui file has changed. If the file did not change
from the last run, then it stops processing. So with
\savetwopassdata{test}{1}{2}
you will get two runs the first time you process the file, and a
single run if you reprocess the file. By default, the maximum number
of runs that you can have is 8, but you can change this by passing
--runs= to texexec
Aditya
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: store counter or variable and reread again
2006-12-30 23:19 ` Aditya Mahajan
@ 2006-12-30 23:51 ` Aditya Mahajan
2006-12-31 8:21 ` Thomas Engel
2007-01-01 22:28 ` Hans Hagen
2007-01-01 8:11 ` Peter Münster
1 sibling, 2 replies; 19+ messages in thread
From: Aditya Mahajan @ 2006-12-30 23:51 UTC (permalink / raw)
On Sat, 30 Dec 2006, Aditya Mahajan wrote:
> On Sat, 30 Dec 2006, Hans Hagen wrote:
>
> > how about
> >
> > \savecurrentvalue\SomeVar{someval}
>
> I was just copying the way it is done with other macros \lastpage,
> etc. I will look at \savecurrentvalue also.
Ahh, \lastpage uses \savecurrentvalue. I was pretty sure that I copied
the twopass some time back from \lastpage. Maybe I was dreaming, maybe
you are changing the internals too fast for me to keep up. Anyways, to
make ammends, here is the solution using \savecurrentvalue
% It may be better to use \setcounter series of macros.
% First let us define a general macro for adding arbitrary number to a counter
\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
% An example usage
\starttext
\title{This exam is of \nofPoints\ Points}
% Lets set 10 problems with different points
\dorecurse{10}
{\pkt[\recurselevel] \input tufte \endgraf}
\stoptext
The whole things is much shorter :)
Hans, I just noticed that \everystarttext is executed at the start of
components and products, while \everystoptext is not. Does it make
sense to define \stopcomponet and \stopproduct so that \everystoptext
is executed?
Aditya
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: store counter or variable and reread again
2006-12-30 23:51 ` Aditya Mahajan
@ 2006-12-31 8:21 ` Thomas Engel
2006-12-31 17:52 ` Aditya Mahajan
2007-01-01 22:28 ` Hans Hagen
1 sibling, 1 reply; 19+ messages in thread
From: Thomas Engel @ 2006-12-31 8:21 UTC (permalink / raw)
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}
\setupbackgrounds[page][background=kopf]
\starttext
% Lets set 10 problems with different points
\dorecurse{10}
{\pkt[\recurselevel] \input tufte \endgraf}
\stoptext
What's going wrong?
Thomas
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: store counter or variable and reread again
2006-12-31 8:21 ` Thomas Engel
@ 2006-12-31 17:52 ` Aditya Mahajan
0 siblings, 0 replies; 19+ messages in thread
From: Aditya Mahajan @ 2006-12-31 17:52 UTC (permalink / raw)
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
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: store counter or variable and reread again
2006-12-30 23:19 ` Aditya Mahajan
2006-12-30 23:51 ` Aditya Mahajan
@ 2007-01-01 8:11 ` Peter Münster
2007-01-01 11:17 ` Aditya Mahajan
1 sibling, 1 reply; 19+ messages in thread
From: Peter Münster @ 2007-01-01 8:11 UTC (permalink / raw)
On Sat, 30 Dec 2006, Aditya Mahajan wrote:
> you will get two runs the first time you process the file, and a
> single run if you reprocess the file. By default, the maximum number
> of runs that you can have is 8, but you can change this by passing
> --runs= to texexec
Hello,
is it also possible to specify the maximum number of runs in the TeX-file,
for example "\maxruns{11}" ?
Cheers, Peter
--
http://pmrb.free.fr/contact/
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: store counter or variable and reread again
2007-01-01 8:11 ` Peter Münster
@ 2007-01-01 11:17 ` Aditya Mahajan
2007-01-01 15:35 ` Peter Münster
0 siblings, 1 reply; 19+ messages in thread
From: Aditya Mahajan @ 2007-01-01 11:17 UTC (permalink / raw)
On Mon, 1 Jan 2007, Peter Münster wrote:
> On Sat, 30 Dec 2006, Aditya Mahajan wrote:
>
> > you will get two runs the first time you process the file, and a
> > single run if you reprocess the file. By default, the maximum number
> > of runs that you can have is 8, but you can change this by passing
> > --runs= to texexec
>
> Hello,
> is it also possible to specify the maximum number of runs in the TeX-file,
> for example "\maxruns{11}" ?
AFAIU, no. I have not checked if runs=11 on top of the file is read.
Aditya
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: store counter or variable and reread again
2007-01-01 11:17 ` Aditya Mahajan
@ 2007-01-01 15:35 ` Peter Münster
2007-01-01 22:14 ` Hans Hagen
0 siblings, 1 reply; 19+ messages in thread
From: Peter Münster @ 2007-01-01 15:35 UTC (permalink / raw)
On Mon, 1 Jan 2007, Aditya Mahajan wrote:
> > is it also possible to specify the maximum number of runs in the TeX-file,
> > for example "\maxruns{11}" ?
>
> AFAIU, no. I have not checked if runs=11 on top of the file is read.
No, runs=11 is not read. But anyway, I would need something like
"\maxruns{11}", because I would like to put it in a module, that needs a
lot of runs to converge (vertical spacing adjustment to get a letter where
the last page is filled at least to 30%).
Cheers, Peter
--
http://pmrb.free.fr/contact/
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: store counter or variable and reread again
2007-01-01 15:35 ` Peter Münster
@ 2007-01-01 22:14 ` Hans Hagen
2007-01-02 18:38 ` Peter Münster
0 siblings, 1 reply; 19+ messages in thread
From: Hans Hagen @ 2007-01-01 22:14 UTC (permalink / raw)
[-- Attachment #1: Type: text/plain, Size: 1062 bytes --]
> On Mon, 1 Jan 2007, Aditya Mahajan wrote:
>
>
>>> is it also possible to specify the maximum number of runs in the TeX-file,
>>> for example "\maxruns{11}" ?
>>>
>> AFAIU, no. I have not checked if runs=11 on top of the file is read.
>>
>
> No, runs=11 is not read. But anyway, I would need something like
> "\maxruns{11}", because I would like to put it in a module, that needs a
> lot of runs to converge (vertical spacing adjustment to get a letter where
> the last page is filled at least to 30%).
> Cheers, Peter
>
>
hm, long long ago i played with strategies for this ... the attached
file shows some of this ... food for thought
Hans
-----------------------------------------------------------------
Hans Hagen | PRAGMA ADE
Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com
| www.pragma-pod.nl
-----------------------------------------------------------------
[-- Attachment #2: opti-pag.tex --]
[-- Type: application/x-tex, Size: 2387 bytes --]
[-- Attachment #3: Type: text/plain, Size: 139 bytes --]
_______________________________________________
ntg-context mailing list
ntg-context@ntg.nl
http://www.ntg.nl/mailman/listinfo/ntg-context
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: store counter or variable and reread again
2006-12-30 23:51 ` Aditya Mahajan
2006-12-31 8:21 ` Thomas Engel
@ 2007-01-01 22:28 ` Hans Hagen
1 sibling, 0 replies; 19+ messages in thread
From: Hans Hagen @ 2007-01-01 22:28 UTC (permalink / raw)
Aditya Mahajan wrote:
>
> Ahh, \lastpage uses \savecurrentvalue. I was pretty sure that I copied
> the twopass some time back from \lastpage. Maybe I was dreaming, maybe
> you are changing the internals too fast for me to keep up. Anyways, to
> make ammends, here is the solution using \savecurrentvalue
>
you probably have subpage numbers in the back of your mind since they
use two pass lists
> % It may be better to use \setcounter series of macros.
> % First let us define a general macro for adding arbitrary number to a counter
>
> \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?
>
i've added:
\def\incrementcounter#1#2% #1 name #2 value
{\setxvalue{#1}{\the\numexpr\csname#1\endcsname+#2\relax}}
\def\decrementcounter#1#2% #1 name #2 value
{\setxvalue{#1}{\the\numexpr\csname#1\endcsname-#2\relax}}
(increment is used elsewere too)
> % 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
>
> % An example usage
>
> \starttext
>
> \title{This exam is of \nofPoints\ Points}
>
> % Lets set 10 problems with different points
> \dorecurse{10}
> {\pkt[\recurselevel] \input tufte \endgraf}
>
> \stoptext
>
> The whole things is much shorter :)
>
> Hans, I just noticed that \everystarttext is executed at the start of
> components and products, while \everystoptext is not. Does it make
> sense to define \stopcomponet and \stopproduct so that \everystoptext
> is executed?
>
everystoptext is more tricky and cannot be handled in the nested case; starttext is less tricky ; both are only expanded once
Hans
-----------------------------------------------------------------
Hans Hagen | PRAGMA ADE
Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com
| www.pragma-pod.nl
-----------------------------------------------------------------
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: store counter or variable and reread again
2007-01-01 22:14 ` Hans Hagen
@ 2007-01-02 18:38 ` Peter Münster
2007-01-04 16:43 ` Hans Hagen
0 siblings, 1 reply; 19+ messages in thread
From: Peter Münster @ 2007-01-02 18:38 UTC (permalink / raw)
On Mon, 1 Jan 2007, Hans Hagen wrote:
> hm, long long ago i played with strategies for this ... the attached
> file shows some of this ... food for thought
Thanks Hans, it's quite similar to my old LaTeX letter class option file,
that I would like to port to ConTeXt.
What is the difference between
\savecurrentvalue ...
and
\setstrategyvariable ... ?
It seems, that both are doing what I'm looking for.
Is there somewhere some documentation about
- texexec --optimize
- strategies
- twopassentries
and so on?
Cheers, Peter
--
http://pmrb.free.fr/contact/
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: store counter or variable and reread again
2007-01-02 18:38 ` Peter Münster
@ 2007-01-04 16:43 ` Hans Hagen
0 siblings, 0 replies; 19+ messages in thread
From: Hans Hagen @ 2007-01-04 16:43 UTC (permalink / raw)
� wrote:
> On Mon, 1 Jan 2007, Hans Hagen wrote:
>
>
>> hm, long long ago i played with strategies for this ... the attached
>> file shows some of this ... food for thought
>>
>
> Thanks Hans, it's quite similar to my old LaTeX letter class option file,
> that I would like to port to ConTeXt.
>
> What is the difference between
> \savecurrentvalue ...
>
just saves a value
> and
> \setstrategyvariable ... ?
>
this is a prelude to multi pass optimizations (till criterium met)
> It seems, that both are doing what I'm looking for.
>
> Is there somewhere some documentation about
> - texexec --optimize
> - strategies
> - twopassentries
>
collections of saved data
> and so on?
>
yes ; btw, when you run context mkiv, all that data is no longer in the
tuo file but in a lua table structure, and it's all loaded at the same
time; this drastically speeds up some of the tuo related stuff
Hans
--
-----------------------------------------------------------------
Hans Hagen | PRAGMA ADE
Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com
| www.pragma-pod.nl
-----------------------------------------------------------------
_______________________________________________
ntg-context mailing list
ntg-context@ntg.nl
http://www.ntg.nl/mailman/listinfo/ntg-context
^ permalink raw reply [flat|nested] 19+ messages in thread
end of thread, other threads:[~2007-01-04 16:43 UTC | newest]
Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[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
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
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).