diff options
Diffstat (limited to 'Master/texmf-dist/tex/generic/oberdiek/alphalph.sty')
-rw-r--r-- | Master/texmf-dist/tex/generic/oberdiek/alphalph.sty | 478 |
1 files changed, 315 insertions, 163 deletions
diff --git a/Master/texmf-dist/tex/generic/oberdiek/alphalph.sty b/Master/texmf-dist/tex/generic/oberdiek/alphalph.sty index 3c4fecd90b2..d8bad96e21f 100644 --- a/Master/texmf-dist/tex/generic/oberdiek/alphalph.sty +++ b/Master/texmf-dist/tex/generic/oberdiek/alphalph.sty @@ -25,7 +25,8 @@ %% %% This work consists of the main source file alphalph.dtx %% and the derived files -%% alphalph.sty, alphalph.pdf, alphalph.ins, alphalph.drv. +%% alphalph.sty, alphalph.pdf, alphalph.ins, alphalph.drv, +%% alphalph-test1.tex, alphalph-test2.tex, alphalph-test3.tex. %% \begingroup \catcode44 12 % , @@ -79,197 +80,348 @@ \fi \expandafter\x\csname ver@alphalph.sty\endcsname \ProvidesPackage{alphalph}% - [2007/04/11 v1.5 Converting numbers to letters (HO)] -\expandafter\edef\csname aa@atcode\endcsname{\the\catcode`\@ } -\catcode`\@=11 + [2007/04/11 v2.0 Converting numbers to letters (HO)] +\expandafter\edef\csname AlPh@AtEnd\endcsname{% + \catcode64 \the\catcode64\relax +} +\catcode64 11 % @ +\def\TMP@EnsureCode#1#2{% + \edef\AlPh@AtEnd{% + \AlPh@AtEnd + \catcode#1 \the\catcode#1\relax + }% + \catcode#1 #2\relax +} +\TMP@EnsureCode{33}{12}% ! +\TMP@EnsureCode{39}{12}% ' +\TMP@EnsureCode{40}{12}% ( +\TMP@EnsureCode{41}{12}% ) +\TMP@EnsureCode{43}{12}% + +\TMP@EnsureCode{44}{12}% , +\TMP@EnsureCode{46}{12}% . +\TMP@EnsureCode{47}{12}% / +\TMP@EnsureCode{59}{12}% ; +\TMP@EnsureCode{60}{12}% < +\TMP@EnsureCode{61}{12}% = +\TMP@EnsureCode{62}{12}% > +\TMP@EnsureCode{91}{12}% [ +\TMP@EnsureCode{93}{12}% ] +\TMP@EnsureCode{96}{12}% ` +\TMP@EnsureCode{124}{12}% | +\begingroup\expandafter\expandafter\expandafter\endgroup +\expandafter\ifx\csname RequirePackage\endcsname\relax + \input infwarerr.sty\relax + \input intcalc.sty\relax +\else + \RequirePackage{infwarerr}[2007/09/09]% + \RequirePackage{intcalc}[2007/09/09]% +\fi +\begingroup\expandafter\expandafter\expandafter\endgroup +\expandafter\ifx\csname numexpr\endcsname\relax + \catcode124=9 % '!': ignore + \catcode43=14 % '+': comment +\else + \catcode124=14 % '!': comment + \catcode43=9 % '+': ignore +\fi +\def\AlPh@Error#1{% + \begingroup + \escapechar=92 % backslash + \@PackageError{alphalph}{#1}\@ehc + \endgroup +} +\begingroup\expandafter\expandafter\expandafter\endgroup +\expandafter\ifx\csname @ifdefinable\endcsname\relax + \def\AlPh@IfDefinable#1#2{% + \ifcase\ifx#1\@undefined\else\ifx#1\relax\else1\fi\fi0 % + #2% + \else + \AlPh@Error{% + Command \string#1 already defined% + }% + \fi + }% +\else + \let\AlPh@IfDefinable\@ifdefinable +\fi \long\def\@ReturnAfterElseFi#1\else#2\fi{\fi#1} \long\def\@ReturnAfterFi#1\fi{\fi#1} -\def\aa@alph#1{% +\expandafter\ifx\csname @gobblefour\endcsname\relax + \long\def\@gobblefour#1#2#3#4{}% +\fi +\begingroup\expandafter\expandafter\expandafter\endgroup +\expandafter\ifx\csname kernel@ifnextchar\endcsname\relax + \begingroup\expandafter\expandafter\expandafter\endgroup + \expandafter\ifx\csname @ifnextchar\endcsname\relax + \def\AlPh@IfOptArg#1#2{% + \def\AlPh@TempA{#1}% + \def\AlPh@TempB{#2}% + \futurelet\AlPh@Token\AlPh@IfOptArgNext + }% + \let\AlPh@BracketLeft=[%] + \def\AlPh@IfOptArgNext{% + \ifx\AlPh@Token\AlPh@BracketLeft + \expandafter\AlPh@TempA + \else + \expandafter\AlPh@TempB + \fi + }% + \else + \def\AlPh@IfOptArg{\@ifnextchar[}%] + \fi +\else + \def\AlPh@IfOptArg{\kernel@ifnextchar[}%] +\fi +\def\alphalph@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% + \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 + \AlPh@ctrerr @% \fi } -\def\aa@Alph#1{% +\def\alphalph@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% + \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 + \AlPh@ctrerr @% \fi } -\def\alphalph{\aa@callmake\aa@alph} -\def\AlphAlph{\aa@callmake\aa@Alph} -\def\aa@callmake#1#2{% - \expandafter\aa@make\expandafter{\number#2}#1% +\def\AlPh@ctrerr{} +\def\AlPh@GetNumberOfSymbols#1{% + \AlPh@TestNumber1!{#1}% + \ifAlPh@Unavailable + \def\AlPh@Number{0}% + \AlPh@Error{No symbols found}% + \else + \def\AlPh@Number{1}% + \AlPh@ExpSearch2!{#1}% + \fi } -\begingroup\expandafter\expandafter\expandafter\endgroup -\expandafter\ifx\csname numexpr\endcsname\relax - \def\aa@make#1#2{% - \ifnum#1<1 % - \else - \@ReturnAfterFi{% - \aa@process1;#1;1..#2% - }% - \fi - }% - \def\aa@process#1;#2;{% - \ifnum#1=#2 % - \expandafter\aa@getresult - \else - \@ReturnAfterFi{% - \expandafter\aa@process\number\aa@inc{#1}\aa@alphinc{;#2;}% - }% - \fi - }% - \def\aa@getresult#1..#2{% - \aa@@getresult!#2#1..% - }% - \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 - }% - \def\aa@inc#1{% - \ifnum#1<9 % - \aa@nextdigit{#1}% - \else - \aa@reverse#1!!% - \fi - }% - \def\aa@nextdigit#1{\ifcase#1 1\or2\or3\or4\or5\or6\or7\or8\or9\fi}% - \def\aa@reverse#1#2!#3!{% - \ifx\\#2\\% - \aa@addone#1#3!!% - \else - \@ReturnAfterFi{% - \aa@reverse#2!#1#3!% - }% +\newif\ifAlPh@Unavailable +\def\AlPh@Unavailabletrue{% + \global\let\ifAlPh@Unavailable\iftrue +} +\def\AlPh@Unavailablefalse{% + \global\let\ifAlPh@Unavailable\iffalse +} +\def\AlPh@TestNumber#1!#2{% + \AlPh@Unavailablefalse + \begingroup + \setbox0=\hbox{% + \begingroup % color + \let\@ctrerr\AlPh@Unavailabletrue + \let\AlPh@ctrerr\AlPh@Unavailabletrue + #2{#1}% + \endgroup + }% + \ifdim\wd0=0pt % + \AlPh@Unavailabletrue \fi - }% - \def\aa@addone#1#2!#3!{% - \ifnum#1<9 % - \expandafter\aa@lastreverse\number\aa@nextdigit#1 #2!#3!% + \endgroup +} +\def\AlPh@ExpSearch#1!#2{% + \let\AlPh@Next\relax + \AlPh@TestNumber#1!{#2}% + \ifAlPh@Unavailable + \expandafter\AlPh@BinSearch\AlPh@Number!#1!{#2}% + \else + \def\AlPh@Number{#1}% + \ifnum#1>1073741823 % + \AlPh@TestNumber2147483647!{#2}% + \ifAlPh@Unavailable + \AlPh@BinSearch#1!2147483647!{#2}% + \else + \def\AlPh@Number{0}% + \AlPh@Error{% + Maximal symbol number not found% + }% + \fi \else - \@ReturnAfterFi{% - \ifx\\#2\\% - 10#3% - \else - \@ReturnAfterFi{% - \aa@addone#2!0#3!% - }% - \fi + \def\AlPh@Next{% + \expandafter\AlPh@ExpSearch\number\intcalcShl{#1}!{#2}% }% \fi - }% - \def\aa@lastreverse#1#2!#3!{% - \ifx\\#2\\% - #1#3% + \fi + \AlPh@Next +} +\def\AlPh@BinSearch#1!#2!#3{% + \expandafter\AlPh@ProcessBinSearch + \number\intcalcShr{\intcalcAdd{#1}{#2}}!% + #1!#2!{#3}% +} +\def\AlPh@ProcessBinSearch#1!#2!#3!#4{% + \let\AlPh@Next\relax + \ifnum#1>#2 % + \ifnum#1<#3 % + \AlPh@TestNumber#1!{#4}% + \ifAlPh@Unavailable + \def\AlPh@Next{% + \AlPh@BinSearch#2!#1!{#4}% + }% + \else + \def\AlPh@Next{% + \AlPh@BinSearch#1!#3!{#4}% + }% + \fi \else - \@ReturnAfterFi{% - \aa@lastreverse#2!#1#3!% - }% + \def\AlPh@Number{#2}% \fi + \else + \def\AlPh@Number{#2}% + \fi + \AlPh@Next +} +\def\AlPh@CheckPositive#1!#2{% + \ifnum#1<1 % + \expandafter\@gobblefour + \fi + #2{#1}% +} +\def\AlPh@Method@alph#1#2#3{% + \expandafter\AlPh@CheckPositive +| \number#3!% ++ \the\numexpr#3!% + \AlPh@ProcessAlph + {#1}{#2}% +} +\def\AlPh@ProcessAlph#1#2#3{% + \ifnum#1>#2 % + \@ReturnAfterElseFi{% + \expandafter\AlPh@StepAlph\number + \intcalcInc{% + \intcalcMod{\intcalcDec{#1}}{#2}% + }% + \expandafter!\number + \intcalcDiv{\intcalcDec{#1}}{#2}% + !{#2}{#3}% + }% + \else + \@ReturnAfterFi{% + #3{#1}% + }% + \fi +} +\def\AlPh@StepAlph#1!#2!#3#4{% + \AlPh@ProcessAlph{#2}{#3}{#4}% + #4{#1}% +} +\def\AlPh@Method@wrap#1#2#3{% + \expandafter\AlPh@CheckPositive +| \number#3!% ++ \the\numexpr#3!% + \AlPh@ProcessWrap + {#1}{#2}% +} +\def\AlPh@ProcessWrap#1#2#3{% + \ifnum#1>#2 % + \@ReturnAfterElseFi{% + \expandafter\AlPh@StepWrap\number + \intcalcInc{\intcalcMod{\intcalcDec{#1}}{#2}}% + !{#3}% + }% + \else + \@ReturnAfterFi{% + #3{#1}% + }% + \fi +} +\def\AlPh@StepWrap#1!#2{% + #2{#1}% +} +\def\AlPh@Method@mult#1#2#3{% + \expandafter\AlPh@CheckPositive +| \number#3!% ++ \the\numexpr#3!% + \AlPh@ProcessMult + {#1}{#2}% +} +\def\AlPh@ProcessMult#1#2#3{% + \ifnum#1>#2 % + \@ReturnAfterElseFi{% + \expandafter\AlPh@StepMult\romannumeral + \intcalcInc{\intcalcDiv{\intcalcDec{#1}}{#2}}% + 000% + \expandafter!\number + \intcalcInc{\intcalcMod{\intcalcDec{#1}}{#2}}% + !{#3}% + }% + \else + \@ReturnAfterFi{% + #3{#1}% + }% + \fi +} +\def\AlPh@StepMult#1#2!#3!#4{% + \ifx\\#2\\% + \else + \@ReturnAfterFi{% + \AlPh@StepMult#2!#3!{#4}% + }% + \fi + #4{#3}% +} +\AlPh@IfDefinable\newalphalph{% + \def\newalphalph#1{% + \AlPh@IfOptArg{% + \AlPh@newalphalph{#1}% + }{% + \AlPh@newalphalph{#1}[alph]% + }% }% - \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.}% +} +\def\AlPh@newalphalph#1[#2]#3#4{% + \begingroup\expandafter\expandafter\expandafter\endgroup + \expandafter\ifx\csname AlPh@Method@#2\endcsname\relax + \AlPh@Error{% + Unknown method % +| `#2'% ++ `\detokenize{#2}'% + }% + \else + \ifx\\#4\\% + \AlPh@GetNumberOfSymbols{#3}% + \ifcase\AlPh@Number + \else + \begingroup + \escapechar=92 % backslash + \@PackageInfo{alphalph}{% + Number of symbols for \string#1 is \AlPh@Number }% - \fi - }% - \fi - }% - \def\aa@alphinclast#1#2{#2#1.}% - \newcommand*{\newalphalph}[3]{% - \PackageError{alphalph}{% - \string\newalphalph\space requires e-TeX% - }\@ehc -\else - \def\aa@make#1#2{% - \ifnum#1<1 % - \else - \@ReturnAfterFi{% - \aa@eprocess#1;#2% - }% - \fi - }% - \def\aa@eprocess#1;#2{% - \ifnum#1<27 % - \@ReturnAfterElseFi{% - #2{#1}% - }% + \endgroup + \expandafter\AlPh@NewAlphAlph + \csname AlPh@Method@#2\expandafter\endcsname + \AlPh@Number!{#1}{#3}% + \fi \else - \@ReturnAfterFi{% - \expandafter\aa@eprocess\number\numexpr(#1-14)/26% - \expandafter\expandafter\expandafter;% - \expandafter\expandafter\expandafter#2% - #2{\numexpr#1-((#1-14)/26)*26}% - }% + \expandafter\AlPh@NewAlphAlph + \csname AlPh@Method@#2\expandafter\endcsname +| \number#4!% ++ \the\numexpr#4!% + {#1}{#3}% \fi - }% - \def\aa@gen@callmake#1#2#3{% - \expandafter\aa@gen@make\expandafter{\number#3}#1{#2}% - }% - \def\aa@gen@make#1#2#3{% - \ifnum#1<1 % + \fi +}% +\def\AlPh@NewAlphAlph#1#2!#3#4{% + \AlPh@IfDefinable#3{% + \ifnum#2>0 % + \def#3{#1{#2}{#4}}% \else - \@ReturnAfterFi{% - \aa@gen@eprocess{#3}#1;#2% - }% - \fi - }% - \def\aa@gen@eprocess#1#2;#3{% - \ifnum#2>#1 % - \@ReturnAfterElseFi{% - \expandafter\aa@gen@eprocess\expandafter{% - \number#1\expandafter + \AlPh@Error{% + Definition of \string#3 failed,\MessageBreak + because number of symbols (#2) is not positive% }% - \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 }% - \def\aa@half#1{% - \number\dimexpr.5\dimexpr #1sp\relax\relax - }% - \newcommand*{\newalphalph}[3]{% - \newcommand*{#1}{}% - \edef#1{% - \noexpand\aa@gen@callmake\noexpand#2{\number\numexpr#3}% - }% - }% -\fi -\catcode`\@=\aa@atcode +} +\newalphalph\AlphAlph\alphalph@Alph{26} +\newalphalph\alphalph\alphalph@alph{26} +\AlPh@AtEnd \endinput %% %% End of file `alphalph.sty'. |