1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
|
% \iffalse meta-comment
%
% Copyright (C) 1999, 2006, 2007 by
% Heiko Oberdiek <oberdiek@uni-freiburg.de>
%
% This work may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either
% version 1.3 of this license or (at your option) any later
% version. The latest version of this license is in
% http://www.latex-project.org/lppl.txt
% and version 1.3 or later is part of all distributions of
% LaTeX version 2005/12/01 or later.
%
% This work has the LPPL maintenance status "maintained".
%
% This Current Maintainer of this work is Heiko Oberdiek.
%
% This work consists of the main source file alphalph.dtx
% and the derived files
% alphalph.sty, alphalph.pdf, alphalph.ins, alphalph.drv.
%
% Distribution:
% CTAN:macros/latex/contrib/oberdiek/alphalph.dtx
% CTAN:macros/latex/contrib/oberdiek/alphalph.pdf
%
% Unpacking:
% (a) If alphalph.ins is present:
% tex alphalph.ins
% (b) Without alphalph.ins:
% tex alphalph.dtx
% (c) If you insist on using LaTeX
% latex \let\install=y\input{alphalph.dtx}
% (quote the arguments according to the demands of your shell)
%
% Documentation:
% (a) If alphalph.drv is present:
% latex alphalph.drv
% (b) Without alphalph.drv:
% latex alphalph.dtx; ...
% The class ltxdoc loads the configuration file ltxdoc.cfg
% if available. Here you can specify further options, e.g.
% use A4 as paper format:
% \PassOptionsToClass{a4paper}{article}
%
% Programm calls to get the documentation (example):
% pdflatex alphalph.dtx
% makeindex -s gind.ist alphalph.idx
% pdflatex alphalph.dtx
% makeindex -s gind.ist alphalph.idx
% pdflatex alphalph.dtx
%
% Installation:
% TDS:tex/generic/oberdiek/alphalph.sty
% TDS:doc/latex/oberdiek/alphalph.pdf
% TDS:source/latex/oberdiek/alphalph.dtx
%
%<*ignore>
\begingroup
\def\x{LaTeX2e}%
\expandafter\endgroup
\ifcase 0\ifx\install y1\fi\expandafter
\ifx\csname processbatchFile\endcsname\relax\else1\fi
\ifx\fmtname\x\else 1\fi\relax
\else\csname fi\endcsname
%</ignore>
%<*install>
\input docstrip.tex
\Msg{************************************************************************}
\Msg{* Installation}
\Msg{* Package: alphalph 2007/04/11 v1.5 Converting numbers to letters (HO)}
\Msg{************************************************************************}
\keepsilent
\askforoverwritefalse
\preamble
This is a generated file.
Copyright (C) 1999, 2006, 2007 by
Heiko Oberdiek <oberdiek@uni-freiburg.de>
This work may be distributed and/or modified under the
conditions of the LaTeX Project Public License, either
version 1.3 of this license or (at your option) any later
version. The latest version of this license is in
http://www.latex-project.org/lppl.txt
and version 1.3 or later is part of all distributions of
LaTeX version 2005/12/01 or later.
This work has the LPPL maintenance status "maintained".
This Current Maintainer of this work is Heiko Oberdiek.
This work consists of the main source file alphalph.dtx
and the derived files
alphalph.sty, alphalph.pdf, alphalph.ins, alphalph.drv.
\endpreamble
\generate{%
\file{alphalph.ins}{\from{alphalph.dtx}{install}}%
\file{alphalph.drv}{\from{alphalph.dtx}{driver}}%
\usedir{tex/generic/oberdiek}%
\file{alphalph.sty}{\from{alphalph.dtx}{package}}%
}
\obeyspaces
\Msg{************************************************************************}
\Msg{*}
\Msg{* To finish the installation you have to move the following}
\Msg{* file into a directory searched by TeX:}
\Msg{*}
\Msg{* alphalph.sty}
\Msg{*}
\Msg{* To produce the documentation run the file `alphalph.drv'}
\Msg{* through LaTeX.}
\Msg{*}
\Msg{* Happy TeXing!}
\Msg{*}
\Msg{************************************************************************}
\endbatchfile
%</install>
%<*ignore>
\fi
%</ignore>
%<*driver>
\NeedsTeXFormat{LaTeX2e}
\ProvidesFile{alphalph.drv}%
[2007/04/11 v1.5 Converting numbers to letters (HO)]%
\documentclass{ltxdoc}
\usepackage{holtxdoc}
\usepackage{alphalph}
\begin{document}
\DocInput{alphalph.dtx}%
\end{document}
%</driver>
% \fi
%
% \CheckSum{393}
%
% \CharacterTable
% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
% Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
% Digits \0\1\2\3\4\5\6\7\8\9
% Exclamation \! Double quote \" Hash (number) \#
% Dollar \$ Percent \% Ampersand \&
% Acute accent \' Left paren \( Right paren \)
% Asterisk \* Plus \+ Comma \,
% Minus \- Point \. Solidus \/
% Colon \: Semicolon \; Less than \<
% Equals \= Greater than \> Question mark \?
% Commercial at \@ Left bracket \[ Backslash \\
% Right bracket \] Circumflex \^ Underscore \_
% Grave accent \` Left brace \{ Vertical bar \|
% Right brace \} Tilde \~}
%
% \GetFileInfo{alphalph.drv}
%
% \title{The \xpackage{alphalph} package}
% \date{2007/04/11 v1.5}
% \author{Heiko Oberdiek\\\xemail{oberdiek@uni-freiburg.de}}
%
% \maketitle
%
% \begin{abstract}
% The package provides the new expandable commands \cs{alphalph}
% and \cs{AlphAlph}. They are like \cs{number}, but the expansion
% consists of lowercase and uppercase letters respectively.
% \end{abstract}
%
% \tableofcontents
%
% \newenvironment{param}{^^A
% \newcommand{\entry}[1]{\meta{\###1}:&}^^A
% \begin{tabular}[t]{@{}l@{ }l@{}}^^A
% }{^^A
% \end{tabular}^^A
% }
%
% \section{Usage}
% The package \Package{alphalph} can be used with both \plainTeX\
% and \LaTeX:
% \begin{description}
% \item[\plainTeX:] |\input alphalph.sty|
% \item[\LaTeXe:] |\usepackage{alphalph}|\\
% There aren't any options.
% \end{description}
%
% \subsection{User commands}
% \begin{description}
% \item[\cmd{\alphalph}:]\DescribeMacro{\alphalph}
% This works like \cmd{\number}, but the expansion consists of
% lowercase letters.
% \item[\cmd{\AlphAlph}:]\DescribeMacro{\AlphAlph}
% It converts a number into uppercase letters.
% \end{description}
% Both commands have following properties:
% \begin{itemize}
% \item They are fully expandable. This means that they can safely
% \begin{itemize}
% \item be written to a file,
% \item used in moving arguments (\LaTeX: they are \emph{robust}),
% \item used in a \cmd{\csname}-\cmd{\endcsname} pair.
% \end{itemize}
% \item If the argument is zero or negative, the commands expand
% to nothing like \cmd{\romannumeral}.
% \item As argument is allowed all that can be used after a \cmd{\number}:
% \begin{itemize}
% \item explicite constants,
% \item macros that expand to a number,
% \item count registers, \LaTeX\ counter can used
% via \cmd{\value}, e.\,g.:\\
% |\alphalph{\value{page}}|
% \end{itemize}
% \end{itemize}
%
% The following table shows, how the conversion is made:
% \begin{center}
% \catcode`\|=12
% \catcode`\+\active
% \def+#1&{\alphalph{#1}&}%
% \begin{tabular}{@{}l|*{14}{r@{, }}r@{}}
% number & 1& 2&\dots& 26& 27&\dots& 52& 53&
% \dots& 78& 79&\dots& 702& 703&\dots
% \\\hline
% \cmd{\alphalph}&+1&+2&\dots&+26&+27&\dots&+52&+53&
% \dots&+78&+79&\dots&+702&+703&\dots
% \end{tabular}
% \end{center}
%
% \subsubsection{New commands like \cs{alphalph}}
% \begin{description}
% \item[\cmd{\newalphalph}:]\DescribeMacro{\newalphalph}
% This macro defines a new command that acts like \cs{alphalph}.
% The use of \eTeX is required.
% The macro has three arguments:
% \begin{itemize}
% \item[\texttt{\#1}:] The command to be defined.
% \item[\texttt{\#2}:] A macro that converts a positive number
% to a symbol.
% \item[\texttt{\#3}:] The number of available symbols.
% \end{itemize}
% \end{description}
%
% Example:
%\begin{quote}
%\begin{verbatim}
%\newcommand*{\myvocals}[1]{%
% \ifcase#1\or A\or E\or I\or O\or U\fi
%}
%\newalphalph{\vocalsvocals}{\myvocals}{5}
%\end{verbatim}
%\end{quote}
%
% \StopEventually{
% }
%
% \section{Implementation}
% \subsection{Begin\texorpdfstring{ of package}{}}
% \begin{macrocode}
%<*package>
% \end{macrocode}
% Reload check, especially if the package is not used with \LaTeX.
% \begin{macrocode}
\begingroup
\expandafter\let\expandafter\x\csname ver@alphalph.sty\endcsname
\ifcase 0%
\ifx\x\relax % plain
\else
\ifx\x\empty % LaTeX
\else
1%
\fi
\fi
\else
\expandafter\ifx\csname PackageInfo\endcsname\relax
\def\x#1#2{%
\immediate\write-1{Package #1 Info: #2.}%
}%
\else
\def\x#1#2{\PackageInfo{#1}{#2, stopped}}%
\fi
\x{alphalph}{The package is already loaded}%
\endgroup
\expandafter\endinput
\fi
\endgroup
% \end{macrocode}
% Package identification:
% \begin{macrocode}
\begingroup
\expandafter\ifx\csname ProvidesPackage\endcsname\relax
\def\x#1#2#3[#4]{\endgroup
\immediate\write-1{Package: #3 #4}%
\xdef#1{#4}%
}%
\else
\def\x#1#2[#3]{\endgroup
#2[{#3}]%
\ifx#1\relax
\xdef#1{#3}%
\fi
}%
\fi
\expandafter\x\csname ver@alphalph.sty\endcsname
\ProvidesPackage{alphalph}%
[2007/04/11 v1.5 Converting numbers to letters (HO)]
% \end{macrocode}
%
% For unique command names this package uses |aa@| as prefix
% for internal command names. Because we need |@| as a letter
% we save the current catcode value.
% \begin{macrocode}
\expandafter\edef\csname aa@atcode\endcsname{\the\catcode`\@ }
\catcode`\@=11
% \end{macrocode}
%
% \subsection{Help macros}
% \begin{macro}{\@ReturnAfterElseFi}
% \begin{macro}{\@ReturnAfterFi}
% The following commands moves the `then' and `else' part respectively
% behind the |\if|-construct. This prevents a too deep |\if|-nesting
% and so a \TeX\ capacity error because of a limited input stack size.
% I use this trick in several packages, so I don't prefix these internal
% commands in order not to have the same macros with different names.
% (It saves memory).
% \begin{macrocode}
\long\def\@ReturnAfterElseFi#1\else#2\fi{\fi#1}
\long\def\@ReturnAfterFi#1\fi{\fi#1}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\aa@alph}
% \begin{macro}{\aa@Alph}
% The two commands \cmd{\aa@alph} and \cmd{\aa@Alph} convert a
% number into a letter (lowercase and uppercase respectivly).
% The character |@| is used as an error symbol,
% if the number isn't in the range of 1 until 26.
% Here we need no space after the number |#1|, because the error
% symbol |@| for the zero case stops scanning the number.
% \begin{macrocode}
\def\aa@alph#1{%
\ifcase#1%
@%
\or a\or b\or c\or d\or e\or f\or g\or h\or i\or j\or k\or l\or m%
\or n\or o\or p\or q\or r\or s\or t\or u\or v\or w\or x\or y\or z%
\else
@%
\fi
}
\def\aa@Alph#1{%
\ifcase#1%
@%
\or A\or B\or C\or D\or E\or F\or G\or H\or I\or J\or K\or L\or M%
\or N\or O\or P\or Q\or R\or S\or T\or U\or V\or W\or X\or Y\or Z%
\else
@%
\fi
}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \subsection{User commands}
% \begin{macro}{\alphalph}
% \begin{macro}{\AlphAlph}
% The whole difference between \cmd{\alphalph} and \cmd{\AlphAlph}
% is that the output consists of lowercase or uppercase letters.
% \begin{macrocode}
\def\alphalph{\aa@callmake\aa@alph}
\def\AlphAlph{\aa@callmake\aa@Alph}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\aa@callmake}
% \cmd{\aa@callmake} converts the number in
% the second argument |#2| into explicite decimal digits via
% the \TeX\ primitive \cmd{\number}. (The closing curly brace stops reading
% the number at the latest.)
% \begin{macrocode}
\def\aa@callmake#1#2{%
\expandafter\aa@make\expandafter{\number#2}#1%
}
% \end{macrocode}
% \end{macro}
%
% \eTeX provides the new primitive \cmd{\numexpr}.
% With this command the implementation is very simple
% (see \ref{sec:etex}). Therefore the package provides two
% methods: a fast and simple one that uses the \eTeX\ extension
% and a method that is restricted to the standard \TeX\ means.
%
% Now we distinguish between \TeX\ and \eTeX\ by checking
% whether \cmd{\numexpr} is defined or isn't.
% Because the \TeX\ primitive \cmd{\csname} defines an
% undefined command to be \cmd{\relax}, \cmd{\csname}
% is executed in a group.
% \begin{macrocode}
\begingroup\expandafter\expandafter\expandafter\endgroup
\expandafter\ifx\csname numexpr\endcsname\relax
% \end{macrocode}
%
% \subsection{\texorpdfstring{Conversion with standard \TeX\ means}{\TeX}}
% \begin{macro}{\aa@make}
% \cmd{\aa@make} catches the cases, if the number is zero or negative.
% Then it expands to nothing like \cmd{\romannumeral}.
% \begin{macrocode}
\def\aa@make#1#2{%
\ifnum#1<1 %
\else
\@ReturnAfterFi{%
\aa@process1;#1;1..#2%
}%
\fi
}%
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\aa@process}
% \cmd{\aa@process} contains the algorithm for the conversion.
% \TeX doesn't provide a simple method to divide or multiply
% numbers in a fully expandable way. An expandable addition by one
% is complicated enough. Therefore \cmd{\aa@process} uses
% only expandible versions of additions by one. The algorithm
% starts with one and increments it until the size of the wanted
% number is reached. The intermediate number that is incremented
% is present in two kinds:
% \begin{itemize}
% \item the normal decimal form for the \cs{ifnum}-comparison,
% \item a digit format: the end of each digit is marked by an dot,
% and the digits are in reserved order. An empty digit
% ends this format. The meaning of a digit is here the
% decimal representation of a letter, the range is
% from 1 until 26.
% \end{itemize}
% Example: The aim number is 100, the intermediate number 50, so
% following would be on the argument stack:
% \begin{quote}
% |50;100;24.1..\aa@alph|
% \end{quote}
% \cmd{\aa@process} increments the first argument |#1| (|50|),
% and calls \cmd{\aa@alphinc} to increment the digit form
% (|24.1..|). The middle part with the aim number |;#2;| (|;100;|)
% will not be changed. Neither \cmd{\aa@process} nor \cmd{\aa@alphinc}
% need the conversion command \cmd{\aa@alph} nor \cmd{\aa@Alph}.
% This command is read by \cmd{\aa@getresult}, if the digit form is
% ready.
%
% The expansion motor is \cmd{\number}. It reads and expands token
% to get decimal numbers until a token is reached that isn't a
% decimal digit. So the expansion doesn't stop, if \cmd{\aa@inc}
% is ready, because \cmd{\aa@inc} produces only decimal digits.
% \cmd{\aa@alphinc} is expanded to look for further digits.
% Now \cmd{\aa@alphinc} makes its job and returns with its
% argument |;#2;|. At last the first character |;| finishes \cmd{\number}.
% \begin{macrocode}
\def\aa@process#1;#2;{%
\ifnum#1=#2 %
\expandafter\aa@getresult
\else
\@ReturnAfterFi{%
\expandafter\aa@process\number\aa@inc{#1}\aa@alphinc{;#2;}%
}%
\fi
}%
% \end{macrocode}
% \end{macro}
%
% \subsubsection{\texorpdfstring{^^A
% Convert the separated digits to the letter result}{^^A
% Digits to letter result}}\label{sec:form}
%
% The single decimal digits of the final letter number are
% limited by a dot and come in reverse order. The end is
% marked by an empty digit.
% The next token is the command to convert a digit
% (\cmd{\aa@alph} or \cmd{\aa@Alph}), e.g.:
% \begin{quote}
% |11.3.1..\alph| $\Rightarrow$ |ack|
% \end{quote}
%
% \begin{macro}{\aa@getresult}
% \cmd{\aa@getresult} reads the digits |#1| and the converting
% command |#2|. Then it
% calls \cmd{\aa@@getresult} with its arguments.
% \begin{macrocode}
\def\aa@getresult#1..#2{%
\aa@@getresult!#2#1..%
}%
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\aa@@getresult}
% In its first argument |#1| \cmd{\aa@@getresult} collects the
% converted letters in the correct order. Character |!| is used
% as a parameter separator. The next token |#2| is the converting
% command (\cmd{\aa@alph} or \cmd{\aa@Alph}). The next digit |#3|
% is read, converted, and |\aa@@getresult| is called again.
% If the digit |#3| is empty, the end of the digit form is reached
% and the process stops and the ready letter number is output.
% \begin{macrocode}
\def\aa@@getresult#1!#2#3.{%
\ifx\\#3\\%
\@ReturnAfterElseFi{#1}% ready
\else
\@ReturnAfterFi{%
\expandafter\expandafter\expandafter\expandafter
\expandafter\expandafter\expandafter
\aa@@getresult
\expandafter\expandafter\expandafter\expandafter
#2{#3}#1!#2%
}%
\fi
}%
% \end{macrocode}
% \end{macro}
%
% \subsubsection{Addition by one}
%
% \paragraph{Expandable addition of a decimal integer.}
% \begin{macro}{\aa@inc}
% \cmd{\aa@inc} increments its argument |#1| by one.
% The case, that the whole number is less than nine, is
% specially treated because of speed. (The space
% after |9| is neccessary.)
% \begin{macrocode}
% \aa@inc adds one to its argument #1.
\def\aa@inc#1{%
\ifnum#1<9 %
\aa@nextdigit{#1}%
\else
\aa@reverse#1!!%
\fi
}%
% \end{macrocode}
% \end{macro}
% \begin{macro}{\aa@nextdigit}
% \cmd{\aa@nextdigit} increments the digit |#1|. The result
% is a digit again. \cmd{\aa@addone} works off the case ``9+1''.
% \begin{macrocode}
\def\aa@nextdigit#1{\ifcase#1 1\or2\or3\or4\or5\or6\or7\or8\or9\fi}%
% \end{macrocode}
% \end{macro}
% \begin{macro}{\aa@reverse}
% Because the addition starts with the lowest significant digit
% of the number. But with the means of \TeX's macro expansion is
% the first digit of a number available. So \cmd{\aa@reverse}
% reverses the order of the digits and calls \cmd{\aa@addone},
% if it is ready.
% \begin{macrocode}
\def\aa@reverse#1#2!#3!{%
\ifx\\#2\\%
\aa@addone#1#3!!%
\else
\@ReturnAfterFi{%
\aa@reverse#2!#1#3!%
}%
\fi
}%
% \end{macrocode}
% \end{macro}
% \begin{macro}{\aa@addone}
% The addition is performed by the macro \cmd{\aa@addone}.
% The digits are in reversed order. The parameter text |#1#2|
% separates the next digit |#1| that have to be incremented.
% Already incremented digits are stored in |#3| in reversed order
% to take some work of \cmd{\aa@lastreverse}.
% \begin{macrocode}
\def\aa@addone#1#2!#3!{%
\ifnum#1<9 %
\expandafter\aa@lastreverse\number\aa@nextdigit#1 #2!#3!%
\else
\@ReturnAfterFi{%
\ifx\\#2\\%
10#3%
\else
\@ReturnAfterFi{%
\aa@addone#2!0#3!%
}%
\fi
}%
\fi
}%
% \end{macrocode}
% \end{macro}
% \begin{macro}{\aa@lastreverse}
% With \cmd{\aa@reverse} the order of the digits is changed to
% perform the addition in \cmd{\aa@addone}. Now we have to return
% to the original order that is done by \cmd{\aa@lastreverse}.
% \begin{macrocode}
\def\aa@lastreverse#1#2!#3!{%
\ifx\\#2\\%
#1#3%
\else
\@ReturnAfterFi{%
\aa@lastreverse#2!#1#3!%
}%
\fi
}%
% \end{macrocode}
% \end{macro}
%
% \paragraph{Increment of the decimal digit result form.}
% \begin{macro}{\aa@alphinc}
% \cmd{\aa@alphinc} adds one to the intermediate number in
% the decimal digit result form (see \ref{sec:form}).
% Parameter |#1| consists of the tokens that come before the
% addition result (see |;#2;| of \cmd{\aa@process}). Then
% it is also used to store already incremented digits.
% |#2| contains the next digit in the range of 1 until 26.
% An empty |#2| marks the end of the number.
% \begin{macrocode}
\def\aa@alphinc#1#2.{%
\ifx\\#2\\%
\@ReturnAfterElseFi{%
#11..% ready
}%
\else
\@ReturnAfterFi{%
\ifnum#2<26 %
\@ReturnAfterElseFi{%
\expandafter\aa@alphinclast\expandafter
{\number\aa@inc{#2}}{#1}%
}%
\else
\@ReturnAfterFi{%
\aa@alphinc{#11.}%
}%
\fi
}%
\fi
}%
% \end{macrocode}
% \end{macro}
% \begin{macro}{\aa@alphinclast}
% \cmd{\aa@alphinclast} is a help macro. Because |#2| consists of
% several tokens (e.g. |;100;|), we cannot jump over it via
% \cmd{\expandafter} in \cmd{\aa@alphinc}.
% \begin{macrocode}
\def\aa@alphinclast#1#2{#2#1.}%
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\newalphalph}
% \begin{macrocode}
\newcommand*{\newalphalph}[3]{%
\PackageError{alphalph}{%
\string\newalphalph\space requires e-TeX%
}\@ehc
% \end{macrocode}
% \end{macro}
%
% \subsection{\texorpdfstring{Conversion with \eTeX\ features}{\eTeX}}
% \label{sec:etex}
% \begin{macrocode}
\else
% \end{macrocode}
%
% \begin{macro}{\aa@make}
% \cmd{\aa@make} catches the cases, if the number is zero or negative.
% Then it expands to nothing like \cmd{\romannumeral}.
% \begin{macrocode}
\def\aa@make#1#2{%
\ifnum#1<1 %
\else
\@ReturnAfterFi{%
\aa@eprocess#1;#2%
}%
\fi
}%
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\aa@eprocess}
% The first argument |#1| contains the number that have to be
% converted yet, the next argument |#2| the command for making
% the conversion of a digit (\cmd{\aa@alph} or \cmd{\aa@Alph}).
% The number is divided by 26 to get the rest. Command
% |#2| converts the rest to a letter that is put after the arguments
% of the next call of \cmd{\aa@eprocess}.
%
% The only feature of \eTeX\ we use the new primitive \cmd{\numexpr}.
% It provides expandible mathematical calculations.
% \begin{macrocode}
\def\aa@eprocess#1;#2{%
\ifnum#1<27 %
\@ReturnAfterElseFi{%
#2{#1}%
}%
\else
\@ReturnAfterFi{%
\expandafter\aa@eprocess\number\numexpr(#1-14)/26%
\expandafter\expandafter\expandafter;%
\expandafter\expandafter\expandafter#2%
#2{\numexpr#1-((#1-14)/26)*26}%
}%
\fi
}%
% \end{macrocode}
% \end{macro}
%
% \subsection{Generic version}
%
% \begin{macro}{\aa@gen@callmake}
% See macro \cs{aa@callmake}. Argument |#3| holds the
% number of available symbols.
% \begin{macrocode}
\def\aa@gen@callmake#1#2#3{%
\expandafter\aa@gen@make\expandafter{\number#3}#1{#2}%
}%
% \end{macrocode}
% \end{macro}
% \begin{macro}{\aa@gen@make}
% See macro \cs{aa@make}. Argument |#3| holds the number of
% available symbols.
% \begin{macrocode}
\def\aa@gen@make#1#2#3{%
\ifnum#1<1 %
\else
\@ReturnAfterFi{%
\aa@gen@eprocess{#3}#1;#2%
}%
\fi
}%
% \end{macrocode}
% \end{macro}
% \begin{macro}{\aa@gen@eprocess}
% See macro \cs{aa@eprocess}. Argument |#1| holds the number of
% available symbols.
% \begin{macrocode}
\def\aa@gen@eprocess#1#2;#3{%
\ifnum#2>#1 %
\@ReturnAfterElseFi{%
\expandafter\aa@gen@eprocess\expandafter{%
\number#1\expandafter
}%
\number\numexpr(#2-(\aa@half{#1}+1))/#1%
\expandafter\expandafter\expandafter;%
\expandafter\expandafter\expandafter#3%
#3{\numexpr#2-((#2-(\aa@half{#1}+1))/#1)*#1\relax}%
}%
\else
\@ReturnAfterFi{%
#3{#2}%
}%
\fi
}%
% \end{macrocode}
% \end{macro}
% \begin{macro}{\aa@half}
% Macro \cs{aa@half} implements integer division by two
% without rounding.
% \begin{macrocode}
\def\aa@half#1{%
\number\dimexpr.5\dimexpr #1sp\relax\relax
}%
% \end{macrocode}
% \end{macro}
% \begin{macro}{\newalphalph}
% New macros are defined by \cs{newalphalph} that act like
% \cs{alphalph}. The macro to be defined is |#1|. Argument |#2|
% contains the macro that converts a number to a symbol and
% argument |#3| holds the number of available symbols.
% \begin{macrocode}
\newcommand*{\newalphalph}[3]{%
\newcommand*{#1}{}%
\edef#1{%
\noexpand\aa@gen@callmake\noexpand#2{\number\numexpr#3}%
}%
}%
% \end{macrocode}
% \end{macro}
%
% \subsection{End\texorpdfstring{ of package}{}}
% Now we can terminate the differentiation between \TeX\ and \eTeX.
% \begin{macrocode}
\fi
% \end{macrocode}
%
% At the end the catcode of the character |@| is restored.
% \begin{macrocode}
\catcode`\@=\aa@atcode
% \end{macrocode}
% \begin{macrocode}
%</package>
% \end{macrocode}
% \section{Installation}
%
% \subsection{Download}
%
% \paragraph{Package.} This package is available on
% CTAN\footnote{\url{ftp://ftp.ctan.org/tex-archive/}}:
% \begin{description}
% \item[\CTAN{macros/latex/contrib/oberdiek/alphalph.dtx}] The source file.
% \item[\CTAN{macros/latex/contrib/oberdiek/alphalph.pdf}] Documentation.
% \end{description}
%
%
% \paragraph{Bundle.} All the packages of the bundle `oberdiek'
% are also available in a TDS compliant ZIP archive. There
% the packages are already unpacked and the documentation files
% are generated. The files and directories obey the TDS standard.
% \begin{description}
% \item[\CTAN{macros/latex/contrib/oberdiek/oberdiek-tds.zip}]
% \end{description}
%
% \subsection{Bundle installation}
%
% \paragraph{Unpacking.} Unpack the \xfile{oberdiek-tds.zip} in the
% TDS tree (also known as \xfile{texmf} tree) of your choice.
% Example (linux):
% \begin{quote}
% |unzip oberdiek-tds.zip -d ~/texmf|
% \end{quote}
%
% \paragraph{Script installation.}
% Check the directory \xfile{TDS:scripts/oberdiek/} for
% scripts that need further installation steps.
% Package \xpackage{attachfile2} comes with the Perl script
% \xfile{pdfatfi.pl} that should be installed in such a way
% that it can be called as \texttt{pdfatfi}.
% Example (linux):
% \begin{quote}
% |chmod +x scripts/oberdiek/pdfatfi.pl|\\
% |cp scripts/oberdiek/pdfatfi.pl /usr/local/bin/|
% \end{quote}
%
% \subsection{Package installation}
%
% \paragraph{Unpacking.} The \xfile{.dtx} file is a self-extracting
% \docstrip\ archive. The files are extracted by running the
% \xfile{.dtx} through \plainTeX:
% \begin{quote}
% \verb|tex alphalph.dtx|
% \end{quote}
%
% \paragraph{TDS.} Now the different files must be moved into
% the different directories in your installation TDS tree
% (also known as \xfile{texmf} tree):
% \begin{quote}
% \sbox0{^^A
% \begin{tabular}{@{}>{\ttfamily}l@{$\quad\rightarrow\quad$}>{\ttfamily}l@{}}
% alphalph.sty & tex/generic/oberdiek/alphalph.sty\\
% alphalph.pdf & doc/latex/oberdiek/alphalph.pdf\\
% alphalph.dtx & source/latex/oberdiek/alphalph.dtx\\
% \end{tabular}^^A
% }%
% \ifdim\wd0>\linewidth
% \mbox{}\nobreak\hskip0pt minus\leftmargin
% \usebox0
% \nobreak\hskip0pt minus\rightmargin
% \else
% \usebox0
% \fi
% \end{quote}
% If you have a \xfile{docstrip.cfg} that configures and enables \docstrip's
% TDS installing feature, then some files can already be in the right
% place, see the documentation of \docstrip.
%
% \subsection{Refresh file name databases}
%
% If your \TeX~distribution
% (\teTeX, \mikTeX, \dots) relies on file name databases, you must refresh
% these. For example, \teTeX\ users run \verb|texhash| or
% \verb|mktexlsr|.
%
% \subsection{Some details for the interested}
%
% \paragraph{Attached source.}
%
% The PDF documentation on CTAN also includes the
% \xfile{.dtx} source file. It can be extracted by
% AcrobatReader 6 or higher. Another option is \textsf{pdftk},
% e.g. unpack the file into the current directory:
% \begin{quote}
% \verb|pdftk alphalph.pdf unpack_files output .|
% \end{quote}
%
% \paragraph{Unpacking with \LaTeX.}
% The \xfile{.dtx} chooses its action depending on the format:
% \begin{description}
% \item[\plainTeX:] Run \docstrip\ and extract the files.
% \item[\LaTeX:] Generate the documentation.
% \end{description}
% If you insist on using \LaTeX\ for \docstrip\ (really,
% \docstrip\ does not need \LaTeX), then inform the autodetect routine
% about your intention:
% \begin{quote}
% \verb|latex \let\install=y\input{alphalph.dtx}|
% \end{quote}
% Do not forget to quote the argument according to the demands
% of your shell.
%
% \paragraph{Generating the documentation.}
% You can use both the \xfile{.dtx} or the \xfile{.drv} to generate
% the documentation. The process can be configured by the
% configuration file \xfile{ltxdoc.cfg}. For instance, put this
% line into this file, if you want to have A4 as paper format:
% \begin{quote}
% \verb|\PassOptionsToClass{a4paper}{article}|
% \end{quote}
% An example follows how to generate the
% documentation with pdf\LaTeX:
% \begin{quote}
%\begin{verbatim}
%pdflatex alphalph.dtx
%makeindex -s gind.ist alphalph.idx
%pdflatex alphalph.dtx
%makeindex -s gind.ist alphalph.idx
%pdflatex alphalph.dtx
%\end{verbatim}
% \end{quote}
%
% \begin{History}
% \begin{Version}{1999/03/19 v0.1}
% \item
% The first version was built as a response to a
% \URL{question}^^A
% {http://www.dejanews.com/[ST_rn=ps]/getdoc.xp?AN=455791936}^^A
% of \NameEmail{Will Douglas}{william.douglas@wolfson.ox.ac.uk}
% and the
% \URL{request}^^A
% {http://www.dejanews.com/[ST_rn=ps]/getdoc.xp?AN=456358639}^^A
% of \NameEmail{Donald Arsenau}{asnd@reg.triumf.ca},
% published in the newsgroup
% \href{news:comp.text.tex}{comp.text.tex}:
% \URL{``Re: alph counters \textgreater\ 26''}^^A
% {http://www.dejanews.com/[ST_rn=ps]/getdoc.xp?AN=456485421}
% \item
% Copyright: LPPL (\CTAN{macros/latex/base/lppl.txt})
% \end{Version}
% \begin{Version}{1999/04/12 v1.0}
% \item
% Documentation added in dtx format.
% \item
% \eTeX\ support added.
% \end{Version}
% \begin{Version}{1999/04/13 v1.1}
% \item
% Minor documentation change.
% \item
% First CTAN release.
% \end{Version}
% \begin{Version}{1999/06/26 v1.2}
% \item
% First generic code about \cmd{\ProvidesPackage} improved.
% \item
% Documentation: Installation part revised.
% \end{Version}
% \begin{Version}{2006/02/20 v1.3}
% \item
% Reload check (for \plainTeX)
% \item
% New DTX framework.
% \item
% LPPL 1.3
% \end{Version}
% \begin{Version}{2006/05/30 v1.4}
% \item
% \cs{newalphalph} added.
% \end{Version}
% \begin{Version}{2007/04/11 v1.5}
% \item
% Line ends sanitized.
% \end{Version}
% \end{History}
%
% \PrintIndex
%
% \Finale
\endinput
|