[texhax] Counting letters
klists at saphor.de
klists at saphor.de
Fri Oct 15 10:17:34 CEST 2004
Hi!
For a critical edition I need to print footnotes as letters, beginning
at "a" and going up to "z", then restarting at "a". The letter "j"
must, for some arcane reasons, not be used. In the base data,
originating from an XML source, the footnotes are numbers sequentially
from 1 to 4000. Each footnote number appear repeatedly to mark
extensions.
My naive idea to handle that problem in TeX was the following:
-----------------
\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}
-----------------
In other words, I want to calculate modulo 25 and then pick the appropriate letter.
However, I get in the log:
1 hallo 1 hallo 2 hallo 2 hallo 2 hallo 2 hallo 3 hallo 3 hallo 4 hallo 4 hallo
5 hallo 5 hallo 6 hallo 6 hallo 7 hallo 7 hallo 8 hallo 8 hallo 9 hallo 9
hallo 9 hallo 10 hallo 10 hallo 9 hallo
! TeX capacity exceeded, sorry [input stack size=1500].
\par ->\@restorepar
\everypar {}\par \@endpefalse
l.49 ...ootnoteA}\Footnotemark{\lettercounter{11}}
\FootnotetextA{\lettercoun...
Why is TeX's capacity exceeded?
My TeX is extremely rusty these days, so please excuse in advance if
the answer should be trivial. I studied the register section of TeX
for the Impatient, to no avail, but I may well have overlooked the
obvious.
Thanks!
Marc
P. S.: Is there any less roundabound way to calculate the modulo in
(La-)TeX than this?
More information about the texhax
mailing list