* using headnumber
@ 2006-04-20 14:22 Thomas A. Schmitz
2006-04-20 15:14 ` Peter Rolf
0 siblings, 1 reply; 7+ messages in thread
From: Thomas A. Schmitz @ 2006-04-20 14:22 UTC (permalink / raw)
Hi,
I have a counter which I want to be incremented after every \section
command and reset after every odd \section (don't ask why...). So I
tried this approach:
\setuphead[section]
[command={{{\determineheadnumber[section]}
\ifodd{\currentheadnumber[section]}\resetSlideNumber
\incrementSlideNumber
\else\incrementSlideNumber
\fi}]
But I'm getting errors:
! Missing number, treated as zero.
<to be read again>
{
\@@kosectioncommand ...adnumber [section]}\ifodd {
\currentheadnumber
[sectio...
\doplaceheadnumbertext ...ue {\??ko #1\c!command }
{\dostartattributes {\??ko...
\dodododoconstructhead ...{\finalsectionnumber }}}
\writesection {#1}
{#3}{#4}...
Any pointers?
Thomas
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: using headnumber
2006-04-20 14:22 using headnumber Thomas A. Schmitz
@ 2006-04-20 15:14 ` Peter Rolf
2006-04-20 16:15 ` Thomas A. Schmitz
2006-04-20 16:54 ` Sanjoy Mahajan
0 siblings, 2 replies; 7+ messages in thread
From: Peter Rolf @ 2006-04-20 15:14 UTC (permalink / raw)
Hi Thomas,
Thomas A. Schmitz wrote:
> Hi,
>
> I have a counter which I want to be incremented after every \section
> command and reset after every odd \section (don't ask why...). So I
> tried this approach:
>
> \setuphead[section]
> [command={{{\determineheadnumber[section]}
^^^^
one opening brace too much
If you problem remains, try to add a \expandafter in front of \ifodd.
Sometimes it is also helpful to enclose the number expression by
\numexpr ... \relax (for conversion).
Greets, Peter
> \ifodd{\currentheadnumber[section]}\resetSlideNumber
> \incrementSlideNumber
> \else\incrementSlideNumber
> \fi}]
>
> But I'm getting errors:
>
> ! Missing number, treated as zero.
> <to be read again>
> {
> \@@kosectioncommand ...adnumber [section]}\ifodd {
> \currentheadnumber
> [sectio...
>
> \doplaceheadnumbertext ...ue {\??ko #1\c!command }
>
> {\dostartattributes {\??ko...
>
> \dodododoconstructhead ...{\finalsectionnumber }}}
> \writesection {#1}
> {#3}{#4}...
>
> Any pointers?
>
> Thomas
> _______________________________________________
> ntg-context mailing list
> ntg-context@ntg.nl
> http://www.ntg.nl/mailman/listinfo/ntg-context
>
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: using headnumber
2006-04-20 15:14 ` Peter Rolf
@ 2006-04-20 16:15 ` Thomas A. Schmitz
2006-04-20 17:06 ` Sanjoy Mahajan
2006-04-20 20:44 ` Hans Hagen
2006-04-20 16:54 ` Sanjoy Mahajan
1 sibling, 2 replies; 7+ messages in thread
From: Thomas A. Schmitz @ 2006-04-20 16:15 UTC (permalink / raw)
Hi Peter,
thanks for the help! The additional { must have been a fluke with
copy/paste; wasn't in my file. By sheer stubbornness, I tried until I
found something that works:
command={{\determineheadnumber[section]}\ifodd\currentheadnumber
\resetSlideNumber\incrementSlideNumber \else\incrementSlideNumber \fi}]
So after \determineheadnumber[something], \currentheadnumber appears
to have that value and doesn't take an argument.
Thanks, and best
Thomas
On Apr 20, 2006, at 5:14 PM, Peter Rolf wrote:
> Hi Thomas,
>
> Thomas A. Schmitz wrote:
>> Hi,
>>
>> I have a counter which I want to be incremented after every \section
>> command and reset after every odd \section (don't ask why...). So I
>> tried this approach:
>>
>> \setuphead[section]
>> [command={{{\determineheadnumber[section]}
> ^^^^
> one opening brace too much
>
> If you problem remains, try to add a \expandafter in front of \ifodd.
> Sometimes it is also helpful to enclose the number expression by
> \numexpr ... \relax (for conversion).
>
> Greets, Peter
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: using headnumber
2006-04-20 15:14 ` Peter Rolf
2006-04-20 16:15 ` Thomas A. Schmitz
@ 2006-04-20 16:54 ` Sanjoy Mahajan
1 sibling, 0 replies; 7+ messages in thread
From: Sanjoy Mahajan @ 2006-04-20 16:54 UTC (permalink / raw)
> \determineheadnumber[section]
Thanks for mentioning that command, which I'd been looking for. I
couldn't quite get it to work, but reading the code near its
definition helped me solve another problem. Each chapter has a
section for exercises, and each exercise is a subsection with a short
title (a few words). e.g.
\exercise{Batteries}
What is the cost of energy from a 9V battery? From a wall socket (the
mains)?
I want the exercises to be numbered just by the exercise number
(e.g. 7), not for example 1.6.7 (if the exercises are the 6th section
in chapter 1). Hence this setup:
\definehead[exercise][subsection]
\def\choptwo#1.#2.{}
\def\processtwo#1{\expandafter\choptwo#1\relax}
\setuphead[exercise][style=italic,
numbercommand={\processtwo{\currentheadnumber} \gobbleoneargument}]
If there's an easier way using \determineheadnumber, I'll be happy to
use it instead but the above probably fragile hack works for me.
The more obvious try
\def\choptwo#1.#2.{}
\setuphead[subsection][numbercommand={\expandafter\choptwo}]
produced 200 lines of complaint, starting with:
ERROR: Argument of \choptwo has an extra }.
In the following minimal example of my attempt to use
determineheadnumber, the subsection numbers are missing (instead of
being the chapter number):
\setuphead[subsection]
[numbercommand={\determineheadnumber[chapter] \gobbleoneargument}]
\starttext
\chapter{One}
\section{A1}
hi
\subsection{B1}
hi
\subsection{B2}
hi
\stoptext
>>
>> \setuphead[section]
>> [command={{{\determineheadnumber[section]}
^^^^
> one opening brace too much
That's why I want the editor to insert } for me automatically when I
type { (in the earlier thread about AUCTeX/Emacs).
-Sanjoy
`Never underestimate the evil of which men of power are capable.'
--Bertrand Russell, _War Crimes in Vietnam_, chapter 1.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: using headnumber
2006-04-20 16:15 ` Thomas A. Schmitz
@ 2006-04-20 17:06 ` Sanjoy Mahajan
2006-04-20 20:44 ` Hans Hagen
1 sibling, 0 replies; 7+ messages in thread
From: Sanjoy Mahajan @ 2006-04-20 17:06 UTC (permalink / raw)
> So after \determineheadnumber[something], \currentheadnumber appears
> to have that value and doesn't take an argument.
Thanks, that information answers the question I just sent to the list.
-Sanjoy
`Never underestimate the evil of which men of power are capable.'
--Bertrand Russell, _War Crimes in Vietnam_, chapter 1.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: using headnumber
2006-04-20 16:15 ` Thomas A. Schmitz
2006-04-20 17:06 ` Sanjoy Mahajan
@ 2006-04-20 20:44 ` Hans Hagen
2006-04-20 21:46 ` Thomas A. Schmitz
1 sibling, 1 reply; 7+ messages in thread
From: Hans Hagen @ 2006-04-20 20:44 UTC (permalink / raw)
Thomas A. Schmitz wrote:
> Hi Peter,
>
> thanks for the help! The additional { must have been a fluke with
> copy/paste; wasn't in my file. By sheer stubbornness, I tried until I
> found something that works:
> command={{\determineheadnumber[section]}\ifodd\currentheadnumber
> \resetSlideNumber\incrementSlideNumber \else\incrementSlideNumber \fi}]
>
why not directly use the slidenumber
\def\SlideNumber{1}
command={\ifodd\SlideNumber\gdef\SlideNumber{1}\else\doglobal\increment\SlideNumber\fi}}
command={\ifodd\SlideNumber\gdef\SlideNumber{1}\else\gdef\SlideNumber{2}\fi}}
command={\xdef\SlideNumber{\ifodd\SlideNumber\space1\else2\fi}}
\def\SlideNumber{\ifconditional\OddSlide1\else2\fi}
command=\ifodd\settrue\OddSlide\else\setfalse\OddSlide\fi
etc etc
> So after \determineheadnumber[something], \currentheadnumber appears
> to have that value and doesn't take an argument.
>
> Thanks, and best
>
> Thomas
>
> On Apr 20, 2006, at 5:14 PM, Peter Rolf wrote:
>
>
>> Hi Thomas,
>>
>> Thomas A. Schmitz wrote:
>>
>>> Hi,
>>>
>>> I have a counter which I want to be incremented after every \section
>>> command and reset after every odd \section (don't ask why...). So I
>>> tried this approach:
>>>
>>> \setuphead[section]
>>> [command={{{\determineheadnumber[section]}
>>>
>> ^^^^
>> one opening brace too much
>>
>> If you problem remains, try to add a \expandafter in front of \ifodd.
>> Sometimes it is also helpful to enclose the number expression by
>> \numexpr ... \relax (for conversion).
>>
>> Greets, Peter
>>
>
> _______________________________________________
> ntg-context mailing list
> ntg-context@ntg.nl
> http://www.ntg.nl/mailman/listinfo/ntg-context
>
--
-----------------------------------------------------------------
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] 7+ messages in thread
* Re: using headnumber
2006-04-20 20:44 ` Hans Hagen
@ 2006-04-20 21:46 ` Thomas A. Schmitz
0 siblings, 0 replies; 7+ messages in thread
From: Thomas A. Schmitz @ 2006-04-20 21:46 UTC (permalink / raw)
Fascinating, but... The slidenumber needs to be reset according to
the criterion whether we're starting an odd or an even section.
If anybody's wondering why I want such a bizarre setup: this is the
manuscript of my course for the entire term. Every class consists of
two lectures = two sections in my manuscript, but because the
lectures are back-to-back, I have one pdf presentation for both and
want the marks for the slides in my manuscript numbered consecutively
for section 1+2, then reset and numbered for 3+4 etc. Btw, I
laboriously wrote my own macro to get nice marks for the slides in my
manuscripts and then I discovered the \definelabel command...
Best
Thomas
On Apr 20, 2006, at 10:44 PM, Hans Hagen wrote:
> why not directly use the slidenumber
>
> \def\SlideNumber{1}
>
> command={\ifodd\SlideNumber\gdef\SlideNumber{1}\else\doglobal
> \increment\SlideNumber\fi}}
>
> command={\ifodd\SlideNumber\gdef\SlideNumber{1}\else\gdef
> \SlideNumber{2}\fi}}
>
>
> command={\xdef\SlideNumber{\ifodd\SlideNumber\space1\else2\fi}}
>
> \def\SlideNumber{\ifconditional\OddSlide1\else2\fi}
>
> command=\ifodd\settrue\OddSlide\else\setfalse\OddSlide\fi
>
> etc etc
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2006-04-20 21:46 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-04-20 14:22 using headnumber Thomas A. Schmitz
2006-04-20 15:14 ` Peter Rolf
2006-04-20 16:15 ` Thomas A. Schmitz
2006-04-20 17:06 ` Sanjoy Mahajan
2006-04-20 20:44 ` Hans Hagen
2006-04-20 21:46 ` Thomas A. Schmitz
2006-04-20 16:54 ` Sanjoy 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).