[texhax] Counting letters

Marc Wilhelm Küster kuester at saphor.net
Sun Oct 17 01:58:41 CEST 2004


On Fri, 20-10-15, 2004 at 05:52:51PM +0100, Robin Fairbairns wrote:
> > > -----------------
> > > 
> > > \newcount\footnotecounter
> > > \newcount\footnotetmp
> > > \def\lettercounter#1{\message{#1}\footnotecounter=#1
> > >   \footnotetmp=\footnotecounter
> > >   \divide\footnotetmp by 25 
> > >   \multiply\footnotetmp by 25 
> > >   \advance\footnotecounter by -\footnotetmp
> > > 
> > >   \ifnum\footnotecounter < 25 \message{hallo}\fi
> > > 
> > >   \ifcase\footnotecounter \or a\or b\or
> > >   c\or d\or e \or f \or g \or h \or i \or k \or l \or m \or n \or o
> > >   \or p \or q \or s \or t \or u \or v \or w \or x \or y \or z\fi}
> > > 
> > 
> > Ross Moore kindly pointed out the problem -- the blanks in the macro
> > definition cause the havoc.
> 
> oh.  i'd noted that down as something to comment on, but hadn't
> imagined it would cause the problem.
> 
> the other issue i'd noted was that you're reducing \footnotecounter to
> the range 0..24, and then doing a case statement that selects 1..25
> 
> i think you need to decrement \footnotecounter by 1 at the start of
> the calculation, and to remove the initial \or in your case statement.

You are perfectly right. Thanks for the pointer!

Best regards,

Marc



More information about the texhax mailing list