jeudi 4 décembre 2014

Weird tipx error


Just for fun I wrote a converter for decimal numbers that prints them in bases < 37:



\documentclass{article}
\usepackage{fixltx2e,hyperref,ifthen}
\usepackage{tipx}

\makeatletter
\newcount\mod

\newcommand*{\modulo}[2]{%
\mod=#1
\@tempcnta=#2
\ifnum\mod<\@tempcnta\else
\loop
\advance\mod by -#2
\unless\ifnum\mod<#2
\repeat
\fi}%

\newcount\cnv@quotient \cnv@quotient=0
\newcount\cnv@power \cnv@power=1
\newcount\cnv \cnv=0
\def\comv{}

\newcommand*{\convertdec}[2][2]{%
\let\uppercase\relax %if symbols should not be uppercased
\cnv@quotient=#2
\whiledo{\cnv@quotient>0}{%
\modulo{\cnv@quotient}{#1}
\xdef\conv{\uppercase{\basechange{\the\mod}}\conv}
\divide\cnv@quotient by #1}%
\texorpdfstring{\conv\textsubscript{#1}}{\conv}
\let\conv\@empty}%
\newcommand{\basechange}[1]{%
\ifcase#1
0\or 1\or 2\or 3\or 4\or 5\or 6\or 7\or 8\or 9\or
\x \or \xi \or \xii \or \xiii \or \xiv \or \xv \or
\xvi \or \xvii \or \xviii \or \xix \or \xx \or
\xxi \or \xxii \or \xxiii \or \xxiv \or \xxv \or
\xxvi \or \xxvii \or \xxviii \or \xxix \or \xxx \or
\xxxi \or \xxxii \or \xxxiii \or \xxxiv \or \xxxv\fi}%
\def\x{a}
\def\xi{b}
\def\xii{c}
%and so on
\makeatother

\begin{document}
\convertdec[12]{131}
\end{document}


If I change the digit control words like



\def\x{$\alpha$}
\def\xi{$\beta$}


everything is fine. But, when I say \def\x{\textturntwo} the compilation won't terminate; seems to end up in a infinite loop. The strange thing is that the console does not yield a TeX capacity exceeded message. The .log file is just incomplete. What is going wrong here?





Aucun commentaire:

Enregistrer un commentaire