| 1 |
% \iffalse |
| 2 |
% +AMDG This document was begun on 14 November 2008, the |
| 3 |
% feast of St. Josaphat, and it is humbly dedicated to him |
| 4 |
% and to the Immaculate Heart of Mary for their prayers, and |
| 5 |
% to the Sacred Heart of Jesus for His mercy. |
| 6 |
% |
| 7 |
% This document is copyright 2008-2018 by Donald P. Goodman, and is |
| 8 |
% released publicly under the LaTeX Project Public License. The |
| 9 |
% distribution and modification of this work is constrained by the |
| 10 |
% conditions of that license. See |
| 11 |
% http://www.latex-project.org/lppl.txt |
| 12 |
% for the text of the license. This document is released |
| 13 |
% under version 1.3 of that license, and this work may be distributed |
| 14 |
% or modified under the terms of that license or, at your option, any |
| 15 |
% later version. |
| 16 |
% |
| 17 |
% This work has the LPPL maintenance status 'maintained'. |
| 18 |
% |
| 19 |
% The Current Maintainer of this work is Donald P. Goodman |
| 20 |
% ([email protected]). |
| 21 |
% |
| 22 |
% This work consists of the files listed in dozenalfilelist.txt. |
| 23 |
% \fi |
| 24 |
|
| 25 |
% \iffalse |
| 26 |
%<package>\NeedsTeXFormat{LaTeX2e}[1999/12/01] |
| 27 |
%<package>\ProvidesPackage{dozenal}[2018/05/11 v7.2 support for dozenal fonts] |
| 28 |
%<*driver> |
| 29 |
|
| 30 |
\documentclass{ltxdoc} |
| 31 |
\usepackage{doc} |
| 32 |
\usepackage{verbatim} |
| 33 |
\usepackage{url} |
| 34 |
\usepackage[typeone]{dozenal} |
| 35 |
\usepackage{mflogo} |
| 36 |
\usepackage{makeidx} |
| 37 |
\makeindex |
| 38 |
\long\def\demonstrate#1#2{% |
| 39 |
\bigskip% |
| 40 |
\hrule% |
| 41 |
\hbox to\linewidth{% |
| 42 |
\hbox to0.5\linewidth{% |
| 43 |
\vbox to2in{\vfil#1\vfil}% |
| 44 |
}\hbox to0.5\linewidth{% |
| 45 |
\vbox to2in{\vfil#2\vfil}% |
| 46 |
}% |
| 47 |
}% |
| 48 |
\hrule% |
| 49 |
\bigskip% |
| 50 |
} |
| 51 |
|
| 52 |
\begin{document} |
| 53 |
\DocInput{dozenal.dtx} |
| 54 |
\end{document} |
| 55 |
%</driver> |
| 56 |
% \fi |
| 57 |
% \title{The \texttt{dozenal} Package, v7.2} |
| 58 |
% \author{Donald P.\ Goodman III} |
| 59 |
% \date{\today} |
| 60 |
% |
| 61 |
% \maketitle |
| 62 |
% \begin{abstract}\noindent |
| 63 |
% The |dozenal| package provides some simple mechanisms for |
| 64 |
% working with the dozenal (duodecimal or ``base 12'') |
| 65 |
% numerical system. It redefines all basic \LaTeX\ |
| 66 |
% counters, provides a command for converting arbitrary |
| 67 |
% decimal numbers into dozenal, and provides new, real |
| 68 |
% \MF\ characters for ten and eleven, though the |
| 69 |
% commands for producing them can be redefined to produce |
| 70 |
% any figure. As of v2.0, it also includes Type 1 versions |
| 71 |
% of the fonts, selected (as of v5.0) with the |typeone| |
| 72 |
% package option. This package uses the |\basexii| |
| 73 |
% algorithm by David Kastrup. |
| 74 |
% \end{abstract} |
| 75 |
% |
| 76 |
% \tableofcontents |
| 77 |
% |
| 78 |
% \section{Introduction} |
| 79 |
% \label{sect:intro} |
| 80 |
% |
| 81 |
% While most would probably call it at best overoptimistic and |
| 82 |
% at worst foolish, some people (the author included) do still |
| 83 |
% find themselves attracted to the dozenal (base-twelve) |
| 84 |
% system. These people, however, have been pretty hard |
| 85 |
% up\footnote{This is an Americanism for ``out of luck'' or |
| 86 |
% ``in difficult circumstances,'' for those who do not |
| 87 |
% know.} in the \LaTeX\ world. There is no package file |
| 88 |
% available which produces dozenal counters, like page and |
| 89 |
% chapter numbers, nor were there \emph{any} (I made a |
| 90 |
% pretty diligent search) dozenal characters for ten and |
| 91 |
% eleven, leaving dozenalists forced to use such makeshift |
| 92 |
% ugliness as the ``X/E'' or ``T/E'' or ``*/\#'' or whatever |
| 93 |
% other standard they decided to use. While this sort of |
| 94 |
% thing may be acceptable in ASCII, it's absolutely |
| 95 |
% unacceptable in a beautiful, typeset document. |
| 96 |
% |
| 97 |
% Enter the |dozenal| package. This package automates all |
| 98 |
% the messiness of being a dozenalist and using \LaTeX. It |
| 99 |
% redefines all the counters (though you'll have to redefine |
| 100 |
% them yourself if you're using your own), provides an |
| 101 |
% algorithm (generously donated by the intrepid David |
| 102 |
% Kastrup) for converting arbitrary positive whole numbers |
| 103 |
% into dozenal (this is e\TeX, but all modern distributions |
| 104 |
% will compile that), and finally, it includes original |
| 105 |
% dozenal characters, specifically designed to blend in well |
| 106 |
% with Knuth's Computer Modern fonts, though they should do |
| 107 |
% fine with a few other common body fonts, as well. |
| 108 |
% |
| 109 |
% This document was typeset in accordance with the \LaTeX\ |
| 110 |
% \textsc{docstrip} utility, which allows automatic |
| 111 |
% extraction of source code and documentation from the same |
| 112 |
% source. |
| 113 |
% |
| 114 |
% \section{Basic Functionality} |
| 115 |
% \label{sect:func} |
| 116 |
% |
| 117 |
% The |dozenal| package performs several basic tasks, which |
| 118 |
% are the core of its functionality. A brief listing of |
| 119 |
% them will help the user understand the options available, |
| 120 |
% which are explained later on in this document. |
| 121 |
% |
| 122 |
% \begin{itemize} |
| 123 |
% \item Provides commands for converting decimal numbers to |
| 124 |
% dozenal and back again. (The ``back again,'' conversion |
| 125 |
% of dozenal back to decimal, only works in limited |
| 126 |
% circumstances.) |
| 127 |
% \item Provides default characters for the two transdecimal |
| 128 |
% digits, ``\x'' for ten and ``\e'' for eleven; these |
| 129 |
% correspond to the accepted Unicode standard digits |
| 130 |
% ``turned digit two'' and ``turned digit three,'' which (as |
| 131 |
% of June 11\e\e) are now part of the Unicode standard. |
| 132 |
% These characters copy-paste as ``X'' and |
| 133 |
% ``E,'' the (somewhat) standard ASCII representations of |
| 134 |
% these two digits. However, other characters can easily be |
| 135 |
% substituted if desired. |
| 136 |
% \item Redefines the counters in standard \LaTeX\ document |
| 137 |
% classes (such as |article|, |book|, and so forth) to use |
| 138 |
% dozenal rather than decimal. This behavior can be shut |
| 139 |
% off if desired. |
| 140 |
% \item Provides macros for converting dozenal numbers to |
| 141 |
% words; e.g., ``3\e'' to ``three dozen eleven.'' |
| 142 |
% \item Provides macros for converting numbers to ``doman'' |
| 143 |
% numerals; that is, a dozenal version of Roman numerals. |
| 144 |
% \end{itemize} |
| 145 |
% |
| 146 |
% That covered, we can now move on to how these features are |
| 147 |
% exploited by the user. |
| 148 |
% |
| 149 |
% \subsection{Base Conversion} |
| 150 |
% \label{sub:numconv} |
| 151 |
% |
| 152 |
% The |dozenal| package provides several new commands for |
| 153 |
% base conversion. The first, and by far the most important |
| 154 |
% given the purpose and content of this package, is |
| 155 |
% |\basexii|\DescribeMacro{\basexii}. This is a very simple |
| 156 |
% command which takes the following structure: |
| 157 |
% \begin{quote} |
| 158 |
% \cs{basexii}\marg{number}\marg{ten symbol}\marg{eleven symbol} |
| 159 |
% \end{quote} |
| 160 |
% What the above means is that the command is |\basexii| and |
| 161 |
% it takes three mandatory arguments: first, the number to |
| 162 |
% be converted into dozenal; second, the symbol that should |
| 163 |
% be used for ten; and third, the symbol that should be used |
| 164 |
% for eleven. This number should be positive and whole; |
| 165 |
% that is, it should be zero or higher, and it should not |
| 166 |
% contain a fractional part. \TeX\ is a typesetting |
| 167 |
% program, after all; if you want a robust decimal to |
| 168 |
% dozenal converter, there are many options that any |
| 169 |
% dozenalists caring enough to use this package will already |
| 170 |
% know about. |
| 171 |
% |
| 172 |
% This |\basexii| algorithm was produced by David Kastrup, |
| 173 |
% well known and admired in the \TeX\ world for his many |
| 174 |
% useful packages and other contributions. He posted this |
| 175 |
% algorithm on comp.text.tex; it is included here with his |
| 176 |
% kind and generous permission. |
| 177 |
% |
| 178 |
% \label{page:dozens} |
| 179 |
% That one would want to use the same ten and eleven symbols |
| 180 |
% throughout a document seems a reasonable assumption; |
| 181 |
% therefore, I have provided a simplified version of the |
| 182 |
% |\basexii| command, |\dozens|\DescribeMacro{\dozens}. |
| 183 |
% |\dozens| takes only a single argument, the number to be |
| 184 |
% converted; the ten and eleven symbols used are those |
| 185 |
% produced by the commands |\x| and |\e|, to which we'll get |
| 186 |
% in a moment. |
| 187 |
% |
| 188 |
% Finally, as of v5.0, we can convert numbers back to |
| 189 |
% decimal from dozenal, if we wish. We do this with the |
| 190 |
% \DescribeMacro{\basex}|\basex| macro, which takes a single |
| 191 |
% argument, which is the dozenal number you wish to convert |
| 192 |
% to decimal. This is subject to a pretty harsh |
| 193 |
% restriction, however: the only tokens allowed in |
| 194 |
% the number are 0--9, |X|, and |E|; putting in anything |
| 195 |
% else will cause violent choking with ``expected a |
| 196 |
% number''-type errors. |
| 197 |
% |
| 198 |
% To illustrate these limitations, let's define a new |
| 199 |
% counter and dozenize it. Here, we define the counter and |
| 200 |
% give it a nice value which will ensure that its dozenal |
| 201 |
% value will have an |\e| in it: |
| 202 |
% |
| 203 |
% \newcounter{testcount}\setcounter{testcount}{47} |
| 204 |
% \begin{quotation} |
| 205 |
% |\newcounter{testcount}\setcounter{testcount}{47}| |
| 206 |
% \end{quotation} |
| 207 |
% |
| 208 |
% In dozenal, of course, ``47'' is ``3\e.'' Now, let's |
| 209 |
% redefine that counter so that its results will be dozenal: |
| 210 |
% |
| 211 |
% \renewcommand\thetestcount{\basexii{\value{testcount}}{\x}{\e}} |
| 212 |
% \begin{quotation} |
| 213 |
% |\renewcommand\thetestcount{\basexii{\value{testcount}}{\x}{\e}}| |
| 214 |
% \end{quotation} |
| 215 |
% |
| 216 |
% Now |dozenal| allow us to do lovely things like the following: |
| 217 |
% |
| 218 |
% \begin{quotation} |
| 219 |
% |\thetestcount| = \thetestcount |
| 220 |
% \end{quotation} |
| 221 |
% |
| 222 |
% It's tempting to try to put that number into |\basex| to |
| 223 |
% get it in decimal; but don't try it; |
| 224 |
% |\basex{\thetestcount}| doesn't work because it contains |
| 225 |
% expanded versions of |\x| and |\e|. Fortunately, you |
| 226 |
% don't need it; \LaTeX\ already has the value of the |
| 227 |
% |testcount| counter in its innards, and is quite used to |
| 228 |
% outputting it in decimal: |
| 229 |
% |
| 230 |
% \begin{quotation} |
| 231 |
% |\arabic{testcount}| = \arabic{testcount} |
| 232 |
% \end{quotation} |
| 233 |
% |
| 234 |
% On the other hand, if you have an actual string you want |
| 235 |
% converted, you can send it directly to |\basex|: |
| 236 |
% |
| 237 |
% \begin{quotation} |
| 238 |
% |\basex{3E}| = \basex{3E} |
| 239 |
% \end{quotation} |
| 240 |
% |
| 241 |
% So |\basex| is of limited utility, but it's a nice tool to |
| 242 |
% add to the box. |
| 243 |
% |
| 244 |
% \subsection{Numbers to Words} |
| 245 |
% \label{sub:numtowords} |
| 246 |
% |
| 247 |
% |dozenal| allows you to easily convert counters into |
| 248 |
% \emph{words}, by supplying said counter's name to the |
| 249 |
% \DescribeMacro{\doznumtoword}|\doznumtoword| macro. It |
| 250 |
% takes as its argument the name of a \emph{counter} (not a |
| 251 |
% number itself!) and converts this into words: |
| 252 |
% |
| 253 |
% \newcounter{somecount}\setcounter{somecount}{851} |
| 254 |
% \begin{quote} |
| 255 |
% |This page's number is ``\doznumtoword{page}.''| \\ |
| 256 |
% This page's number is ``\doznumtoword{page}.'' |
| 257 |
% \end{quote} |
| 258 |
% |
| 259 |
% This macro works with much larger numbers, as well. |
| 260 |
% Purely for exemplary purposes, let's define a counter |
| 261 |
% |somecount| with |\newcounter{somecount}|, and set it |
| 262 |
% equal to (decimal) 851 with |\setcounter{somecount}{851}|. |
| 263 |
% ``851'' |
| 264 |
% in dozenal is ``5\x\e.'' Therefore, |
| 265 |
% |\doznumtoword{somecount}| will yield |
| 266 |
% ``\doznumtoword{somecount}.'' If you want to change the |
| 267 |
% capitalization, use other macros; e.g., |
| 268 |
% \DescribeMacro{\DOZnumtoword}|\DOZnumtoword{somecount}| gives |
| 269 |
% ``\DOZnumtoword{somecount},'' while |
| 270 |
% \DescribeMacro{\Doznumtoword}|\Doznumtoword{somecount}| gives |
| 271 |
% ``\Doznumtoword{somecount}.'' |
| 272 |
% |
| 273 |
% |\doznumtoword| (and friends) do act correctly when there |
| 274 |
% are zeroes in the middle of the number, e.g., when |
| 275 |
% |somecount| is equal to decimal 6977, which is dozenal |
| 276 |
% 4055, it will output |
| 277 |
% \setcounter{somecount}{6977}``\doznumtoword{somecount}.'' |
| 278 |
% When there's a zero at the \emph{end} of the number, that |
| 279 |
% zero is still output: |\doznumtoword{somecount}| where |
| 280 |
% |somecount|\setcounter{somecount}{144} is equal to 144 gives |
| 281 |
% ``\doznumtoword{somecount},'' not simply ``one biqua.'' I |
| 282 |
% haven't decided yet if this is a bug or a feature; when I |
| 283 |
% do, I'll act accordingly. |
| 284 |
% |
| 285 |
% The rank words (``unqua,'' ``biqua,'' and so forth) are |
| 286 |
% all customizable by user-level commands, which are named |
| 287 |
% |\dozrankoneword| for ``unqua,'' |\dozranktwoword| for |
| 288 |
% ``biqua,'' and so forth. Simply redefine them like so: |
| 289 |
% |
| 290 |
% \begin{quote} |
| 291 |
% |\def\dozrankoneword{dozen}|\def\dozrankoneword{dozen} \\ |
| 292 |
% |\setcounter{somecount}{51}|\setcounter{somecount}{51} \\ |
| 293 |
% |\doznumtoword{somecount}| = \doznumtoword{somecount} |
| 294 |
% \end{quote} |
| 295 |
% \def\dozrankoneword{unqua} |
| 296 |
% |
| 297 |
% This type of macro is useful for putting page numbers in |
| 298 |
% both digits and words, for example. |
| 299 |
% |
| 300 |
% \subsection{Doman Numerals} |
| 301 |
% \label{sub:domannums} |
| 302 |
% |
| 303 |
% Dozenalists have also come up with some ideas for how to |
| 304 |
% use Roman numerals in a decimal way; therefore, the |
| 305 |
% |dozenal| package provides some macros to assist with |
| 306 |
% that, as well. |
| 307 |
% |
| 308 |
% To form ``Doman'' numerals, we simply alter the values of |
| 309 |
% the traditional Roman characters into more |
| 310 |
% dozenal-friendly alternatives. So ``v'' is 6, ``x'' is |
| 311 |
% 10, and so on. Then, to avoid stringing four of the same |
| 312 |
% character together, we extend the subtractive principle to |
| 313 |
% allow up to \emph{two} lower characters prior to a |
| 314 |
% higher-value character. So, e.g., ``iiv'' is $6 - 2$, or |
| 315 |
% 4, while ``iv'' is $6 - 1$, or 5. |
| 316 |
% |
| 317 |
% The macros |\Doman|\DescribeMacro{\Doman}\ and |
| 318 |
% |\doman|\DescribeMacro{\doman}\ are equivalent to |\Roman| |
| 319 |
% and |\roman|, giving either capitalized or lowercase |
| 320 |
% dozenal Roman numerals. |
| 321 |
% |
| 322 |
% \newcounter{testdoman}\setcounter{testdoman}{1} |
| 323 |
% \renewcommand\thetestdoman{\doman{\value{testdoman}}} |
| 324 |
% |
| 325 |
% \begin{center} |
| 326 |
% \begin{tabular}{cccccccccccccc} |
| 327 |
% \dozens{\value{testdoman}} & \thetestdoman\stepcounter{testdoman} & |
| 328 |
% \dozens{\value{testdoman}} & \thetestdoman\stepcounter{testdoman} & |
| 329 |
% \dozens{\value{testdoman}} & \thetestdoman\stepcounter{testdoman} & |
| 330 |
% \dozens{\value{testdoman}} & \thetestdoman\stepcounter{testdoman} & |
| 331 |
% \dozens{\value{testdoman}} & \thetestdoman\stepcounter{testdoman} & |
| 332 |
% \dozens{\value{testdoman}} & \thetestdoman\stepcounter{testdoman} \\ |
| 333 |
% \dozens{\value{testdoman}} & \thetestdoman\stepcounter{testdoman} & |
| 334 |
% \dozens{\value{testdoman}} & \thetestdoman\stepcounter{testdoman} & |
| 335 |
% \dozens{\value{testdoman}} & \thetestdoman\stepcounter{testdoman} & |
| 336 |
% \dozens{\value{testdoman}} & \thetestdoman\stepcounter{testdoman} & |
| 337 |
% \dozens{\value{testdoman}} & \thetestdoman\stepcounter{testdoman} & |
| 338 |
% \dozens{\value{testdoman}} & \thetestdoman\stepcounter{testdoman} \\ |
| 339 |
% \dozens{\value{testdoman}} & \thetestdoman\stepcounter{testdoman} & |
| 340 |
% \dozens{\value{testdoman}} & \thetestdoman\stepcounter{testdoman} & |
| 341 |
% \dozens{\value{testdoman}} & \thetestdoman\stepcounter{testdoman} & |
| 342 |
% \dozens{\value{testdoman}} & \thetestdoman\stepcounter{testdoman} & |
| 343 |
% \dozens{\value{testdoman}} & \thetestdoman\stepcounter{testdoman} & |
| 344 |
% \dozens{\value{testdoman}} & \thetestdoman\stepcounter{testdoman} \\ |
| 345 |
% \dozens{\value{testdoman}} & \thetestdoman\stepcounter{testdoman} & |
| 346 |
% \dozens{\value{testdoman}} & \thetestdoman\stepcounter{testdoman} & |
| 347 |
% \dozens{\value{testdoman}} & \thetestdoman\stepcounter{testdoman} & |
| 348 |
% \dozens{\value{testdoman}} & \thetestdoman\stepcounter{testdoman} & |
| 349 |
% \dozens{\value{testdoman}} & \thetestdoman\stepcounter{testdoman} & |
| 350 |
% \dozens{\value{testdoman}} & \thetestdoman\stepcounter{testdoman} \\ |
| 351 |
% \dozens{\value{testdoman}} & \thetestdoman\stepcounter{testdoman} & |
| 352 |
% \dozens{\value{testdoman}} & \thetestdoman\stepcounter{testdoman} & |
| 353 |
% \dozens{\value{testdoman}} & \thetestdoman\stepcounter{testdoman} & |
| 354 |
% \dozens{\value{testdoman}} & \thetestdoman\stepcounter{testdoman} & |
| 355 |
% \dozens{\value{testdoman}} & \thetestdoman\stepcounter{testdoman} & |
| 356 |
% \dozens{\value{testdoman}} & \thetestdoman\stepcounter{testdoman} \\ |
| 357 |
% \dozens{\value{testdoman}} & \thetestdoman\stepcounter{testdoman} & |
| 358 |
% \dozens{\value{testdoman}} & \thetestdoman\stepcounter{testdoman} & |
| 359 |
% \dozens{\value{testdoman}} & \thetestdoman\stepcounter{testdoman} & |
| 360 |
% \dozens{\value{testdoman}} & \thetestdoman\stepcounter{testdoman} & |
| 361 |
% \dozens{\value{testdoman}} & \thetestdoman\stepcounter{testdoman} & |
| 362 |
% \dozens{\value{testdoman}} & \thetestdoman\stepcounter{testdoman} \\ |
| 363 |
% \dozens{\value{testdoman}} & \thetestdoman\stepcounter{testdoman} & |
| 364 |
% \dozens{\value{testdoman}} & \thetestdoman\stepcounter{testdoman} & |
| 365 |
% \dozens{\value{testdoman}} & \thetestdoman\stepcounter{testdoman} & |
| 366 |
% \dozens{\value{testdoman}} & \thetestdoman\stepcounter{testdoman} & |
| 367 |
% \dozens{\value{testdoman}} & \thetestdoman\stepcounter{testdoman} & |
| 368 |
% \dozens{\value{testdoman}} & \thetestdoman\stepcounter{testdoman} \\ |
| 369 |
% \dozens{\value{testdoman}} & \thetestdoman\stepcounter{testdoman} & |
| 370 |
% \dozens{\value{testdoman}} & \thetestdoman\stepcounter{testdoman} & |
| 371 |
% \dozens{\value{testdoman}} & \thetestdoman\stepcounter{testdoman} & |
| 372 |
% \dozens{\value{testdoman}} & \thetestdoman\stepcounter{testdoman} & |
| 373 |
% \dozens{\value{testdoman}} & \thetestdoman\stepcounter{testdoman} & |
| 374 |
% \dozens{\value{testdoman}} & \thetestdoman\stepcounter{testdoman} \\ |
| 375 |
% \dozens{\value{testdoman}} & \thetestdoman\stepcounter{testdoman} & |
| 376 |
% \dozens{\value{testdoman}} & \thetestdoman\stepcounter{testdoman} & |
| 377 |
% \dozens{\value{testdoman}} & \thetestdoman\stepcounter{testdoman} & |
| 378 |
% \dozens{\value{testdoman}} & \thetestdoman\stepcounter{testdoman} & |
| 379 |
% \dozens{\value{testdoman}} & \thetestdoman\stepcounter{testdoman} & |
| 380 |
% \dozens{\value{testdoman}} & \thetestdoman\stepcounter{testdoman} \\ |
| 381 |
% \dozens{\value{testdoman}} & \thetestdoman\stepcounter{testdoman} & |
| 382 |
% \dozens{\value{testdoman}} & \thetestdoman\stepcounter{testdoman} & |
| 383 |
% \dozens{\value{testdoman}} & \thetestdoman\stepcounter{testdoman} & |
| 384 |
% \dozens{\value{testdoman}} & \thetestdoman\stepcounter{testdoman} & |
| 385 |
% \dozens{\value{testdoman}} & \thetestdoman\stepcounter{testdoman} & |
| 386 |
% \dozens{\value{testdoman}} & \thetestdoman\stepcounter{testdoman} \\ |
| 387 |
% \dozens{\value{testdoman}} & \thetestdoman\stepcounter{testdoman} & |
| 388 |
% \dozens{\value{testdoman}} & \thetestdoman\stepcounter{testdoman} & |
| 389 |
% \dozens{\value{testdoman}} & \thetestdoman\stepcounter{testdoman} & |
| 390 |
% \dozens{\value{testdoman}} & \thetestdoman\stepcounter{testdoman} & |
| 391 |
% \dozens{\value{testdoman}} & \thetestdoman\stepcounter{testdoman} & |
| 392 |
% \dozens{\value{testdoman}} & \thetestdoman\stepcounter{testdoman} \\ |
| 393 |
% \dozens{\value{testdoman}} & \thetestdoman\stepcounter{testdoman} & |
| 394 |
% \dozens{\value{testdoman}} & \thetestdoman\stepcounter{testdoman} & |
| 395 |
% \dozens{\value{testdoman}} & \thetestdoman\stepcounter{testdoman} & |
| 396 |
% \dozens{\value{testdoman}} & \thetestdoman\stepcounter{testdoman} & |
| 397 |
% \dozens{\value{testdoman}} & \thetestdoman\stepcounter{testdoman} & |
| 398 |
% \dozens{\value{testdoman}} & \thetestdoman\stepcounter{testdoman} \\ |
| 399 |
% \end{tabular} |
| 400 |
% \end{center} |
| 401 |
% |
| 402 |
% In the table above, the Doman numerals 1--60 are |
| 403 |
% displayed, along with their Hindu-Arabic equivalents. This |
| 404 |
% table was produced entirely using a new \LaTeX\ counter, |
| 405 |
% |testdoman|; |\thetestdoman| was defined by saying |
| 406 |
% |
| 407 |
% \begin{quote} |
| 408 |
% |\renewcommand\thetestdoman{\doman{\value{testdoman}}}| |
| 409 |
% \end{quote} |
| 410 |
% |
| 411 |
% The Hindu-Arabic columns were displayed with |
| 412 |
% |\dozens{\value{testdoman}}|. Every two table cells, |
| 413 |
% |testdoman| is increased by one. The whole table was |
| 414 |
% produced without manually entering a single number in |
| 415 |
% either form. |
| 416 |
% |
| 417 |
% Most commonly, Roman numerals are seen in part numbers and |
| 418 |
% in the page numbering of frontmatter. |
| 419 |
% To achieve that result, do: |
| 420 |
% |
| 421 |
% \begin{quote} |
| 422 |
% |\renewcommand\thepage{\doman{\arabic{page}}}| |
| 423 |
% \end{quote} |
| 424 |
% |
| 425 |
% You can reset this to normal dozenal numerals (or whatever |
| 426 |
% else you'd prefer) when you reach your mainmatter. |
| 427 |
% |
| 428 |
% \section{Dozenal Characters and Fonts} |
| 429 |
% \label{sect:fonts} |
| 430 |
% |
| 431 |
% \subsection{Shorthands for Dozenal Characters} |
| 432 |
% \label{sub:shorthands} |
| 433 |
% |
| 434 |
% To make use of the |\dozens| shorthand discussed |
| 435 |
% earlier,\footnote{See supra, Section \ref{sub:numconv}, |
| 436 |
% at page \pageref{page:dozens}.} you need to have the |
| 437 |
% commands |\x| and |\e| defined. Fortunately, this package |
| 438 |
% does that for you. |
| 439 |
% |
| 440 |
% |\x|\DescribeMacro{\x}\ and |\e|\DescribeMacro{\e}\ are |
| 441 |
% the commands used to quickly and easily access the symbols |
| 442 |
% for ten and eleven. They default to using the special |
| 443 |
% dozenal characters that are part of this package; they |
| 444 |
% could be easily redefined if for some reason you don't |
| 445 |
% like the Pitman characters (which are soon to be included |
| 446 |
% in Unicode) in the following manner: |
| 447 |
% \begin{quote} |
| 448 |
% |\renewcommand\x{X}| |
| 449 |
% \end{quote} |
| 450 |
% Or whichever characters you like to use. If you prefer |
| 451 |
% the Dozenal Society of America's proposed characters (a |
| 452 |
% stylized X and E), then this package will disappoint you. |
| 453 |
% May I suggest |$\chi$| ($\chi$) and |$\xi$| ($\xi$) as a |
| 454 |
% stopgap while you locate or produce real characters of |
| 455 |
% your own? Sorry; I'm an American myself, but I much |
| 456 |
% prefer the Pitman characters for a variety of reasons |
| 457 |
% (feel free to email me if you care), and creating fonts in |
| 458 |
% \MF, even small and inconsequential ones like this, is too |
| 459 |
% much work for characters that I don't even like. |
| 460 |
% |
| 461 |
% \subsection{The \texttt{dozenal} Fonts} |
| 462 |
% \label{sub:dozfonts} |
| 463 |
% |
| 464 |
% The fonts provided by the dozenal package are essentially |
| 465 |
% complete fonts which contain only the Pitman dozenal |
| 466 |
% characters; these are \x\ for ten and \e\ for eleven. |
| 467 |
% These characters are designed to blend well with the |
| 468 |
% Computer Modern fonts; they work passably well with |
| 469 |
% Times-type fonts and with kpfonts, and possibly with |
| 470 |
% others. |
| 471 |
% |
| 472 |
% The characters also come in all the appropriate shapes and |
| 473 |
% sizes; a few examples follow. |
| 474 |
% |
| 475 |
% \begin{center} |
| 476 |
% \begin{tabular}{lccc} |
| 477 |
% {} & Roman & \textit{Italic} & \textbf{Boldface} \\ |
| 478 |
% \footnotesize Footnotesize & \footnotesize\x\ \e & \footnotesize\itshape |
| 479 |
% \x\ \e & \footnotesize\bfseries \x \e \\ |
| 480 |
% \normalsize Normalsize & \normalsize\x\ \e & \normalsize\itshape |
| 481 |
% \x\ \e & \normalsize\bfseries \x \e \\ |
| 482 |
% \LARGE LARGE & \LARGE\x\ \e & \LARGE\itshape |
| 483 |
% \x\ \e & \LARGE\bfseries \x \e \\ |
| 484 |
% \Huge Huge & \Huge\x\ \e & \Huge\itshape |
| 485 |
% \x\ \e & \Huge\bfseries \x \e \\ |
| 486 |
% \end{tabular} |
| 487 |
% \end{center} |
| 488 |
% |
| 489 |
% They will work in paragraph or math mode without |
| 490 |
% distinction. |
| 491 |
% |
| 492 |
% \subsection{Tally Marks} |
| 493 |
% \label{sub:tallymarks} |
| 494 |
% |
| 495 |
% As of v4.0, |dozenal| also includes fonts for tally marks |
| 496 |
% specifically designed for use in the dozenal base. In many |
| 497 |
% European countries tallies are kept in a very similar way; |
| 498 |
% this font demonstrates a way that such tally marks can be |
| 499 |
% made consistent as well as dozenal. |
| 500 |
% |
| 501 |
% \begin{center} |
| 502 |
% \begin{tabular}{cccccc} |
| 503 |
% 1 & 2 & 3 & 4 & 5 & 6 \\ |
| 504 |
% \Huge\tally{1} & \Huge\tally{2} & \Huge\tally{3} & \Huge\tally{4} & \Huge\tally{5} & \Huge\tally{6} \\ |
| 505 |
% \end{tabular} |
| 506 |
% \end{center} |
| 507 |
% |
| 508 |
% These are accessed by the \DescribeMacro{\tally}|\tally| |
| 509 |
% command, which takes one argument: the number, 1--6, |
| 510 |
% which you want to put in tallies. Entering ``X'' or ``E'' |
| 511 |
% will yield ``\x'' or ``\e'' respectively. Other |
| 512 |
% characters will produce nothing. |
| 513 |
% |
| 514 |
% As of v6.0, there are separate, hand-written versions of |
| 515 |
% the tally marks, accessed by putting tallies in italic: |
| 516 |
% |
| 517 |
% \begin{center}\itshape |
| 518 |
% \begin{tabular}{cccccc} |
| 519 |
% 1 & 2 & 3 & 4 & 5 & 6 \\ |
| 520 |
% \Huge\tally{1} & \Huge\tally{2} & \Huge\tally{3} & \Huge\tally{4} & \Huge\tally{5} & \Huge\tally{6} \\ |
| 521 |
% \end{tabular} |
| 522 |
% \end{center} |
| 523 |
% |
| 524 |
% In other words, to get these shapes, say |
| 525 |
% |\textit{\tally{6}}|; this will give you |
| 526 |
% ``\textit{\tally{6}}.'' |
| 527 |
% |
| 528 |
% The fonts are all prefixed |dozch|, if for some reason |
| 529 |
% direct access to them is needed. |
| 530 |
% |
| 531 |
% \subsection{Dozenal Radix Point} |
| 532 |
% \label{sub:dozradixpoint} |
| 533 |
% |
| 534 |
% Lastly, |dozenal| allows the use of the common dozenal |
| 535 |
% radix point, ``;'', to work properly in math mode. Some |
| 536 |
% dozenalists prefer to use ``;'' rather than ``.'' (or |
| 537 |
% ``,'') to mark the transition from integers to fractions |
| 538 |
% in numbers; e.g., three-and-a-half is ``3;6.'' In math |
| 539 |
% mode, however, this doesn't work; a semicolon in math |
| 540 |
% mode is punctuation, and a spurious space is inserted |
| 541 |
% (quite correctly) afterward. We don't want this space |
| 542 |
% when we're using it as a radix point. So |dozenal| (using |
| 543 |
% code adapted from Walter Schmidt's |icomma| package) fixes |
| 544 |
% this: |
| 545 |
% |
| 546 |
% |$3;6$| = 3;6 |
| 547 |
% |
| 548 |
% And all is right with the world. |
| 549 |
% |
| 550 |
% \section{Package Options} |
| 551 |
% \label{sect:packopts} |
| 552 |
% |
| 553 |
% The |dozenal| package redefines all the standard |
| 554 |
% \LaTeX\ counters, such as |section| and |enumii|. If |
| 555 |
% you've defined your own counters, you'll need to dozenize |
| 556 |
% them yourself; however, this is an easy matter: |
| 557 |
% \begin{quote} |
| 558 |
% |\renewcommand\thecounter{\basexii{\arabic{counter}}{\x}{\e}}| |
| 559 |
% \end{quote} |
| 560 |
% For example. Of course, you can fill in the |\x| and |\e| |
| 561 |
% with whatever you want (though it would make more sense to |
| 562 |
% simply redefine |\x| and |\e|, so that all the counters |
| 563 |
% would use the same characters), or you could use the |
| 564 |
% |\dozens| command instead. Whatever your pleasure might |
| 565 |
% be. |
| 566 |
% |
| 567 |
% If you \emph{don't} want all the counters to be redefined, |
| 568 |
% or if you're using a class which doesn't include basic |
| 569 |
% \LaTeX\ counters, you'll want to use the |nocounters| |
| 570 |
% option. The |nocounters|\DescribeMacro{nocounters}\ |
| 571 |
% option to the package prevents the redefinition of these |
| 572 |
% counters. The effect of this is that the commands of the |
| 573 |
% package (|\basexii|, |\dozens|, etc.) are made available, |
| 574 |
% but all the counters will still be in decimal. This |
| 575 |
% permits using dozenal characters in an otherwise decimal |
| 576 |
% document; it also proves useful in document classes in |
| 577 |
% which these counters are undefined (e.g., |minimal|). |
| 578 |
% |
| 579 |
% The |dozenal| fonts were designed in \MF, and they are |
| 580 |
% distributed in both \MF-generated bitmaps and autotraced |
| 581 |
% Postscript Type1 fonts. The |
| 582 |
% |typeone|\DescribeMacro{typeone}\ option forces |dozenal| |
| 583 |
% to provide Postscript Type 1 fonts rather than \MF\ |
| 584 |
% bitmaps to \TeX. Both of these are produced from the same |
| 585 |
% font files, though, so the difference is very slight. |
| 586 |
% However, the Type1 fonts do generally look better on |
| 587 |
% screen; the |typeone| option will probably be used most of |
| 588 |
% the time that |dozenal| itself is used. |
| 589 |
% |
| 590 |
% \section{Implementation} |
| 591 |
% \label{sect:code} |
| 592 |
% |
| 593 |
% Make sure that we have |fixltx2e| loaded, so that the |
| 594 |
% |\TextOrMath| magic will work. Also, as of v6.0, we also |
| 595 |
% require |xstring| to use |\IfStrEq| in the number-to-word |
| 596 |
% code. |
| 597 |
% \begin{macrocode} |
| 598 |
\RequirePackage{fixltx2e} |
| 599 |
\RequirePackage{xstring} |
| 600 |
% \end{macrocode} |
| 601 |
% Now we ensure that |ifpdf| is loaded, so that we can test |
| 602 |
% for pdf or dvi modes. We also make sure we have |
| 603 |
% |ifluatex|, so that |dozenal| won't choke when you use it |
| 604 |
% with the |typeone| option. We'll take care of the |
| 605 |
% |luatex| stuff right away, while we're at it: |
| 606 |
% \begin{macrocode} |
| 607 |
\RequirePackage{ifpdf} |
| 608 |
\RequirePackage{ifluatex} |
| 609 |
\ifluatex |
| 610 |
\protected\def\pdfmapfile {\pdfextension mapfile } |
| 611 |
\fi |
| 612 |
% \end{macrocode} |
| 613 |
% We also require |mfirstuc|, because it's \emph{great}: |
| 614 |
% \begin{macrocode} |
| 615 |
\RequirePackage{mfirstuc} |
| 616 |
% \end{macrocode} |
| 617 |
% Now we declare the option ``nocounters'', which prevents |
| 618 |
% |dozenal| from redefining all the counters. This prevents |
| 619 |
% errors in document classes which don't have these counters, |
| 620 |
% such as |minimal|. Defines the command |\nocounters| if |
| 621 |
% and only if the options is named. |
| 622 |
% \begin{macrocode} |
| 623 |
\DeclareOption{nocounters}{% |
| 624 |
\def\nocounters{}% |
| 625 |
}% |
| 626 |
% \end{macrocode} |
| 627 |
% Now we define the |typeone| option, which forces the use |
| 628 |
% of the Type 1 versions of the dozenal fonts. |
| 629 |
% \begin{macrocode} |
| 630 |
\newif\iftypeone\typeonefalse |
| 631 |
\DeclareOption{typeone}{\typeonetrue} |
| 632 |
\ProcessOptions\relax |
| 633 |
% \end{macrocode} |
| 634 |
% We then define the font that we're using for our |
| 635 |
% \MF-produced Pitman characters. Incidentally, we also |
| 636 |
% define the command |\doz|, though I can't foresee any |
| 637 |
% decent use for it except in packages and preambles; it is |
| 638 |
% then used to define |\x| and |\e|, which provide the ten |
| 639 |
% and eleven symbols for all the counter redefinitions. |
| 640 |
% This includes definitions for both T1 and OT1 encodings, |
| 641 |
% so it will work with either. |
| 642 |
% \begin{macrocode} |
| 643 |
\iftypeone% |
| 644 |
\ifpdf |
| 645 |
\pdfmapfile{=dozenal.map} |
| 646 |
\fi |
| 647 |
\DeclareFontFamily{T1}{dozch}{} |
| 648 |
\DeclareFontShape{T1}{dozch}{m}{n}{<-6> dozchars6 |
| 649 |
<7> dozchars7 <8> dozchars8 <9> dozchars9 <10-11> |
| 650 |
dozchars10 <12-16> dozchars12 <17-> dozchars17 }{} |
| 651 |
\DeclareFontShape{T1}{dozch}{b}{n}{<-> dozchb10 }{} |
| 652 |
\DeclareFontShape{T1}{dozch}{bx}{n}{<-6> dozchbx6 |
| 653 |
<7> dozchbx7 <8> dozchbx8 <9> dozchbx9 <10-11> |
| 654 |
dozchbx10 <12-> dozchbx12 }{} |
| 655 |
\DeclareFontShape{T1}{dozch}{m}{sl}{<-8> dozchsl8 |
| 656 |
<9> dozchsl9 <10-11> dozchsl10 <12-> dozchsl12 }{} |
| 657 |
\DeclareFontShape{T1}{dozch}{bx}{sl}{<-> dozchbxsl10 }{} |
| 658 |
\DeclareFontShape{T1}{dozch}{m}{it}{<-7> dozchit7 |
| 659 |
<8> dozchit8 <9> dozchit9 <10-11> dozchit10 |
| 660 |
<12-> dozchit12 }{} |
| 661 |
\DeclareFontShape{T1}{dozch}{bx}{it}{<-> dozchbxi10 }{} |
| 662 |
\def\doz#1{{\fontfamily{dozch}\fontencoding{T1}\selectfont #1}}% |
| 663 |
\DeclareSymbolFont{dozens}{T1}{dozch}{m}{n} |
| 664 |
\else% |
| 665 |
\DeclareFontFamily{OT1}{dozch}{} |
| 666 |
\DeclareFontShape{OT1}{dozch}{m}{n}{<-6> dozchars6 |
| 667 |
<7> dozchars7 <8> dozchars8 <9> dozchars9 <10-11> |
| 668 |
dozchars10 <12-16> dozchars12 <17-> dozchars17 }{} |
| 669 |
\DeclareFontShape{OT1}{dozch}{b}{n}{<-> dozchb10 }{} |
| 670 |
\DeclareFontShape{OT1}{dozch}{bx}{n}{<-6> dozchbx6 |
| 671 |
<7> dozchbx7 <8> dozchbx8 <9> dozchbx9 <10-11> |
| 672 |
dozchbx10 <12-> dozchbx12 }{} |
| 673 |
\DeclareFontShape{OT1}{dozch}{m}{sl}{<-8> dozchsl8 |
| 674 |
<9> dozchsl9 <10-11> dozchsl10 <12-> dozchsl12 }{} |
| 675 |
\DeclareFontShape{OT1}{dozch}{bx}{sl}{<-> dozchbxsl10 }{} |
| 676 |
\DeclareFontShape{OT1}{dozch}{m}{it}{<-7> dozchit7 |
| 677 |
<8> dozchit8 <9> dozchit9 <10-11> dozchit10 |
| 678 |
<12-> dozchit12 }{} |
| 679 |
\DeclareFontShape{OT1}{dozch}{bx}{it}{<-> dozchbxi10 }{} |
| 680 |
\def\doz#1{{\fontfamily{dozch}\fontencoding{OT1}\selectfont #1}}% |
| 681 |
\DeclareSymbolFont{dozens}{OT1}{dozch}{m}{n} |
| 682 |
\fi% |
| 683 |
\newcommand\x{\unexpanded{\TextOrMath{\protect\doz{{X}}}{\doz@X}}}% |
| 684 |
\newcommand\e{\unexpanded{\TextOrMath{\protect\doz{{E}}}{\doz@E}}}% |
| 685 |
\DeclareMathSymbol{\doz@X}{\mathord}{dozens}{88}% |
| 686 |
\DeclareMathSymbol{\doz@E}{\mathord}{dozens}{69}% |
| 687 |
% \end{macrocode} |
| 688 |
% Put in some additional code for the tally marks. |
| 689 |
% \begin{macrocode} |
| 690 |
\newcommand\tally[1]{% |
| 691 |
% \usefont{OT1}{dozch}{m}{n}\selectfont{#1}% |
| 692 |
\doz{#1}% |
| 693 |
}% |
| 694 |
% \end{macrocode} |
| 695 |
% Then we define our command which will produce the dozenal |
| 696 |
% numbers from decimal sources. This algorithm was taken |
| 697 |
% directly from the publicly available archives of |
| 698 |
% comp.text.tex, where it was posted by the well-known and |
| 699 |
% redoubtable David Kastrup. We also define the |\dozens| |
| 700 |
% command, a simplified |\basexii| (which, in fact, depends |
| 701 |
% utterly upon |\basexii|), just to make it easy for |
| 702 |
% everyone. |
| 703 |
% \begin{macrocode} |
| 704 |
\def\basexii#1#2#3{\ifcase\numexpr(#1)\relax |
| 705 |
0\or1\or2\or3\or4\or5\or6\or7\or8\or9\or#2\or#3\else |
| 706 |
\expandafter\basexii\expandafter{\number\numexpr((#1)-6)/12}{#2}{#3}\expandafter\basexii\expandafter{\number\numexpr(#1)-((#1)-6)/12*12}{#2}{#3}\fi} |
| 707 |
\newcommand\dozens[1]{\basexii{#1}{\x}{\e}} |
| 708 |
% \end{macrocode} |
| 709 |
% Now that we can convert numbers \emph{to} dozenal, let's |
| 710 |
% set it up so that we can convert them \emph{from} dozenal. |
| 711 |
% I use |xstring| here, replacing a messy macro mesh from |
| 712 |
% the last version (5.3). |
| 713 |
% \begin{macrocode} |
| 714 |
\newcount\doz@countchar |
| 715 |
\def\doz@charcount#1{% |
| 716 |
\StrLen{#1}[\doz@filler]% |
| 717 |
\doz@countchar=\doz@filler% |
| 718 |
}% |
| 719 |
% \end{macrocode} |
| 720 |
% Now we develop our conversion routines for |\basex|. For |
| 721 |
% v6.0, these were hugely simplified by using the |xstring| |
| 722 |
% package instead of trying to bash through in plain |
| 723 |
% \TeX, which eventually worked but was \emph{not} pretty. |
| 724 |
% We start by defining a few counters to help us out: |
| 725 |
% \begin{macrocode} |
| 726 |
\newcount\doz@lfiller\doz@lfiller=-1% |
| 727 |
\newcount\doz@total\doz@total=0% |
| 728 |
\newcount\doz@loopi\doz@loopi=0% |
| 729 |
\newcount\doz@multiplier\doz@multiplier=1% |
| 730 |
% \end{macrocode} |
| 731 |
% Next we adopt a macro from TeX.SE question 140476, from |
| 732 |
% user "Dan", which works like a charm even when using |
| 733 |
% counter values rather than simple integers. These macros |
| 734 |
% let us grab an individual character from a string; in this |
| 735 |
% case, from the argument of |\basex|. |
| 736 |
% \begin{macrocode} |
| 737 |
% macro from TeX.SE question 140476, posted by user "Dan" |
| 738 |
\def\ninthofmany#1#2#3#4#5#6#7#8#9{#9\gobbletorelax} |
| 739 |
\def\gobbletorelax#1\relax{} |
| 740 |
\def\doz@CharAt#1#2{% |
| 741 |
\expandafter\ninthofmany\romannumeral\numexpr(9000-\number#1000)#2\relax} |
| 742 |
% end "Dan" macro |
| 743 |
% \end{macrocode} |
| 744 |
% Here's where the money happens. We loop through each |
| 745 |
% digit of the argument, multiplying it by the appropriate |
| 746 |
% factor of 10 (the dozen, of course), and then add that to |
| 747 |
% a rolling total. At the end, we output the number. |
| 748 |
% \begin{macrocode} |
| 749 |
\def\doz@ten{X}% |
| 750 |
\def\doz@elv{E}% |
| 751 |
\def\doz@basex#1{% |
| 752 |
\doz@total=0% |
| 753 |
\doz@loopi=\doz@countchar% |
| 754 |
\doz@multiplier=1% |
| 755 |
\def\doz@wholenum{#1}% |
| 756 |
\loop\ifnum\doz@loopi>0% |
| 757 |
\def\doz@currchar{\doz@CharAt{\number\doz@loopi}{\doz@wholenum}}% |
| 758 |
\if\doz@currchar\doz@ten% |
| 759 |
\doz@lfiller=10% |
| 760 |
\else\if\doz@currchar\doz@elv% |
| 761 |
\doz@lfiller=11% |
| 762 |
\else% |
| 763 |
\doz@lfiller=\doz@currchar% |
| 764 |
\fi\fi% |
| 765 |
\multiply\doz@lfiller by\doz@multiplier% |
| 766 |
\multiply\doz@multiplier by12% |
| 767 |
\advance\doz@total by\doz@lfiller% |
| 768 |
\advance\doz@loopi by-1% |
| 769 |
\repeat% |
| 770 |
\the\doz@total% |
| 771 |
}% |
| 772 |
\def\basex#1{% |
| 773 |
\doz@charcount{#1}% |
| 774 |
\doz@loopi=0% |
| 775 |
\doz@basex{#1}% |
| 776 |
\doz@multiplier=1% |
| 777 |
\doz@total=0% |
| 778 |
}% |
| 779 |
% \end{macrocode} |
| 780 |
% Finally, we define the macros for creating ``Doman'' |
| 781 |
% (dozenal Roman) numerals. One, of course, is defined in |
| 782 |
% terms of the other. First, though, we need a modulus |
| 783 |
% operator: |
| 784 |
% \begin{macrocode} |
| 785 |
\newcount\doz@modulus% |
| 786 |
\def\doz@modulo#1#2{% |
| 787 |
\doz@modulus=#1% |
| 788 |
\divide\doz@modulus by#2% |
| 789 |
\multiply\doz@modulus by#2% |
| 790 |
\multiply\doz@modulus by-1% |
| 791 |
\advance\doz@modulus by#1\relax% |
| 792 |
}% |
| 793 |
\newcount\doz@quotient% |
| 794 |
\def\doz@quot#1#2{% |
| 795 |
\doz@quotient=#1% |
| 796 |
\divide\doz@quotient by#2% |
| 797 |
}% |
| 798 |
% \end{macrocode} |
| 799 |
% Now we can move on to the meat of the operation: |
| 800 |
% \begin{macrocode} |
| 801 |
\newcount\doz@romct% |
| 802 |
\newif\ifdoz@domancaps% |
| 803 |
\def\doz@doman#1{% |
| 804 |
\doz@romct=#1% |
| 805 |
\doz@quot{\doz@romct}{1728}% |
| 806 |
\loop\ifnum\doz@quotient>0% |
| 807 |
\ifdoz@domancaps M\else m\fi% |
| 808 |
\advance\doz@quotient by-1% |
| 809 |
\advance\doz@romct by-1728% |
| 810 |
\repeat |
| 811 |
\ifnum\doz@romct>1440 |
| 812 |
\ifnum\doz@romct<1584 |
| 813 |
\ifdoz@domancaps CCM\else ccm\fi% |
| 814 |
\advance\doz@romct by-1440 |
| 815 |
\else%\ifnum\doz@romct>1583 |
| 816 |
\ifdoz@domancaps CM\else cm\fi% |
| 817 |
\advance\doz@romct by-1584 |
| 818 |
\fi |
| 819 |
\fi |
| 820 |
\ifnum\doz@romct>575% |
| 821 |
\ifnum\doz@romct<719 |
| 822 |
\ifdoz@domancaps CCD\else ccd\fi% |
| 823 |
\advance\doz@romct by-576 |
| 824 |
\else |
| 825 |
\ifnum\doz@romct<864% |
| 826 |
\ifdoz@domancaps CD\else cd\fi% |
| 827 |
\advance\doz@romct by-720% |
| 828 |
\fi |
| 829 |
\fi |
| 830 |
\else |
| 831 |
\ifnum\doz@romct>719 |
| 832 |
\ifdoz@domancaps D\else d\fi% |
| 833 |
\advance\doz@romct by-719% |
| 834 |
\fi |
| 835 |
\fi |
| 836 |
\doz@quot{\doz@romct}{144}% |
| 837 |
\loop\ifnum\doz@quotient>0% |
| 838 |
\ifdoz@domancaps C\else c\fi% |
| 839 |
\advance\doz@quotient by-1% |
| 840 |
\advance\doz@romct by-144% |
| 841 |
\repeat |
| 842 |
\ifnum\doz@romct>119 |
| 843 |
\ifnum\doz@romct<132 |
| 844 |
\ifdoz@domancaps XXC\else xxc\fi% |
| 845 |
\advance\doz@romct by-120 |
| 846 |
\else |
| 847 |
\ifdoz@domancaps XC\else xc\fi% |
| 848 |
\advance\doz@romct by-132 |
| 849 |
\fi |
| 850 |
\fi |
| 851 |
\ifnum\doz@romct>71 |
| 852 |
\ifdoz@domancaps L\else l\fi% |
| 853 |
\advance\doz@romct by-72 |
| 854 |
\fi |
| 855 |
\ifnum\doz@romct>47% |
| 856 |
\ifnum\doz@romct>59% |
| 857 |
\ifdoz@domancaps XL\else xl\fi% |
| 858 |
\advance\doz@romct by-60% |
| 859 |
\else |
| 860 |
\ifdoz@domancaps XXL\else xxl\fi% |
| 861 |
\advance\doz@romct by-48% |
| 862 |
\fi |
| 863 |
\fi |
| 864 |
\doz@quot{\doz@romct}{12}% |
| 865 |
\loop\ifnum\doz@quotient>0% |
| 866 |
\ifdoz@domancaps X\else x\fi% |
| 867 |
\advance\doz@quotient by-1% |
| 868 |
\advance\doz@romct by-12% |
| 869 |
\repeat |
| 870 |
\doz@modulo{\doz@romct}{12}% |
| 871 |
\ifnum\doz@modulus=10 |
| 872 |
\ifdoz@domancaps IIX\else iix\fi% |
| 873 |
\advance\doz@romct by-10 |
| 874 |
\fi |
| 875 |
\ifnum\doz@modulus=11 |
| 876 |
\ifdoz@domancaps IX\else ix\fi% |
| 877 |
\advance\doz@romct by-11 |
| 878 |
\fi |
| 879 |
\ifnum\doz@romct>5 |
| 880 |
\ifdoz@domancaps V\else v\fi% |
| 881 |
\advance\doz@romct by-6 |
| 882 |
\fi |
| 883 |
\ifnum\doz@romct>3% |
| 884 |
\ifnum\doz@romct=4% |
| 885 |
\ifdoz@domancaps IIV\else iiv\fi% |
| 886 |
\advance\doz@romct by-4% |
| 887 |
\else |
| 888 |
\ifnum\doz@romct=5% |
| 889 |
\ifdoz@domancaps IV\else iv\fi% |
| 890 |
\advance\doz@romct by-5% |
| 891 |
\fi |
| 892 |
\ifnum\doz@romct=6% |
| 893 |
\ifdoz@domancaps V\else v\fi% |
| 894 |
\advance\doz@romct by-6 |
| 895 |
\fi |
| 896 |
\fi |
| 897 |
\fi |
| 898 |
\doz@quot{\doz@romct}{1}% |
| 899 |
\loop\ifnum\doz@quotient>0% |
| 900 |
\ifdoz@domancaps I\else i\fi% |
| 901 |
\advance\doz@quotient by-1% |
| 902 |
\advance\doz@romct by-1% |
| 903 |
\repeat |
| 904 |
} |
| 905 |
\protected\def\doman#1{% |
| 906 |
\doz@domancapsfalse% |
| 907 |
\doz@doman{#1}% |
| 908 |
}% |
| 909 |
\protected\def\Doman#1{% |
| 910 |
\doz@domancapstrue% |
| 911 |
\doz@doman{#1}% |
| 912 |
}% |
| 913 |
% \end{macrocode} |
| 914 |
% Now, of course, we simply redefine all the counters. This |
| 915 |
% covers only those counters included in the basic \LaTeX\ |
| 916 |
% document classes, however, so if you've written your own, |
| 917 |
% you'll need to redefine them yourself. |
| 918 |
% |
| 919 |
% This first bit ensures that the counters are redefined |
| 920 |
% even if the command |\mainmatter| is not defined. We have |
| 921 |
% to do this outside of the |\g@addto@macro| below; |
| 922 |
% otherwise, in documents where |\mainmatter| is defined but |
| 923 |
% not used, the counters will not be redefined. This way, |
| 924 |
% they're redefined in all cases. |
| 925 |
% |
| 926 |
% This also takes care of ensuring that the counters are |
| 927 |
% only redefined if the ``nocounters'' options was |
| 928 |
% \emph{not} specified. |
| 929 |
% \begin{macrocode} |
| 930 |
\@ifundefined{nocounters}{% |
| 931 |
\@ifundefined{c@page}{}{% |
| 932 |
\renewcommand\thepage{\basexii{\value{page}}{\x}{\e}}} |
| 933 |
\@ifundefined{c@footnote}{}{% |
| 934 |
\renewcommand\thefootnote{% |
| 935 |
\basexii{\value{footnote}}{\x}{\e}}} |
| 936 |
\@ifundefined{c@part}{}{% |
| 937 |
\renewcommand\thepart{% |
| 938 |
\basexii{\value{part}}{\x}{\e}}} |
| 939 |
\@ifundefined{c@subparagraph}{}{% |
| 940 |
\renewcommand\thesubparagraph{% |
| 941 |
\basexii{\value{subparagraph}}{\x}{\e}}} |
| 942 |
\@ifundefined{c@paragraph}{}{% |
| 943 |
\renewcommand\theparagraph{% |
| 944 |
\basexii{\value{paragraph}}{\x}{\e}}} |
| 945 |
\@ifundefined{c@equation}{}{% |
| 946 |
\renewcommand\theequation{% |
| 947 |
\basexii{\value{equation}}{\x}{\e}}} |
| 948 |
\@ifundefined{c@figure}{}{% |
| 949 |
\renewcommand\thefigure{% |
| 950 |
\basexii{\value{figure}}{\x}{\e}}} |
| 951 |
\@ifundefined{c@table}{}{% |
| 952 |
\renewcommand\thetable{% |
| 953 |
\basexii{\value{table}}{\x}{\e}}} |
| 954 |
\@ifundefined{c@table}{}{% |
| 955 |
\renewcommand\thempfootnote{% |
| 956 |
\basexii{\value{mpfootnote}}{\x}{\e}}} |
| 957 |
\@ifundefined{c@enumi}{}{% |
| 958 |
\renewcommand\theenumi{% |
| 959 |
\basexii{\value{enumi}}{\x}{\e}}} |
| 960 |
\@ifundefined{c@enumii}{}{% |
| 961 |
\renewcommand\theenumii{% |
| 962 |
\basexii{\value{enumii}}{\x}{\e}}} |
| 963 |
\@ifundefined{c@enumiii}{}{% |
| 964 |
\renewcommand\theenumiii{% |
| 965 |
\basexii{\value{enumiii}}{\x}{\e}}} |
| 966 |
\@ifundefined{c@enumiv}{}{% |
| 967 |
\renewcommand\theenumiv{% |
| 968 |
\basexii{\value{enumiv}}{\x}{\e}}} |
| 969 |
\@ifundefined{c@chapter}{% |
| 970 |
\renewcommand\thesection{% |
| 971 |
\basexii{\value{section}}{\x}{\e}} |
| 972 |
\renewcommand\thesubsection{% |
| 973 |
\thesection.\basexii{\value{subsection}}{\x}{\e}} |
| 974 |
\renewcommand\thesubsubsection{% |
| 975 |
\thesubsection.\basexii{\value{subsubsection}}{\x}{\e}} |
| 976 |
}{ |
| 977 |
\renewcommand\thechapter{% |
| 978 |
\basexii{\value{chapter}}{\x}{\e}} |
| 979 |
\renewcommand\thesection{% |
| 980 |
\thechapter.\basexii{\value{section}}{\x}{\e}} |
| 981 |
\renewcommand\thesubsection{% |
| 982 |
\thesection.\basexii{\value{subsection}}{\x}{\e}} |
| 983 |
\renewcommand\thesubsubsection{% |
| 984 |
\thesubsection.\basexii{\value{subsubsection}}{\x}{\e}} |
| 985 |
} |
| 986 |
% \end{macrocode} |
| 987 |
% Finally, if the |\mainmatter| command is used, we need to |
| 988 |
% make sure that it doesn't mess up our numbering scheme. |
| 989 |
% \begin{macrocode} |
| 990 |
\@ifundefined{mainmatter}{}{% |
| 991 |
\g@addto@macro\mainmatter{% |
| 992 |
\@ifundefined{c@page}{}{% |
| 993 |
\renewcommand\thepage{\basexii{\value{page}}{\x}{\e}}} |
| 994 |
\@ifundefined{c@footnote}{}{% |
| 995 |
\renewcommand\thefootnote{\basexii{\value{footnote}}{\x}{\e}}} |
| 996 |
\@ifundefined{c@part}{}{% |
| 997 |
\renewcommand\thepart{\basexii{\value{part}}{\x}{\e}}} |
| 998 |
\@ifundefined{c@subparagraph}{}{% |
| 999 |
\renewcommand\thesubparagraph{% |
| 1000 |
\basexii{\value{subparagraph}}{\x}{\e}}} |
| 1001 |
\@ifundefined{c@paragraph}{}{% |
| 1002 |
\renewcommand\theparagraph{% |
| 1003 |
\basexii{\value{paragraph}}{\x}{\e}}} |
| 1004 |
\@ifundefined{c@equation}{}{% |
| 1005 |
\renewcommand\theequation{% |
| 1006 |
\basexii{\value{equation}}{\x}{\e}}} |
| 1007 |
\@ifundefined{c@figure}{}{% |
| 1008 |
\renewcommand\thefigure{% |
| 1009 |
\basexii{\value{figure}}{\x}{\e}}} |
| 1010 |
\@ifundefined{c@table}{}{% |
| 1011 |
\renewcommand\thetable{% |
| 1012 |
\basexii{\value{table}}{\x}{\e}}} |
| 1013 |
\@ifundefined{c@table}{}{% |
| 1014 |
\renewcommand\thempfootnote{% |
| 1015 |
\basexii{\value{mpfootnote}}{\x}{\e}}} |
| 1016 |
\@ifundefined{c@enumi}{}{% |
| 1017 |
\renewcommand\theenumi{% |
| 1018 |
\basexii{\value{enumi}}{\x}{\e}}} |
| 1019 |
\@ifundefined{c@enumii}{}{% |
| 1020 |
\renewcommand\theenumii{% |
| 1021 |
\basexii{\value{enumii}}{\x}{\e}}} |
| 1022 |
\@ifundefined{c@enumiii}{}{% |
| 1023 |
\renewcommand\theenumiii{% |
| 1024 |
\basexii{\value{enumiii}}{\x}{\e}}} |
| 1025 |
\@ifundefined{c@enumiv}{}{% |
| 1026 |
\renewcommand\theenumiv{% |
| 1027 |
\basexii{\value{enumiv}}{\x}{\e}}} |
| 1028 |
\@ifundefined{c@chapter}{ |
| 1029 |
\renewcommand\thesection{% |
| 1030 |
\basexii{\value{section}}{\x}{\e}} |
| 1031 |
\renewcommand\thesubsection{% |
| 1032 |
\thesection.\basexii{\value{subsection}}{\x}{\e}} |
| 1033 |
\renewcommand\thesubsubsection{% |
| 1034 |
\thesubsection.\basexii{\value{subsubsection}}{\x}{\e}} |
| 1035 |
}{ |
| 1036 |
\renewcommand\thechapter{% |
| 1037 |
\basexii{\value{chapter}}{\x}{\e}} |
| 1038 |
\renewcommand\thesection{% |
| 1039 |
\thechapter.\basexii{\value{section}}{\x}{\e}} |
| 1040 |
\renewcommand\thesubsection{% |
| 1041 |
\thesection.\basexii{\value{subsection}}{\x}{\e}} |
| 1042 |
\renewcommand\thesubsubsection{% |
| 1043 |
\thesubsection.\basexii{\value{subsubsection}}{\x}{\e}} |
| 1044 |
} % end if it's defined |
| 1045 |
} |
| 1046 |
} |
| 1047 |
}{} % end redefinition of counters block |
| 1048 |
% \end{macrocode} |
| 1049 |
% Now we begin the number-to-word macros. First, we define |
| 1050 |
% the macros which allow the user to specify his own words |
| 1051 |
% for each rank: |
| 1052 |
% \begin{macrocode} |
| 1053 |
\def\dozrankoneword{unqua} |
| 1054 |
\def\dozranktwoword{biqua} |
| 1055 |
\def\dozrankthreeword{triqua} |
| 1056 |
\def\dozrankfourword{quadqua} |
| 1057 |
\def\dozrankfiveword{pentqua} |
| 1058 |
\def\dozranksixword{hexqua} |
| 1059 |
\def\dozranksevenword{septqua} |
| 1060 |
\def\dozrankeightword{octqua} |
| 1061 |
\def\dozranknineword{ennqua} |
| 1062 |
\def\dozranktenword{decqua} |
| 1063 |
\def\dozrankelvword{elvqua} |
| 1064 |
% \end{macrocode} |
| 1065 |
% Then we define some |\if|s to help us decide how we should |
| 1066 |
% capitalize the end result. |
| 1067 |
% \begin{macrocode} |
| 1068 |
\newif\ifDOZcaps\DOZcapsfalse |
| 1069 |
\newif\ifDozcaps\Dozcapsfalse |
| 1070 |
% \end{macrocode} |
| 1071 |
% Then, we give some utility macros: |
| 1072 |
% \begin{macrocode} |
| 1073 |
\def\doz@expandloop#1{\doz@xloop#1\relax} |
| 1074 |
\def\doz@xloop#1{% |
| 1075 |
\ifx\relax#1\else% |
| 1076 |
\doz@numword#1% |
| 1077 |
\expandafter\doz@xloop\fi% |
| 1078 |
} |
| 1079 |
\def\printdozrankword{} |
| 1080 |
\def\doz@rankword{% |
| 1081 |
\ifnum\doz@countchar=12 |
| 1082 |
\def\printdozrankword{\dozrankelvword}% |
| 1083 |
\fi |
| 1084 |
\ifnum\doz@countchar=11 |
| 1085 |
\def\printdozrankword{\dozranktenword}% |
| 1086 |
\fi |
| 1087 |
\ifnum\doz@countchar=10 |
| 1088 |
\def\printdozrankword{\dozranknineword}% |
| 1089 |
\fi |
| 1090 |
\ifnum\doz@countchar=9 |
| 1091 |
\def\printdozrankword{\dozrankeightword}% |
| 1092 |
\fi |
| 1093 |
\ifnum\doz@countchar=8 |
| 1094 |
\def\printdozrankword{\dozranksevenword}% |
| 1095 |
\fi |
| 1096 |
\ifnum\doz@countchar=7 |
| 1097 |
\def\printdozrankword{\dozranksixword}% |
| 1098 |
\fi |
| 1099 |
\ifnum\doz@countchar=6 |
| 1100 |
\def\printdozrankword{\dozrankfiveword}% |
| 1101 |
\fi |
| 1102 |
\ifnum\doz@countchar=5 |
| 1103 |
\def\printdozrankword{\dozrankfourword}% |
| 1104 |
\fi |
| 1105 |
\ifnum\doz@countchar=4 |
| 1106 |
\def\printdozrankword{\dozrankthreeword}% |
| 1107 |
\fi |
| 1108 |
\ifnum\doz@countchar=3 |
| 1109 |
\def\printdozrankword{\dozranktwoword}% |
| 1110 |
\fi |
| 1111 |
\ifnum\doz@countchar=2 |
| 1112 |
\def\printdozrankword{\dozrankoneword}% |
| 1113 |
\fi |
| 1114 |
\ifnum\doz@countchar=1 |
| 1115 |
\def\printdozrankword{\relax}% |
| 1116 |
\fi |
| 1117 |
\advance\doz@countchar by-1 |
| 1118 |
\ifDOZcaps |
| 1119 |
\edef\printdozrankword{\uppercase{\printdozrankword}}% |
| 1120 |
\fi |
| 1121 |
\ifDozcaps |
| 1122 |
\edef\printdozrankword{\capitalisewords{\printdozrankword}}% |
| 1123 |
\fi |
| 1124 |
\ifnum\doz@countchar>0 |
| 1125 |
\ \printdozrankword\ % |
| 1126 |
\else |
| 1127 |
\printdozrankword% |
| 1128 |
\fi |
| 1129 |
}% |
| 1130 |
\def\doz@numword#1{% |
| 1131 |
\IfStrEq{#1}{0}{\def\doz@numberword{zero}}{}% |
| 1132 |
\IfStrEq{#1}{1}{\def\doz@numberword{one}}{}% |
| 1133 |
\IfStrEq{#1}{2}{\def\doz@numberword{two}}{}% |
| 1134 |
\IfStrEq{#1}{3}{\def\doz@numberword{three}}{}% |
| 1135 |
\IfStrEq{#1}{4}{\def\doz@numberword{four}}{}% |
| 1136 |
\IfStrEq{#1}{5}{\def\doz@numberword{five}}{}% |
| 1137 |
\IfStrEq{#1}{6}{\def\doz@numberword{six}}{}% |
| 1138 |
\IfStrEq{#1}{7}{\def\doz@numberword{seven}}{}% |
| 1139 |
\IfStrEq{#1}{8}{\def\doz@numberword{eight}}{}% |
| 1140 |
\IfStrEq{#1}{9}{\def\doz@numberword{nine}}{}% |
| 1141 |
\IfStrEq{#1}{X}{\def\doz@numberword{ten}}{}% |
| 1142 |
\IfStrEq{#1}{E}{\def\doz@numberword{eleven}}{}% |
| 1143 |
\ifDOZcaps |
| 1144 |
\edef\doz@numberword{\uppercase{\doz@numberword}}% |
| 1145 |
\fi |
| 1146 |
\ifDozcaps |
| 1147 |
\edef\doz@numberword{\makefirstuc{\doz@numberword}}% |
| 1148 |
\fi |
| 1149 |
\doz@numberword% |
| 1150 |
\doz@rankword% |
| 1151 |
}% |
| 1152 |
\def\doznumtoword#1{% |
| 1153 |
\edef\thenumber{\basexii{\value{#1}}{X}{E}}% |
| 1154 |
\expandafter\doz@charcount\expandafter{\thenumber}% |
| 1155 |
\expandafter\doz@expandloop\expandafter{\thenumber}% |
| 1156 |
\doz@countchar=0% |
| 1157 |
}% |
| 1158 |
\def\DOZnumtoword#1{% |
| 1159 |
\DOZcapstrue% |
| 1160 |
\doznumtoword{#1}% |
| 1161 |
\DOZcapsfalse% |
| 1162 |
}% |
| 1163 |
\def\Doznumtoword#1{% |
| 1164 |
\Dozcapstrue% |
| 1165 |
\doznumtoword{#1}% |
| 1166 |
\Dozcapsfalse% |
| 1167 |
}% |
| 1168 |
% \end{macrocode} |
| 1169 |
% Our last job is to make sure the semicolon (Humphrey |
| 1170 |
% point) works correctly as a radix point in math mode. |
| 1171 |
% This code is adapted from the |icomma| package by Walter |
| 1172 |
% Schmidt. |
| 1173 |
% \begin{macrocode} |
| 1174 |
\AtBeginDocument{% |
| 1175 |
\mathchardef\humphrey\mathcode`\;% |
| 1176 |
\mathcode`\;="8000 % |
| 1177 |
} |
| 1178 |
{\catcode`;=\active |
| 1179 |
\gdef;{\futurelet\@let@token\sm@rtsemi} |
| 1180 |
} |
| 1181 |
\def\sm@rtsemi{% |
| 1182 |
\ifx\@let@token\@sptoken \else |
| 1183 |
\ifx\@let@token\space \else |
| 1184 |
\mathord\fi\fi \humphrey} |
| 1185 |
% \end{macrocode} |
| 1186 |
% And that's the end. Thanks for reading, |
| 1187 |
% folks; please email me with any suggestions or improvements. |