Created
June 14, 2023 15:42
-
-
Save doraTeX/8a5d9bce827c0371760461628c8ed4a8 to your computer and use it in GitHub Desktop.
カウンタ値を全角数字で出力する完全展開可能な命令 \zarabic を定義する
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%!uplatex | |
\documentclass[autodetect-engine,dvipdfmx]{jsarticle} | |
\usepackage{pgffor} | |
\usepackage{xcolor} | |
\usepackage{zarabic} | |
\newcounter{testCounter} | |
\makeatletter | |
\def\test#1{% | |
\setcounter{testCounter}{#1}% | |
Testing \arabic{testCounter} : | |
\begingroup | |
\kansujichar0=`0 | |
\kansujichar1=`1 | |
\kansujichar2=`2 | |
\kansujichar3=`3 | |
\kansujichar4=`4 | |
\kansujichar5=`5 | |
\kansujichar6=`6 | |
\kansujichar7=`7 | |
\kansujichar8=`8 | |
\kansujichar9=`9 | |
\xdef\test@a{\kansuji\csname c@testCounter\endcsname}% | |
\endgroup | |
\edef\test@b{\zarabic{testCounter}}% | |
\ifx\test@a\test@b \textcolor{blue}{OK}(\test@b )\else \textcolor{red}{NG!}\fi | |
\par | |
} | |
\makeatother | |
\begin{document} | |
\foreach \x in {0,...,999}{\test{\x}} | |
\foreach \x in {0,...,999}{\pgfmathrandom{0,9999999}\test{\pgfmathresult}} | |
\end{document} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
\def\zarabic#1{\expandafter\zarabic@ZERO\the\csname c@#1\endcsname 0\relax} | |
\def\zarabic@ZERO#10#2\relax{% | |
\if"#2"% | |
\zarabic@ONE#11\relax | |
\else | |
\zarabic@ONE#11\relax 0\zarabic@ZERO#2\relax | |
\fi} | |
\def\zarabic@ONE#11#2\relax{% | |
\if"#2"% | |
\zarabic@TWO#12\relax | |
\else | |
\zarabic@TWO#12\relax 1\zarabic@ONE#2\relax | |
\fi} | |
\def\zarabic@TWO#12#2\relax{% | |
\if"#2"% | |
\zarabic@THREE#13\relax | |
\else | |
\zarabic@THREE#13\relax 2\zarabic@TWO#2\relax | |
\fi} | |
\def\zarabic@THREE#13#2\relax{% | |
\if"#2"% | |
\zarabic@FOUR#14\relax | |
\else | |
\zarabic@FOUR#14\relax 3\zarabic@THREE#2\relax | |
\fi} | |
\def\zarabic@FOUR#14#2\relax{% | |
\if"#2"% | |
\zarabic@FIVE#15\relax | |
\else | |
\zarabic@FIVE#15\relax 4\zarabic@FOUR#2\relax | |
\fi} | |
\def\zarabic@FIVE#15#2\relax{% | |
\if"#2"% | |
\zarabic@SIX#16\relax | |
\else | |
\zarabic@SIX#16\relax 5\zarabic@FIVE#2\relax | |
\fi} | |
\def\zarabic@SIX#16#2\relax{% | |
\if"#2"% | |
\zarabic@SEVEN#17\relax | |
\else | |
\zarabic@SEVEN#17\relax 6\zarabic@SIX#2\relax | |
\fi} | |
\def\zarabic@SEVEN#17#2\relax{% | |
\if"#2"% | |
\zarabic@EIGHT#18\relax | |
\else | |
\zarabic@EIGHT#18\relax 7\zarabic@SEVEN#2\relax | |
\fi} | |
\def\zarabic@EIGHT#18#2\relax{% | |
\if"#2"% | |
\zarabic@NINE#19\relax | |
\else | |
\zarabic@NINE#19\relax 8\zarabic@EIGHT#2\relax | |
\fi} | |
\def\zarabic@NINE#19#2\relax{% | |
\if"#2"% | |
#1% | |
\else | |
#19\zarabic@NINE#2\relax | |
\fi} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment