summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/dozenal/dozenal.sty
blob: 4b81f53e1467f985ed87a87ba54298c11ece56b5 (plain)
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
%\iffalse
% +AMDG  This document was begun on 14 November 2008, the
% feast of St. Josaphat, and it is humbly dedicated to him
% and to the Immaculate Heart of Mary for their prayers, and
% to the Sacred Heart of Jesus for His mercy.
% 
% This document is copyright 2008 by Donald P. Goodman, and is
% released publicly under the LaTeX Project Public License.  The
% distribution and modification of this work is constrained by the
% conditions of that license.  See
% 	http://www.latex-project.org/lppl.txt
% for the text of the license.  This document is released
% under version 1.3 of that license, and this work may be distributed
% or modified under the terms of that license or, at your option, any
% later version.
% 
% This work has the LPPL maintenance status 'maintained'.
% 
% The Current Maintainer of this work is Donald P. Goodman
% (dgoodmaniii@fastmail.fm).
% 
% This work consists of the files dozenal.dtx, dozenal.sty,
% dozchars6.mf, dozchars7.mf, dozchars8.mf, dozchars9.mf,
% dozchars10.mf, dozchars12.mf, dozchars17.mf, dozchsl8.mf,
% dozchsl9.mf, dozchsl10.mf, dozchsl12.mf, dozchb10.mf,
% dozchbx5.mf, dozchbx6.mf, dozchbx7.mf, dozchbx8.mf, dozchbx9.mf, 
% dozchbx10.mf, dozchbx12.mf, dozchit7.mf, dozchit8.mf, 
% dozchit9.mf, dozchit10.mf, dozchit12.mf, dozchbxi10.mf, 
% dozchbxsl10.mf, dozenal.mf, dozenalb.mf, dozenali.mf, 
% fdzb8a.pfb, fdzbi8a.pfb, fdzbs8a.pfb, fdzi8a.pfb,
% fdzr8a.pfb, fdzs8a.pfb, fdz.map, , fdzb7t.tfm, fdzb8a.tfm,
% fdzb8c.tfm, fdzb8r.tfm, fdzb8t.tfm, fdzbc7t.tfm,
% fdzbc8t.tfm, fdzbi7t.tfm, fdzbi8a.tfm, fdzbi8c.tfm,
% fdzbi8r.tfm, fdzbi8t.tfm, fdzbo7t.tfm, fdzbo8c.tfm,
% fdzbo8r.tfm, fdzbo8t.tfm, fdzbs8a.tfm, fdzi8a.tfm,
% fdzr7t.tfm, fdzr8a.tfm, fdzr8c.tfm, fdzr8r.tfm, fdzr8t.tfm,
% fdzrc7t.tfm, fdzrc8t.tfm, fdzro7t.tfm, fdzro8c.tfm,
% fdzro8r.tfm, fdzro8t.tfm, fdzs7t.tfm, fdzs8a.tfm,
% fdzs8c.tfm, fdzs8r.tfm, fdzs8t.tfm, fdzsc7t.tfm,
% fdzsc8t.tfm, fdzso7t.tfm, fdzso8c.tfm, fdzso8r.tfm,
% fdzso8t.tfm,, fdzb7t.vf, fdzb8c.vf, fdzb8t.vf, fdzbc7t.vf,
% fdzbc8t.vf, fdzbi7t.vf, fdzbi8c.vf, fdzbi8t.vf, fdzbo7t.vf,
% fdzbo8c.vf, fdzbo8t.vf, fdzr7t.vf, fdzr8c.vf, fdzr8t.vf,
% fdzrc7t.vf, fdzrc8t.vf, fdzro7t.vf, fdzro8c.vf, fdzro8t.vf,
% fdzs7t.vf, fdzs8c.vf, fdzs8t.vf, fdzsc7t.vf, fdzsc8t.vf,
% fdzso7t.vf, fdzso8c.vf, fdzso8t.vf, testfdzchars.tex,
% testdozchars.tex, dozenal.sty, and dozenal.pdf, along with
% this README.
% 
% \fi
%
% \maketitle
% \begin{abstract}
% The |dozenal| package provides some simple mechanisms for
% working with the dozenal (duodecimal or ``base 12'')
% numerical system.  It redefines all basic \LaTeX\
% counters, provides a command for converting arbitrary
% decimal numbers into dozenal, and provides new, real
% Metafont characters for ten and eleven, though the
% commands for producing them can be redefined to produce
% any figure.  As of v2.0, it also includes Type 1 versions
% of the fonts, used automatically whenever T1 encoding is
% selected for the document.  This package uses the |\basexii| 
% algorithm by David Kastrup.
% \end{abstract}
% 
% \tableofcontents
% 
% \section{Introduction}
% \label{sect:intro}
% 
% While most would probably call it at best overoptimistic and
% at worst foolish, some people (the author included) do still
% find themselves attracted to the dozenal (base-twelve)
% system.  These people, however, have been pretty hard
% up\footnote{This is an Americanism for ``out of luck'' or
% ``in difficult circumstances,'' for those who do not
% know.} in the \LaTeX\ world.  There is no package file
% available which produces dozenal counters, like page and
% chapter numbers, nor were there \emph{any} (I made a
% pretty diligent search) dozenal characters for ten and
% eleven, leaving dozenalists forced to use such makeshift
% ugliness as the ``X/E'' or ``T/E'' or ``*/\#'' or whatever
% other standard they decided to use.  While this sort of
% thing may be acceptable in ASCII, it's absolutely
% unacceptable in a beautiful, typeset document.
% 
% Enter the |dozenal| package.  This package automates all
% the messiness of being a dozenalist and using \LaTeX.  It
% redefines all the counters (though you'll have to redefine
% them yourself if you're using your own), provides an
% algorithm (generously donated by the intrepid David
% Kastrup) for converting arbitrary positive whole numbers
% into dozenal (this is e\TeX, but all modern distributions
% will compile that), and finally, it includes original
% dozenal characters, specifically designed to blend in well
% with Knuth's Computer Modern fonts, though they should do
% fine with the more common body fonts, as well.
% 
% This document was typeset in accordance with the \LaTeX\
% \textsc{docstrip} utility.
%
% \section{Usage}
% \label{sect:usage}
%
% The |dozenal| package provides four new commands (though
% I can only take credit for two of them).  The first, and
% by far the most important given the purpose and content of
% this package, is |\basexii|\DescribeMacro{\basexii}.  This
% is a very simple command which takes the following
% structure:
% \begin{quote}
% \cs{basexii}\marg{number}\marg{ten symbol}\marg{eleven symbol}
% \end{quote}
% What the above means is that the command is |\basexii| and
% it takes three mandatory arguments:  first, the number to
% be converted into dozenal; second, the symbol that should
% be used for ten; and third, the symbol that should be used
% for eleven.  This number should be positive and whole;
% that is, it should be zero or higher, and it should not
% contain a fractional part.  \TeX\ is a typesetting
% program, after all; if you want a robust decimal to
% dozenal converter, there are many options that any
% dozenalists caring enough to use this package will already
% know about.
% 
% This |\basexii| algorithm was produced by David Kastrup,
% well known and admired in the \TeX\ world for his many
% useful packages and other contributions.  He posted this
% algorithm on comp.text.tex; it is included here with his 
% kind and generous permission.
%
% That one would want to use the same ten and eleven symbols
% throughout a document seems a reasonable assumption;
% therefore, I have provided a simplified version of the
% |\basexii| command, |\dozens|\DescribeMacro{\dozens}.
% |\dozens| takes only a single argument, the number to be
% converted; the ten and eleven symbols used are those
% produced by the commands |\x| and |\e|, to which we'll get
% in a moment.
% 
% |\x|\DescribeMacro{\x}\ and |\e|\DescribeMacro{\e}\ are the
% commands used to quickly and easily access the symbols for
% ten and eleven without having to use active characters
% (the \TeX\ gurus will know what that means; if you don't
% know, that's okay; you don't need to to use this package
% effectively).  In any case, |\x| and |\e| default to using
% the special dozenal characters that are part of this
% package; they could be easily redefined if for some reason
% you don't like the Pitman characters (which this package,
% and the Dozenal Society of Great Britain, prefer), in the
% following manner:
% \begin{quote}
% |\renewcommand\x{X}|
% \end{quote}
% Or whichever characters you like to use.  If you prefer
% the Dozenal Society of America's proposed characters (a
% stylized X and E), then this package will disappoint you.
% May I suggest |$\chi$| ($\chi$) and |$\xi$| ($\xi$) as a
% stopgap while you locate or produce real characters of
% your own?  Sorry; I'm an American myself, but I much
% prefer the Pitman characters for a variety of reasons
% (feel free to email me if you care), and creating fonts in
% \MF, even small and inconsequential ones like this, is too
% much work for characters that I don't even like.
% 
% The |dozenal| package also redefines all the standard
% \LaTeX\ counters, such as |section| and |enumii|.  If
% you've defined your own counters, you'll need to define
% them yourself; however, this is an easy matter: 
% \begin{quote}
% |\renewcommand\thecounter{\basexii{\arabic{counter}}{\x}{\e}}|
% \end{quote}
% For example.  Of course, you can fill in the |\x| and |\e|
% with whatever you want (though it would make more sense to
% simply redefine |\x| and |\e|, so that all the counters
% would use the same characters), or you could use the
% |\dozens| command instead.  Whatever your pleasure might
% be.
%
% The |nocounters|\DescribeMacro{nocounters}\ option to the
% package prevents the redefinition of these counters.  The
% effect of this is that the commands of the package
% (|\basexii|, |\dozens|, etc.) are made available, but
% all the counters will still be in decimal.  This permits
% using dozenal characters in an otherwise decimal document;
% it also proves useful in dozenal document in which these
% counters are undefined (e.g., |minimal|).
%
% \section{The Fonts}
% \label{sect:fonts}
%
% The fonts provided by the dozenal package are essentially
% complete fonts which contain only the Pitman dozenal
% characters; these are \x\ for ten and \e\ for eleven.
% These characters are designed to blend well with the
% Computer Modern fonts; they work passable well with
% Times-type fonts and with kpfonts, and possibly with
% others.
%
% The characters also come in all the appropriate shapes and
% sizes; a few examples follow.
%
% \begin{center}
% \begin{tabular}{lccc}
% {} & Roman & \textit{Italic} & \textbf{Boldface} \\
% \footnotesize Footnotesize & \footnotesize\x\ \e & \footnotesize\itshape
% 	\x\ \e & \footnotesize\bfseries \x \e \\
% \normalsize Normalsize & \normalsize\x\ \e & \normalsize\itshape
% 	\x\ \e & \normalsize\bfseries \x \e \\
% \LARGE LARGE & \LARGE\x\ \e & \LARGE\itshape
% 	\x\ \e & \LARGE\bfseries \x \e \\
% \Huge Huge & \Huge\x\ \e & \Huge\itshape
% 	\x\ \e & \Huge\bfseries \x \e \\
% \end{tabular}
% \end{center}
% 
% They will work in paragraph or math mode without
% distinction.
% 
% As of v4.0, |dozenal| also includes fonts for tally marks
% specifically designed for use in the dozenal base.  In many
% European countries tallies are kept in a very similar way;
% this font demonstrates a way that such tally marks can be
% made consistent as well as dozenal.
% 
% \begin{center}
% \begin{tabular}{cccccc}
% 1 & 2 & 3 & 4 & 5 & 6 \\
% \Huge\tally{1} & \Huge\tally{2} & \Huge\tally{3} & \Huge\tally{4} & \Huge\tally{5} & \Huge\tally{6} \\
% \end{tabular}
% \end{center}
%
% The fonts are called |dozch|, if for some reason direct
% access to them is needed.  The Type 1 versions are
% prefixed |fdz|; e.g., |fdzr8a|.
% 
% \section{Implementation}
% \label{sect:code}
% 
% First, we name the package that we provide.  This is
% not exactly the most difficult part of the code.
%    \begin{macrocode}
\ProvidesPackage{dozenal}[2012/05/13 v4.0 support for dozenal fonts]
%    \end{macrocode}
% Now we need to make sure that we have fixltx2e loaded, so
% that the |\TextorMath| magic will work.
%    \begin{macrocode}
\RequirePackage{fixltx2e}
%    \end{macrocode}
% Now we ensure that |ifpdf| is loaded, so that we can test
% for pdf or dvi modes.
%    \begin{macrocode}
\RequirePackage{ifpdf}
%    \end{macrocode}
% Now we declare the option ``nocounters'', which prevents
% |dozenal| from redefining all the counters.  This prevents
% errors in document classes which don't have these counters,
% such as |minimal|.  Defines the command |\nocounters| if
% and only if the options is named.
%    \begin{macrocode}
\DeclareOption{nocounters}{%
	\def\nocounters{}%
}%
\ProcessOptions\relax
%    \end{macrocode}
% We then define the font that we're using for our
% \MF-produced Pitman characters.  Incidentally, we also
% define the command |\doz|, though I can't foresee any
% decent use for it except in packages and preambles; it is
% then used to define |\x| and |\e|, which provide the ten
% and eleven symbols for all the counter redefinitions.
% This includes definitions for both T1 and OT1 encodings,
% so it will work with either.
%    \begin{macrocode}
\DeclareFontFamily{OT1}{dozch}{}
\DeclareFontShape{OT1}{dozch}{m}{n}{<-6> dozchars6 <7> dozchars7 <8> dozchars8 <9> dozchars9 <10-11> dozchars10 <12-16> dozchars12 <17-> dozchars17  }{}
\DeclareFontShape{OT1}{dozch}{b}{n}{<-> dozchb10 }{}
\DeclareFontShape{OT1}{dozch}{bx}{n}{<-6> dozchbx6 <7> dozchbx7 <8> dozchbx8 <9> dozchbx9 <10-11> dozchbx10 <12-> dozchbx12 }{}
\DeclareFontShape{OT1}{dozch}{m}{sl}{<-8> dozchsl8 <9> dozchsl9 <10-11> dozchsl10 <12-> dozchsl12 }{}
\DeclareFontShape{OT1}{dozch}{bx}{sl}{<-> dozchbxsl10 }{}
\DeclareFontShape{OT1}{dozch}{m}{it}{<-7> dozchit7 <8> dozchit8 <9> dozchit9 <10-11> dozchit10 <12-> dozchit12 }{}
\DeclareFontShape{OT1}{dozch}{bx}{it}{<-> dozchbxi10 }{}
\ifpdf
	\pdfmapfile{=fdz.map}
