Re: [NTG-context] using headnumber

2006-04-20 Thread Peter Rolf
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
 
 

___
ntg-context mailing list
ntg-context@ntg.nl
http://www.ntg.nl/mailman/listinfo/ntg-context


Re: [NTG-context] using headnumber

2006-04-20 Thread Thomas A. Schmitz
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

___
ntg-context mailing list
ntg-context@ntg.nl
http://www.ntg.nl/mailman/listinfo/ntg-context


Re: [NTG-context] using headnumber

2006-04-20 Thread Sanjoy Mahajan
 \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.
___
ntg-context mailing list
ntg-context@ntg.nl
http://www.ntg.nl/mailman/listinfo/ntg-context


Re: [NTG-context] using headnumber

2006-04-20 Thread Sanjoy Mahajan
 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.
___
ntg-context mailing list
ntg-context@ntg.nl
http://www.ntg.nl/mailman/listinfo/ntg-context


Re: [NTG-context] using headnumber

2006-04-20 Thread Hans Hagen
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
-

___
ntg-context mailing list
ntg-context@ntg.nl
http://www.ntg.nl/mailman/listinfo/ntg-context


Re: [NTG-context] using headnumber

2006-04-20 Thread Thomas A. Schmitz
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

___
ntg-context mailing list
ntg-context@ntg.nl
http://www.ntg.nl/mailman/listinfo/ntg-context