\fi
\DeclareFontFamily{T1}{dozch}{}
\DeclareFontShape{T1}{dozch}{m}{n}{<-> fdzr8r  }{}
\DeclareFontShape{T1}{dozch}{bx}{n}{<-> fdzb8r }{}
\DeclareFontShape{T1}{dozch}{m}{sl}{<-> fdzs8r }{}
\DeclareFontShape{T1}{dozch}{bx}{sl}{<-> fdzbo8r }{}
\DeclareFontShape{T1}{dozch}{m}{it}{<-> fdzso8r }{}
\DeclareFontShape{T1}{dozch}{bx}{it}{<-> fdzbi8r }{}
\newcommand\doz[1]{{\fontfamily{dozch}\selectfont #1}}
\newcommand\x{\TextOrMath{\protect\doz{{X}}}{\X}}%
\newcommand\e{\TextOrMath{\protect\doz{{E}}}{\E}}%
\DeclareSymbolFont{dozens}{OT1}{dozch}{m}{n}
\DeclareMathSymbol{\X}{\mathord}{dozens}{88}
\DeclareMathSymbol{\E}{\mathord}{dozens}{69}
%    \end{macrocode}
% Put in some additional code for the tally marks.
%    \begin{macrocode}
\newcommand\tally[1]{%
	\doz{#1}%
}%
%    \end{macrocode}
% Then we define our command which will produce the dozenal
% numbers from decimal sources.  This algorithm was taken
% directly from the publicly available archives of
% comp.text.tex, where it was posted by the well-known and
% redoubtable David Kastrup.  We also define the |\dozens|
% command, a simplified |\basexii| (which, in fact, depends
% utterly upon |\basexii|), just to make it easy for
% everyone.
%    \begin{macrocode}
\def\basexii#1#2#3{\ifcase\numexpr(#1)\relax
0\or1\or2\or3\or4\or5\or6\or7\or8\or9\or#2\or#3\else
\expandafter\basexii\expandafter{\number\numexpr((#1)-6)/12}{#2}{#3}\expandafter\basexii\expandafter{\number\numexpr(#1)-((#1)-6)/12*12}{#2}{#3}\fi}
\newcommand\dozens[1]{\basexii{#1}{\x}{\e}}
%    \end{macrocode}
% Now, of course, we simply redefine all the counters.  This
% covers only those counters included in the basic \LaTeX\
% document classes, however, so if you've written your own,
% you'll need to redefine them yourself.
%
% This first bit ensures that the counters are redefined
% even if the command |\mainmatter| is not defined.  We have
% to do this outside of the |\g@addto@macro| below;
% otherwise, in documents where |\mainmatter| is defined but
% not used, the counters will not be redefined.  This way,
% they're redefined in all cases.
% 
% This also takes care of ensuring that the counters are
% only redefined if the ``nocounters'' options was
% \emph{not} specified.
%    \begin{macrocode}
\@ifundefined{nocounters}{%
\@ifundefined{c@page}{}{\renewcommand\thepage{\basexii{\value{page}}{\x}{\e}}}
\@ifundefined{c@footnote}{}{\renewcommand\thefootnote{\basexii{\value{footnote}}{\x}{\e}}}
\@ifundefined{c@part}{}{\renewcommand\thepart{\basexii{\value{part}}{\x}{\e}}}
\@ifundefined{c@subparagraph}{}{\renewcommand\thesubparagraph{\basexii{\value{subparagraph}}{\x}{\e}}}
\@ifundefined{c@paragraph}{}{\renewcommand\theparagraph{\basexii{\value{paragraph}}{\x}{\e}}}
\@ifundefined{c@equation}{}{\renewcommand\theequation{\basexii{\value{equation}}{\x}{\e}}}
\@ifundefined{c@figure}{}{\renewcommand\thefigure{\basexii{\value{figure}}{\x}{\e}}}
\@ifundefined{c@table}{}{\renewcommand\thetable{\basexii{\value{table}}{\x}{\e}}}
\@ifundefined{c@table}{}{\renewcommand\thempfootnote{\basexii{\value{mpfootnote}}{\x}{\e}}}
\@ifundefined{c@enumi}{}{\renewcommand\theenumi{\basexii{\value{enumi}}{\x}{\e}}}
\@ifundefined{c@enumii}{}{\renewcommand\theenumii{\basexii{\value{enumii}}{\x}{\e}}}
\@ifundefined{c@enumiii}{}{\renewcommand\theenumiii{\basexii{\value{enumiii}}{\x}{\e}}}
\@ifundefined{c@enumiv}{}{\renewcommand\theenumiv{\basexii{\value{enumiv}}{\x}{\e}}}
\@ifundefined{c@chapter}{% if it's undefined
\renewcommand\thesection{\basexii{\value{section}}{\x}{\e}}
\renewcommand\thesubsection{\thesection.\basexii{\value{subsection}}{\x}{\e}}
\renewcommand\thesubsubsection{\thesubsection.\basexii{\value{subsubsection}}{\x}{\e}}
} % end undefined
{%if it's defined
\renewcommand\thechapter{\basexii{\value{chapter}}{\x}{\e}}
\renewcommand\thesection{\thechapter.\basexii{\value{section}}{\x}{\e}}
\renewcommand\thesubsection{\thesection.\basexii{\value{subsection}}{\x}{\e}}
\renewcommand\thesubsubsection{\thesubsection.\basexii{\value{subsubsection}}{\x}{\e}}
}%end if chapter's defined
%    \end{macrocode}
% Finally, if the ``mainmatter'' command is used, we need to
% make sure that it doesn't mess up our numbering scheme.
%    \begin{macrocode}
\@ifundefined{mainmatter}{}{%
\g@addto@macro\mainmatter{%
\@ifundefined{c@page}{}{\renewcommand\thepage{\basexii{\value{page}}{\x}{\e}}}
\@ifundefined{c@footnote}{}{\renewcommand\thefootnote{\basexii{\value{footnote}}{\x}{\e}}}
\@ifundefined{c@part}{}{\renewcommand\thepart{\basexii{\value{part}}{\x}{\e}}}
\@ifundefined{c@subparagraph}{}{\renewcommand\thesubparagraph{\basexii{\value{subparagraph}}{\x}{\e}}}
\@ifundefined{c@paragraph}{}{\renewcommand\theparagraph{\basexii{\value{paragraph}}{\x}{\e}}}
\@ifundefined{c@equation}{}{\renewcommand\theequation{\basexii{\value{equation}}{\x}{\e}}}
\@ifundefined{c@figure}{}{\renewcommand\thefigure{\basexii{\value{figure}}{\x}{\e}}}
\@ifundefined{c@table}{}{\renewcommand\thetable{\basexii{\value{table}}{\x}{\e}}}
\@ifundefined{c@table}{}{\renewcommand\thempfootnote{\basexii{\value{mpfootnote}}{\x}{\e}}}
\@ifundefined{c@enumi}{}{\renewcommand\theenumi{\basexii{\value{enumi}}{\x}{\e}}}
\@ifundefined{c@enumii}{}{\renewcommand\theenumii{\basexii{\value{enumii}}{\x}{\e}}}
\@ifundefined{c@enumiii}{}{\renewcommand\theenumiii{\basexii{\value{enumiii}}{\x}{\e}}}
\@ifundefined{c@enumiv}{}{\renewcommand\theenumiv{\basexii{\value{enumiv}}{\x}{\e}}}
\@ifundefined{c@chapter}{% if it's undefined
\renewcommand\thesection{\basexii{\value{section}}{\x}{\e}}
\renewcommand\thesubsection{\thesection.\basexii{\value{subsection}}{\x}{\e}}
\renewcommand\thesubsubsection{\thesubsection.\basexii{\value{subsubsection}}{\x}{\e}}
} % end undefined
{%if it's defined
\renewcommand\thechapter{\basexii{\value{chapter}}{\x}{\e}}
\renewcommand\thesection{\thechapter.\basexii{\value{section}}{\x}{\e}}
\renewcommand\thesubsection{\thesection.\basexii{\value{subsection}}{\x}{\e}}
\renewcommand\thesubsubsection{\thesubsection.\basexii{\value{subsubsection}}{\x}{\e}}
} % end if it's defined
}}
}{} % end redefinition of counters block
%    \end{macrocode}
% And that's the end.  Thanks for reading, 
% folks; please email me with any suggestions or improvements.
% \printindex