Debian Codegraph @

texmf-dist/source/latex/xistercian/xistercian.dtx

raw
1 % \iffalse meta-comment
2 %
3 % File: xistercian.dtx Copyright (C) 2021-2025 Jonathan P. Spratte
4 %
5 % This work may be distributed and/or modified under the conditions of the
6 % LaTeX Project Public License (LPPL), either version 1.3c of this license or
7 % (at your option) any later version. The latest version of this license is in
8 % the file:
9 %
10 % http://www.latex-project.org/lppl.txt
11 %
12 % ------------------------------------------------------------------------------
13 %
14 %<*driver>^^A>>=
15 \def\nameofplainTeX{plain}
16 \ifx\fmtname\nameofplainTeX\else
17 \expandafter\begingroup
18 \fi
19 \input l3docstrip.tex
20 \askforoverwritefalse
21 \preamble
22
23 --------------------------------------------------------------
24 xistercian -- Cistercian numerals in LaTeX
25 E-mail: [email protected]
26 Released under the LaTeX Project Public License v1.3c or later
27 See http://www.latex-project.org/lppl.txt
28 --------------------------------------------------------------
29
30 Copyright (C) 2021-2025 Jonathan P. Spratte
31
32 This work may be distributed and/or modified under the conditions of the
33 LaTeX Project Public License (LPPL), either version 1.3c of this license or
34 (at your option) any later version. The latest version of this license is in
35 the file:
36
37 http://www.latex-project.org/lppl.txt
38
39 This work is "maintained" (as per LPPL maintenance status) by
40 Jonathan P. Spratte.
41
42 This work consists of the file xistercian.dtx
43 and the derived files xistercian.pdf
44 xistercian.sty
45
46 \endpreamble
47 % stop docstrip adding \endinput
48 \postamble
49 \endpostamble
50 \generate{\file{xistercian.sty}{\from{xistercian.dtx}{pkg}}}
51 \ifx\fmtname\nameofplainTeX
52 \expandafter\endbatchfile
53 \else
54 \expandafter\endgroup
55 \fi
56 %
57 \IfFileExists{xistercian.sty}{\RequirePackage[debug]{xistercian}}{}
58 \ProvidesFile{xistercian.dtx}[2025-04-13 v1.3 Cistercian numerals in LaTeX]
59 \PassOptionsToPackage{full}{textcomp}
60 \documentclass{l3doc}
61 \RequirePackage[fulloldstyle,nott]{kpfonts}
62 \RequirePackage{microtype}
63 \RequirePackage{csquotes}
64 \RequirePackage{tikz}
65 \usetikzlibrary{arrows.meta}
66 \RequirePackage{randtext}
67 \input{glyphtounicode}
68 \pdfgentounicode=1
69 \makeatletter
70 \@ifdefinable\gobbledocstriptag{\def\gobbledocstriptag#1>{}}
71 \makeatother
72 \let\metaORIG\meta
73 \protected\def\meta#1{\texttt{\metaORIG{#1}}}
74 \renewcommand*\thefootnote{\cistercian{footnote}}
75 \newcommand*\cistexnum[1]
76 {^^A
77 \begingroup
78 \color{red!65!black}^^A
79 \cisterciansetup{s=.15ex}^^A
80 \cisterciannum{#1}^^A
81 \endgroup
82 }
83 \pagenumbering{cistercian}
84 \ExplSyntaxOn
85 \makeatletter
86 \AddToHook{env/syntax/begin}{\let\myhfill\hfill}
87 \let\myhfill\@empty
88 \newcommand*\mydefault[1]
89 {
90 \begingroup
91 \color{darkgray}
92 \myrestoredefaults
93 \myhfill
94 \texttt
95 {
96 \expandafter\ifx\csname xister@#1\endcsname\@empty
97 \normalfont\emph{empty}
98 \else
99 \detokenize\expandafter\expandafter\expandafter
100 {\csname xister@#1\endcsname}
101 \unskip
102 \fi
103 }
104 \endgroup
105 }
106 \newcommand*\mysdefault[1]
107 {
108 \begingroup
109 \color{darkgray}
110 \myrestoredefaults
111 \myhfill
112 \texttt { \str_if_eq:nnTF {#1} { empty } { \normalfont \emph{#1} } {#1} }
113 \endgroup
114 }
115 \def\myrestoredefaults#1{\def\unexpanded{#1}{\unexpanded\expandafter{#1}}}
116 \edef\myrestoredefaults
117 {
118 \myrestoredefaults\xister@x
119 \myrestoredefaults\xister@y
120 \myrestoredefaults\xister@bx
121 \myrestoredefaults\xister@by
122 \myrestoredefaults\xister@tv
123 \myrestoredefaults\xister@th
124 \myrestoredefaults\xister@tdu
125 \myrestoredefaults\xister@tdd
126 \myrestoredefaults\xister@ts
127 \myrestoredefaults\xister@font
128 }
129 \makeatother
130 \newcommand\examplerow[1]
131 {
132 \cisterciannum{1#1}&\cisterciannum{2#1}&\cisterciannum{3#1}&
133 \cisterciannum{4#1}&\cisterciannum{5#1}&\cisterciannum{6#1}&
134 \cisterciannum{7#1}&\cisterciannum{8#1}&\cisterciannum{9#1}\\
135 \noalign{\vskip-.5ex}
136 $1#1$&$2#1$&$3#1$&
137 $4#1$&$5#1$&$6#1$&
138 $7#1$&$8#1$&$9#1$\\
139 \noalign{\vskip1ex}
140 }
141 \AddToHook{bfseries}
142 {\cisterciansetup{sv=.27ex,sdd=.27ex,sh=.12ex,sdu=.12ex,wd=.625em}}
143 \AddToHook{mdseries}{\myrestoredefaults}
144 \cisterciansetup{redraw+=series}
145 \tl_new:N \l__xisterexample_digit_tl
146 \newcommand*\showbb[1]
147 {
148 \begingroup
149 \cisterciansetup{#1}\cistercianredraw
150 \fboxrule=.5pt
151 \fboxsep=-.5\fboxrule
152 \leavevmode
153 \rlap
154 {
155 \textcolor{red}
156 {\fbox{\phantom{\cistercianeval{\l__xisterexample_digit_tl}}}}
157 }
158 \kern.5\fboxrule
159 \cistercianeval{\l__xisterexample_digit_tl}
160 \kern.5\fboxrule
161 \endgroup
162 }
163 \newcommand*\exampledigits{\tl_set:Nn \l__xisterexample_digit_tl}
164 \cistercianstyle{.ex}{sv=3pt,sdd=3pt,sh=2pt,sdu=2pt}
165 \cistercianstyle{vex}{o=v,bx=,by=,wd=7mm,ht=14mm,.ex}
166 \cistercianstyle{hex}{o=h,bx=,by=,ht=7mm,wd=14mm,.ex}
167 \newcommand\setversion{}
168 \ExplSyntaxOff
169 \protected\def\setversion#1-#2-#3 v#4\relax
170 {%
171 \year=#1\relax
172 \month=#2\relax
173 \day=#3\relax
174 \def\xistercianversion{#4}%
175 }
176 \setversion 2025-04-13 v1.3\relax
177 \newcommand\twodigits[1]{\ifnum#1<10 0\fi\the#1}
178 \newcommand\expkvLogo% >>=
179 {%
180 \begingroup
181 \rmfamily
182 \bfseries
183 {\color{ekvgrey}e\kern-.05em x\kern-.05em}%
184 \lower.493ex\hbox{{\color{ekvgrey}P}\kern-.1em{\color{ekvred}k}}%
185 \kern-.18em{\color{ekvred}v}%
186 \endgroup
187 }
188 \definecolor{ekvred}{HTML}{9F393D}
189 \colorlet{ekvgrey}{black!75}
190 % =<<
191 \begin{document}
192 \title{The \pkg{xistercian} package}
193 \author{Jonathan P. Spratte\thanks{\protect\randomize{[email protected]}}}
194 \date
195 {%
196 \begin{tabular}{@{}c*2{@{-}c}@{}}
197 \twodigits\year & \twodigits\month & \twodigits\day \\
198 \cistercianeval\year & \cistercianeval\month & \cistercianeval\day
199 \end{tabular}
200 \quad v\xistercianversion
201 }
202 \DocInput{xistercian.dtx}
203 \end{document}
204 %</driver>^^A=<<
205 % \fi
206 %
207 % \maketitle
208 % \tableofcontents
209 %
210 % \section{Documentation}
211 %
212 % The \pkg{xistercian} package provides Cistercian numerals for use in \LaTeX.
213 % The name is chosen to be \pkg{xistercian} because of the older (but earlier
214 % unreleased) \href{https://ctan.org/pkg/cistercian}{\pkg{cistercian} package},
215 % which has the same goal but goes a different way implementing it. In that
216 % other package you can change the way things look using Ti\textit{k}Z keys, so
217 % you might want to check it out and see which of the two fits your needs best.
218 %
219 %
220 % \subsection{Introduction}
221 %
222 % Cistercian numerals are a system to denote the numbers from $1$ to $9999$ with
223 % a single glyph. They use a stem (\cistexnum{0}) that is used as zero by this
224 % package, and add the digits to that using small tick marks, the place denoting
225 % the digits' value. On the upper right means units (\cistexnum{1}), upper left
226 % tens (\cistexnum{10}), lower right hundreds (\cistexnum{100}), and lower left
227 % thousands (\cistexnum{1000}). Figure~\ref{fig:glyphs} gives an overview over
228 % the base glyphs.
229 %
230 % In the medieval times it was quite common (according to Wikipedia more common
231 % than the vertical style) to use the Cistercian numerals horizontally instead.
232 % This package also supports that, in which case the numerals are rotated by
233 % $90$ degrees counter-clockwise, see figure~\ref{fig:glyphs:h}.
234 %
235 % Moreover some glyphs have a different shape in some manuscripts. The shapes in
236 % figures~\ref{fig:glyphs} and~\ref{fig:glyphs:h} are the most used ones
237 % nowadays (most likely because those are the ones Wikipedia shows vector
238 % graphics of). This package offers some (not all) alternative forms. Most
239 % notably some historic documents have swapped shapes of digits. To not further
240 % the confusion this package doesn't support swapping digit shapes.
241 %
242 % All glyphs have the same bounding box, are drawn using the \pkg{pgf}
243 % package, and cached inside \TeX\ box registers. Therefore the performance is
244 % quite well, at least well enough to actually consider using these numerals
245 % without a major performance hit. But it still slows down the compilation,
246 % especially if the glyphs have to be redrawn often. By default they will be
247 % redrawn if the font size changed since the last usage inside the current group
248 % scope, but you can specify which font feature changes should cause a redraw.
249 %
250 % \begin{figure}
251 % \centering
252 % \small
253 % \cistercianredraw
254 % \begin{tabular}{*9c}
255 % \examplerow{}
256 % \examplerow{0}
257 % \examplerow{00}
258 % \examplerow{000}
259 % \end{tabular}
260 % \caption{The different base glyphs in vertical mode\label{fig:glyphs}}
261 % \end{figure}
262 %
263 % \begin{figure}
264 % \centering
265 % \small
266 % \cisterciansetup{horizontal}\cistercianredraw
267 % \begin{tabular}{*9c}
268 % \examplerow{}
269 % \examplerow{0}
270 % \examplerow{00}
271 % \examplerow{000}
272 % \end{tabular}
273 % \caption{The different base glyphs in horizontal mode\label{fig:glyphs:h}}
274 % \end{figure}
275 %
276 % Since Cistercian numerals quite compactly cover a big range of natural numbers
277 % they might be used to compactly keep track of running numbers. For instance,
278 % to use Cistercian numerals as page numbers you can use:
279 % \begin{verbatim}
280 % \pagenumbering{cistercian}
281 % \end{verbatim}
282 % or to use them as footnotes:
283 % \begin{verbatim}
284 % \renewcommand\thefootnote{\cistercian{footnotes}}
285 % \end{verbatim}
286 %
287 % The package tries to play nice on \pkg{hyperref} if it is loaded, but
288 % bookmarks containing material that should've been a Cistercian numeral will
289 % have a leading |CISTER| in front of the numeric value to give unique
290 % strings compared to |\arabic| (to my knowledge there are no Unicode points for
291 % Cistercian numerals).
292 %
293 % Negative numbers just keep a leading~|-|, and numbers with an absolute number
294 % greater than $9999$ are displayed with multiple Cistercian digits. For
295 % instance $-12345678$ is displayed as \cistexnum{-12345678}. And in the case
296 % that four consecutive digits are zeros they get displayed as that:
297 % \cistexnum{10000} is $10000$.
298 %
299 % Full disclaimer: I'm neither a historian nor have I any authority on the
300 % matter. I'm just a bloke who was fascinated by this numeral system and wanted
301 % to provide \LaTeX\ support for it. Most of my knowledge about this stems from
302 % Wikipedia and similar sources.
303 %
304 %
305 % \subsection{Macros}
306 %
307 % \begin{function}{\cistercian}
308 % \begin{syntax}
309 % \cs{cistercian}\marg{counter}
310 % \end{syntax}
311 % Prints the value of the \LaTeXe\ \meta{counter} as a Cistercian numeral
312 % (similar to how |\roman| prints a \meta{counter} as a Roman numeral). It can
313 % also be used as |\pagenumbering|\hskip0pt |{cistercian}| to change the page
314 % numbering, \emph{etc}.
315 % \end{function}
316 %
317 % \begin{function}{\cisterciannum}
318 % \begin{syntax}
319 % \cs{cisterciannum}\marg{integer}
320 % \end{syntax}
321 % Prints the \meta{integer} as a Cistercian numeral. The \meta{integer} has to
322 % be provided as a string containing only digits and optionally a single
323 % leading~|-| (spaces are ignored). This can handle integers of arbitrary
324 % size.
325 % \end{function}
326 %
327 % \begin{function}{\cistercianeval}
328 % \begin{syntax}
329 % \cs{cistercianeval}\marg{integer expression}
330 % \end{syntax}
331 % Evaluates the \meta{integer expression} and prints the result as a
332 % Cistercian numeral.
333 % \end{function}
334 %
335 % \begin{function}{\cisterciansetup}
336 % \begin{syntax}
337 % \cs{cisterciansetup}\marg{key=value,\ldots}
338 % \end{syntax}
339 % Can be used to locally change the options after the package was loaded. The
340 % glyphs of the Cistercian numerals aren't automatically updated when you
341 % change the setup.
342 % \end{function}
343 %
344 % \begin{function}{\cistercianredraw,\cistercianredrawlazy}
345 % \begin{syntax}
346 % \cs{cistercianredraw}
347 % \end{syntax}
348 % When this is used the glyphs will be redrawn for the current group. The
349 % |lazy| variant will not immediately redraw the glyphs, but instead ensure
350 % that the next usage of a Cistercian numeral in the current scope will redraw
351 % the glyphs. The |lazy| variant could result in the glyphs being redrawn
352 % multiple times (if Cistercian numerals are used in different nested groups),
353 % while the normal variant might result in the glyphs being redrawn too
354 % eagerly.
355 % \end{function}
356 %
357 % \begin{function}{\cistercianstyle}
358 % \begin{syntax}
359 % \cs{cistercianstyle}\meta{*}\marg{name}\marg{key=value,\ldots}
360 % \end{syntax}
361 % With this macro you can define a key called \meta{name} that'll set the
362 % options in the \meta{key=value} list if used inside |\cisterciansetup|.
363 % Only new names are allowed. If your style shouldn't take an argument (so is
364 % fixed) use the normal variant. If your style needs to take an argument use
365 % the variant with \meta{*}.
366 % \end{function}
367 % For example, the key |horizontal| is equivalently defined to and can be used
368 % as
369 % \begin{verbatim}
370 % \cistercianstyle{horizontal}{o=h,wd=0.775em,ht=1.13ex}
371 % \cisterciansetup{horizontal}
372 % \end{verbatim}
373 % And if you want to define a style that at the same time changes the stroke
374 % widths for vertical and horizontal strokes you could use
375 % \begin{verbatim}
376 % \cistercianstyle*{sh+v}{sh={#1},sv={#1}}
377 % \cisterciansetup{sh+v=.12ex}
378 % \end{verbatim}
379 %
380 %
381 % \subsection{Options}
382 %
383 % The options\footnote{\meta{key}=\meta{value} interface powered by
384 % \href{https://ctan.org/pkg/expkv-bundle}{\expkvLogo}} described here are all
385 % usable as package options (except when explicitly stated otherwise).
386 % \pkg{xistercian} doesn't parse the global options provided to the
387 % documentclass. Additionally you can change the options (except for the |debug|
388 % option) using |\cisterciansetup|.
389 %
390 % For the options |width| and |height|, and probably also the strokes, you
391 % should use dimensions using |ex| or |em| to get sizes depending on the current
392 % font size. A \meta{dimension expression} is evaluated (using the setup
393 % specified in |font|) every time the font changed according to the |redraw|
394 % option's feature list (by default only when the size changed) since the last
395 % time they were drawn.
396 %
397 % Initial values if present are printed on the right. A small graphic explaining
398 % most of the size related options is shown in figure~\ref{fig:size}.
399 %
400 % \begin{figure}
401 % \centering
402 % \def\share{1/3}
403 % \expanded
404 % {^^A
405 % \cisterciansetup
406 % {bx=1,by=1,fr=\share,ht=4cm,wd=2cm,sv=9pt,sh=5pt,sdd=9pt,sdu=5pt}^^A
407 % }^^A
408 % \cistercianredraw
409 % \begin{tikzpicture}[>=Stealth,baseline=(base)]
410 % \node[color=green,inner sep=0] (sym) {\cisterciannum{9}};
411 % \begin{scope}[y=(sym.north),x=(sym.east)]
412 % \draw (-1,-1) rectangle (1,1);
413 % \draw[dashed, line width=0.2pt]
414 % \foreach\x in{{-1,0},{1,0},{0,-1},{0,1}} { (0,0) -- (\x) }
415 % ;
416 % \draw[dashed, line width=0.2pt] (0, \share) coordinate(fr) -- ++(1,0);
417 % \draw[<->]
418 % (1.2, 0) -- node[rotate=90,below]{\texttt{0.5*fr*ht}} (1.2,0 |- fr);
419 % \draw[<->] (-1, -1.1) -- node[below]{\texttt{wd}} ++(2,0);
420 % \draw[<->] (-1.2, -1) -- node[rotate=90,above]{\texttt{ht}} ++(0,2);
421 % \draw[red] (-1.6, -1.3) rectangle (1.6, 1.3);
422 % \draw[<->] (-1.6, -1.4) -- node[below]{\texttt{bx*wd}} (1.6, -1.4);
423 % \draw[<->]
424 % (1.8, -1.3) -- node[rotate=90,below]{\texttt{by*ht}} (1.8, 1.3);
425 % \draw[<->]
426 % (-1.8, 0) -- node[rotate=90,above]{\texttt{0.5*bs*ht}} (-1.8, -.75);
427 % \fill (-1.6, -0.75) circle[radius=2pt] coordinate(base);
428 % \end{scope}
429 % \end{tikzpicture}
430 % \cisterciansetup{o=h,ht=2cm,wd=4cm}\cistercianredraw
431 % \begin{tikzpicture}[>=Stealth,baseline=(base)]
432 % \node[color=green,inner sep=0] (sym) {\cisterciannum{9}};
433 % \begin{scope}[y=(sym.north),x=(sym.east)]
434 % \draw (-1,-1) rectangle (1,1);
435 % \draw[dashed, line width=0.2pt]
436 % \foreach\x in{{-1,0},{1,0},{0,-1},{0,1}} { (0,0) -- (\x) }
437 % ;
438 % \draw[dashed, line width=0.2pt] (-\share,0) coordinate(fr) -- ++(0,1);
439 % \draw[<->] (0, 1.2) -- node[above]{\texttt{0.5*fr*wd}} (0,1.2 -| fr);
440 % \draw[<->] (-1, -1.2) -- node[below]{\texttt{wd}} ++(2,0);
441 % \draw[<->] (-1.1, -1) -- node[rotate=90,above]{\texttt{ht}} ++(0,2);
442 % \draw[red] (-1.3, -1.6) rectangle (1.3, 1.6);
443 % \draw[<->] (-1.3, -1.8) -- node[below]{\texttt{bx*wd}} (1.3, -1.8);
444 % \draw[<->]
445 % (1.4, -1.6) -- node[rotate=90,below]{\texttt{by*ht}} (1.4, 1.6);
446 % \draw[<->]
447 % (-1.4, 0) -- node[rotate=90,above]{\texttt{0.5*bs*ht}} (-1.4, -.75);
448 % \fill (-1.3, -0.75) circle[radius=2pt] coordinate(base);
449 % \end{scope}
450 % \end{tikzpicture}
451 % \caption[Measurements of a glyph]
452 % {Measurements of a glyph. The red rectangle is the bounding box, the
453 % dot on the left shows the reference point placed on the surrounding
454 % baseline.\label{fig:size}}
455 % \end{figure}
456 %
457 % \begin{function}{width,wd}
458 % \begin{syntax}
459 % width = \marg{dimension expression} \mydefault{x}
460 % \end{syntax}
461 % Set the width of the Cistercian numeral digits.
462 % \end{function}
463 %
464 % \begin{function}{height,ht}
465 % \begin{syntax}
466 % height = \marg{dimension expression} \mydefault{y}
467 % \end{syntax}
468 % Set the height of the Cistercian numeral digits.
469 % \end{function}
470 %
471 % \begin{function}{bound-x,bx}
472 % \begin{syntax}
473 % bound-x = \marg{float} \mydefault{bx}
474 % \end{syntax}
475 % Specifies the factor the bounding box in $x$-direction is bigger than the
476 % |width|. An empty \meta{float} is considered the same as $1$.
477 % \end{function}
478 %
479 % \begin{function}{bound-y,by}
480 % \begin{syntax}
481 % bound-y = \marg{float} \mydefault{by}
482 % \end{syntax}
483 % Specifies the factor the bounding box in $y$-direction is bigger than the
484 % |height|. An empty \meta{float} is considered the same as $1$.
485 % \end{function}
486 %
487 % \begin{function}{baseline,bs}
488 % \begin{syntax}
489 % baseline = \marg{float} \mydefault{bs}
490 % \end{syntax}
491 % Sets the baseline of the symbols in multiples of the negative height. $1$
492 % (or empty) results in the symbol starting on the surrounding baseline,
493 % bigger values shift the symbols upwards, smaller values downwards.
494 % \end{function}
495 %
496 % \begin{function}{stroke-v,sv}
497 % \begin{syntax}
498 % stroke-v = \marg{dimension expression} \mydefault{tv}
499 % \end{syntax}
500 % Sets the stroke thickness of vertical strokes.
501 % \end{function}
502 %
503 % \begin{function}{stroke-h,sh}
504 % \begin{syntax}
505 % stroke-h = \marg{dimension expression} \mydefault{th}
506 % \end{syntax}
507 % Sets the stroke thickness of horizontal strokes.
508 % \end{function}
509 %
510 % \begin{function}{stroke-du,sdu}
511 % \begin{syntax}
512 % stroke-du = \marg{dimension expression} \mydefault{tdu}
513 % \end{syntax}
514 % Sets the stroke thickness of diagonal strokes going from lower left to upper
515 % right.
516 % \end{function}
517 %
518 % \begin{function}{stroke-dd,sdd}
519 % \begin{syntax}
520 % stroke-dd = \marg{dimension expression} \mydefault{tdd}
521 % \end{syntax}
522 % Sets the stroke thickness of diagonal strokes going from upper left to lower
523 % right.
524 % \end{function}
525 %
526 % \begin{function}{stroke-s,ss}
527 % \begin{syntax}
528 % stroke-s = \marg{dimension expression} \mydefault{ts}
529 % \end{syntax}
530 % Sets the stroke thickness of the zero stem. If this is set to an empty value
531 % the stroke thickness in vertical mode is that of |stroke-v| and in
532 % horizontal mode that of |stroke-h|.
533 % \end{function}
534 %
535 % \begin{function}{strokes,s}
536 % \begin{syntax}
537 % stroke = \marg{dimension expression}
538 % \end{syntax}
539 % Sets all stroke thicknesses at once.
540 % \end{function}
541 %
542 % \begin{function}{fraction,fr}
543 % \begin{syntax}
544 % fraction = \marg{float} \mysdefault{/6}
545 % fraction = \marg{float}/\marg{integer}
546 % \end{syntax}
547 % The Cistercian digits are drawn only in a fraction of the total bounding box
548 % of each symbol. The ones are drawn (with vertical Cistercians) in the upper
549 % right rectangle. The width of that rectangle is determined by |width|, and
550 % the upper border by |height|, and with this option you can set the lower
551 % border as a fraction of the |height|. You can either just give a factor as a
552 % \meta{float}, or just pass in a divisor as an \meta{integer} (with a leading
553 % slash), or both. An empty \meta{float} equals $1$.
554 % \end{function}
555 % Consider the following example (result on the right):\\[\bigskipamount]
556 % \begin{minipage}[c]{.8\linewidth}
557 % \begin{verbatim}
558 % {\cisterciansetup{fr=2/9,redraw}\cisterciannum{9}}\par
559 % {\cisterciansetup{fr=0.6,redraw}\cisterciannum{9}}\par
560 % \end{verbatim}
561 % \end{minipage}
562 % \begin{minipage}[c]{1em}
563 % {\cisterciansetup{fr=2/9,redraw}\cisterciannum{9}}\par
564 % {\cisterciansetup{fr=0.6,redraw}\cisterciannum{9}}\par
565 % \end{minipage}
566 %
567 % \begin{function}{orientation,o}
568 % \begin{syntax}
569 % orientation = \marg{choice} \mysdefault{vertical}
570 % \end{syntax}
571 % Sets the orientation of the Cistercian numerals. Choices are |horizontal|
572 % (or |h| for short) or |vertical| (or |v| for short). You'll most likely want
573 % to change the |width| and |height| of the symbols if you decide to change
574 % this.
575 % \end{function}
576 %
577 % \begin{function}{horizontal}
578 % \begin{syntax}
579 % horizontal
580 % \end{syntax}
581 % Same as setting
582 % |orientation = horizontal, width = 0.775em, height = 1.13ex|.
583 % \end{function}
584 %
585 % \begin{function}{vertical}
586 % \begin{syntax}
587 % vertical
588 % \end{syntax}
589 % Same as setting |orientation = vertical, width = 0.5em, height = 1.55ex|.
590 % \end{function}
591 %
592 % \begin{function}{alternate-5,5}
593 % \begin{syntax}
594 % alternate-5 = \marg{choice} \mysdefault{triangle}
595 % \end{syntax}
596 % There are alternative forms of the digit $5$. While the most often used one
597 % nowadays seems to be the |triangle| form, this package also supports two
598 % other variants. Those are called |dot| and |dash|. While if you choose
599 % |triangle| you can't give an additional value, if your choice is |dot| or
600 % |dash| you can customise those using a second equals sign and some value. If
601 % you don't customise them they use their respective initial value (or last
602 % value if you changed the value at some point in time).
603 %
604 % For |dot| you can also specify the radius as a dimension. The default is
605 % \mydefault{five@dot}.
606 %
607 % For |dash| you can specify the length of the dash in multiples of the used
608 % stroke thickness (which might differ for the horizontal and vertical
609 % symbols), an empty value is considered the same as $1$. The default is
610 % \mydefault{five@dash}. Please ensure that your readers can't confuse the
611 % results with the shape of $6$.
612 %
613 % A comparison of the three alternate forms is shown in
614 % figure~\ref{fig:fives}.
615 % \end{function}
616 % The usage might look like any of the following:
617 % \begin{verbatim}
618 % \cisterciansetup
619 % {
620 % 5=triangle, 5={triangle},
621 % 5=dot, 5={dot}, 5=dot=.1ex, 5={dot=.1ex},
622 % 5=dash, 5={dash}, 5=dash=2, 5={dash=2}
623 % }
624 % \end{verbatim}
625 %
626 % \begin{figure}
627 % \centering
628 % \exampledigits{5555}%
629 % \begingroup
630 % \cisterciansetup{vex}%
631 % \begin{tabular}{*5c}
632 % \texttt{triangle} &
633 % \texttt{dot=2pt} & \texttt{dot=4pt} &
634 % \texttt{dash=1} & \texttt{dash=3} \\
635 % \showbb{5=triangle} &
636 % \showbb{5=dot=2pt} & \showbb{5=dot=4pt} &
637 % \showbb{5=dash=1} & \showbb{5=dash=3} \\
638 % \showbb{5=triangle,hex} &
639 % \showbb{5=dot=2pt,hex} & \showbb{5=dot=4pt,hex} &
640 % \showbb{5=dash=1, hex} & \showbb{5=dash=3, hex} \\
641 % \end{tabular}
642 % \endgroup
643 % \caption[Alternate forms of the digit $5$]
644 % {Alternate forms of the digit $5$. The length of the \texttt{dash=3}
645 % variant is too long in the normal setup of this document, as the
646 % difference between {\cisterciansetup{5=dash=3,r!}\cisterciannum{5555}}
647 % and \cisterciannum{6666} is hard to notice. The tight bounding boxes
648 % using \texttt{bx=1,by=1} are drawn red.\label{fig:fives}}
649 % \end{figure}
650 %
651 % \begin{function}{alternate-6,6}
652 % \begin{syntax}
653 % \cs{alternate-6} = \marg{choice} \mysdefault{stroke}
654 % \end{syntax}
655 % There are alternative forms of the digit $6$. While today the usual form is
656 % |stroke|, there are also historic documents showing the $6$ as two dots,
657 % which you can achieve using the |dot| choice, and to support squares or
658 % short dashes instead of round dots you can use the |dash| choice.
659 %
660 % For |dot| you can also specify the radius as a dimension. The default is
661 % \mydefault{six@dot}. And for |dash| you can also specify the length in
662 % multiples of the used stroke thickness, an empty value is considered the
663 % same as $1$. The default is \mydefault{six@dash}. The |stroke| has always
664 % the full length and doesn't accept an additional specification.
665 %
666 % A comparison of the alternate forms is shown in figure~\ref{fig:69}.
667 % \end{function}
668 %
669 % \begin{function}{alternate-9,9}
670 % \begin{syntax}
671 % \cs{alternate-9} = \marg{choice} \mysdefault{rectangle}
672 % \end{syntax}
673 % Another digit having alternative forms is the $9$. For this two
674 % \meta{choice}s are available, |rectangle| and |triangle|. Neither of the two
675 % accept additional specifications.
676 %
677 % A comparison of the alternate forms is shown in figure~\ref{fig:69}.
678 % \end{function}
679 %
680 % \begin{figure}
681 % \centering
682 % \exampledigits{6666}%
683 % \cisterciansetup{vex}%
684 % \begin{tabular}{@{}*5c}
685 % \texttt{stroke} & \texttt{dot=2pt} & \texttt{dot=4pt}
686 % & \texttt{dash=1} & \texttt{dash=2} \\
687 % \showbb{6=stroke} & \showbb{6=dot=2pt} & \showbb{6=dot=4pt}
688 % & \showbb{6=dash=1} & \showbb{6=dash=2} \\
689 % \showbb{6=stroke,hex} & \showbb{6=dot=2pt,hex} & \showbb{6=dot=4pt,hex}
690 % & \showbb{6=dash=1, hex} & \showbb{6=dash=2, hex} \\
691 % \end{tabular}\hfill
692 % \exampledigits{9999}%
693 % \begin{tabular}{*2c@{}}
694 % \texttt{rectangle} & \texttt{triangle} \\
695 % \showbb{9=rectangle} & \showbb{9=triangle} \\
696 % \showbb{9=rectangle,hex} & \showbb{9=triangle,hex} \\
697 % \end{tabular}
698 % \caption[Alternate forms of the digits $6$ and $9$]
699 % {Alternate forms of the digits $6$ (left) and $9$ (right). The tight
700 % bounding boxes using \texttt{bx=1,by=1} are drawn red.\label{fig:69}}
701 % \end{figure}
702 %
703 % \begin{function}{font,f}
704 % \begin{syntax}
705 % font = \marg{font setup} \mydefault{font}
706 % \end{syntax}
707 % Set the font which \pkg{xistercian} uses locally to evaluate the dimensions
708 % given to |width|, |height|, and |stroke| (only font switches work here, you
709 % can't use stuff like |\texttt|, instead use |\ttfamily|).
710 % \end{function}
711 %
712 % \begin{function}{redraw,r}
713 % \begin{syntax}
714 % redraw = \marg{feature-list} \mysdefault{size}
715 % redraw += \marg{feature-list}
716 % redraw
717 % redraw!
718 % \end{syntax}
719 % Selects which font features to consider when deciding to redraw the glyphs.
720 % If one of the features has changed (or the features to consider) the glyphs
721 % will be redrawn. This is especially handy if you change the |font| used
722 % while evaluating the given dimensions. The available features in the comma
723 % separated \meta{feature-list} are |encoding|, |family|, |series|, |shape|,
724 % |size|, and |color|.
725 %
726 % If you see that a Cistercian numeral doesn't have the correct colour of the
727 % surrounding text you need to add |color| to the font features
728 % (\pkg{xistercian} uses some hack to get the boxed glyphs to respect the
729 % surrounding colour, but that hack might fail in certain circumstances).
730 %
731 % If you use the |+=|~variant of this option the \meta{feature-list} is added
732 % to the existing features, else they overwrite any existing configuration.
733 %
734 % Without a value the key will issue |\cistercianredrawlazy|, and if you use
735 % the |!|~variant it'll use |\cistercianredraw|. This usage is only available
736 % after the package was loaded.
737 % \end{function}
738 %
739 % \begin{function}{debug}
740 % \begin{syntax}
741 % debug
742 % \end{syntax}
743 % Only usable as a package option. If this is used a bit of debugging
744 % information is printed in the log file and terminal, and some keys try to
745 % evaluate the given argument on the spot instead of lazily. This might help
746 % to locate faulty input.
747 % \end{function}
748 %
749 %
750 % \subsection{Bold Cistercian Numerals}
751 %
752 % While the package doesn't directly support bold glyphs, it is possible to
753 % utilize the hooks provided by the NFSS to pick different stroke widths
754 % whenever the font is changed to |bfseries| and back to |mdseries|:
755 %
756 % \begin{verbatim}
757 % \AddToHook{bfseries}
758 % {%
759 % \cisterciansetup{sv=.27ex,sdd=.27ex,sh=.15ex,sdu=.15ex,wd=.625em}%
760 % \cistercianredrawlazy
761 % }
762 % \AddToHook{mdseries}
763 % {%
764 % \cisterciansetup{sv=.18ex,sdd=.18ex,sh=.1ex,sdu=.1ex,wd=.5em}%
765 % \cistercianredrawlazy
766 % }
767 % This results in \cisterciannum{2} different \enquote{series}.\par
768 % \bfseries
769 % This results in \cisterciannum{2} different \enquote{series}.
770 % \end{verbatim}
771 %
772 % \begingroup
773 % This results in \cisterciannum{2} different \enquote{series}.\par
774 % \bfseries
775 % This results in \cisterciannum{2} different \enquote{series}.
776 % \endgroup
777 %
778 % Of course, instead of doing |\cistercianredrawlazy| in the above code, we
779 % could as well do the following equivalent thing and let \pkg{xistercian}
780 % determine when to redraw:
781 % \begin{verbatim}
782 % \AddToHook{bfseries}
783 % {\cisterciansetup{sv=.27ex,sdd=.27ex,sh=.15ex,sdu=.15ex,wd=.625em}}
784 % \AddToHook{mdseries}
785 % {\cisterciansetup{sv=.18ex,sdd=.18ex,sh=.1ex,sdu=.1ex,wd=.5em}}
786 % \cisterciansetup{redraw+=series}
787 % \end{verbatim}
788 %
789 %
790 % \clearpage
791 % \section{Implementation}
792 %
793 % First we say who we are and load the required packages
794 % \gobbledocstriptag
795 %<*pkg>
796 % \begin{macrocode}
797 \ProvidesPackage{xistercian}[2025-04-13 v1.3 Cistercian numerals in LaTeX]
798 \RequirePackage{pgf,expkv-opt}
799 % \end{macrocode}
800 %
801 %
802 % \subsection{Variables}
803 %
804 % There are variables stored as macros to be evaluated later, as well as
805 % register types for faster access during the glyph drawing.
806 % \begin{macrocode}
807 \newcommand*\xister@th{.1ex}
808 \newcommand*\xister@tv{.18ex}
809 \newcommand*\xister@tdu{.1ex}
810 \newcommand*\xister@tdd{.18ex}
811 \newcommand*\xister@ts{}
812 \newcommand*\xister@x{.5em}
813 \newcommand*\xister@y{1.55ex}
814 \newcommand*\xister@bx{1.2}
815 \newcommand*\xister@by{}
816 \newcommand*\xister@bs{}
817 \newcommand*\xister@font{\normalfont}
818 \newcommand*\xister@five@dot{.09ex}
819 \newcommand*\xister@five@dash{}
820 \newcommand*\xister@six@dot{.09ex}
821 \newcommand*\xister@six@dash{}
822 \newcommand*\xister@share@div{/6}
823 \newcommand*\xister@share@mul{}
824 \newif\ifxister@dbg@
825 \newif\ifxister@five@triangle@\xister@five@triangle@true
826 \newif\ifxister@five@dot@
827 \newif\ifxister@six@dot@
828 \newif\ifxister@six@stroke@\xister@six@stroke@true
829 \newif\ifxister@nine@triangle@
830 \newdimen\xister@X
831 \newdimen\xister@Y
832 \newdimen\xister@XY@share
833 \newdimen\xister@Th
834 \newdimen\xister@Tv
835 \newdimen\xister@Tdu
836 \newdimen\xister@Tdd
837 \newdimen\xister@Ts
838 \newdimen\xister@TMPA
839 \newdimen\xister@TMPB
840 \newdimen\xister@Five@dot
841 \newdimen\xister@Six@dot
842 % \end{macrocode}
843 %
844 % We also need a bunch of box registers ($37$ of them to be precise). For the
845 % loop we borrow an \pkg{expl3} function.
846 % \begin{macrocode}
847 \ExplSyntaxOn
848 \int_step_inline:nn {9}
849 {
850 \expandafter\newsavebox\csname xister@digitbox@#1\endcsname
851 \expandafter\newsavebox\csname xister@digitbox@#10\endcsname
852 \expandafter\newsavebox\csname xister@digitbox@#100\endcsname
853 \expandafter\newsavebox\csname xister@digitbox@#1000\endcsname
854 }
855 \ExplSyntaxOff
856 \expandafter\newsavebox\csname xister@digitbox@0\endcsname
857 % \end{macrocode}
858 %
859 % \begin{macro}[internal]{\xister@dbg@dim,\xister@dbg@float}
860 % These are initially just |\@gobble|, but the |debug| option might change
861 % things.
862 % \begin{macrocode}
863 \let\xister@dbg@dim\@gobble
864 \let\xister@dbg@div\@gobble
865 \let\xister@dbg@float\@gobble
866 % \end{macrocode}
867 % \end{macro}
868 %
869 %
870 % \subsection{Options}
871 %
872 % Some macros are required to parse options.
873 %
874 % \begin{macro}[internal]{\xister@if@slash}
875 % We need to test whether a slash is inside an argument to parse some user
876 % option. Since this isn't needed inside an inner loop we don't create an
877 % optimised version and only borrow a generic \pkg{expl3} function.
878 % \begin{macrocode}
879 \ExplSyntaxOn
880 \cs_new_protected:Npn \xister@if@slash #1 { \tl_if_in:nnTF {#1} { / } }
881 \ExplSyntaxOff
882 % \end{macrocode}
883 % \end{macro}
884 %
885 % \begin{macro}[internal]{\xister@fraction}
886 % \begin{macrocode}
887 \protected\long\def\xister@fraction#1/#2\xister@stop
888 {%
889 \edef\xister@share@mul{\unexpanded{#1}}%
890 \xister@dbg@float{#1}%
891 \edef\xister@share@div{/\unexpanded{#2}}%
892 \xister@dbg@div{#2}%
893 }
894 % \end{macrocode}
895 % \end{macro}
896 %
897 % \begin{macro}[internal]
898 % {
899 % \xister@build,
900 % \xister@build@h,\xister@build@horizontal,
901 % \xister@build@v,\xister@build@vertical
902 % }
903 % First we set the length registers to the correct size, then we draw the
904 % glyphs batch wise. We have to flip the $x$-direction for the tenths and
905 % thousands, and the $y$-direction for the hundreds and thousands. The macro
906 % |\xister@sgn| is used to set the baseline in the correct direction. We
907 % locally disable |\pgfsetcolor| to allow building colour-unsafe boxes. This
908 % only works as long as \pkg{luacolor} (or something equivalent) isn't used,
909 % so consider this a crude hack.
910 % \begin{macrocode}
911 \protected\def\xister@build@vertical
912 {%
913 \let\xister@pgfsetcolor\pgfsetcolor
914 \let\pgfsetcolor\@gobble
915 \xister@setlengths
916 \def\xister@sgn{-}%
917 \xister@drawzero@vertical
918 \xister@drawdigits@vertical{}{}{}%
919 \xister@X=-\xister@X
920 \xister@Y=-\xister@Y
921 \def\xister@sgn{+}%
922 \xister@drawdigits@vertical{000}{-}{-}%
923 \xister@TMPA=\xister@Tdd
924 \xister@Tdd=\xister@Tdu
925 \xister@Tdu=\xister@TMPA
926 \xister@X=-\xister@X
927 \xister@drawdigits@vertical{00}{-}{}%
928 \xister@X=-\xister@X
929 \xister@Y=-\xister@Y
930 \def\xister@sgn{-}%
931 \xister@drawdigits@vertical{0}{}{-}%
932 \let\pgfsetcolor\xister@pgfsetcolor
933 }
934 \protected\def\xister@build@horizontal
935 {%
936 \let\xister@pgfsetcolor\pgfsetcolor
937 \let\pgfsetcolor\@gobble
938 \xister@setlengths
939 \def\xister@sgn{-}%
940 \xister@drawzero@horizontal
941 \xister@drawdigits@horizontal{}{}{}%
942 \xister@X=-\xister@X
943 \xister@Y=-\xister@Y
944 \def\xister@sgn{+}%
945 \xister@drawdigits@horizontal{000}{-}{-}%
946 \xister@TMPA=\xister@Tdd
947 \xister@Tdd=\xister@Tdu
948 \xister@Tdu=\xister@TMPA
949 \xister@X=-\xister@X
950 \xister@drawdigits@horizontal{0}{-}{}%
951 \xister@X=-\xister@X
952 \xister@Y=-\xister@Y
953 \def\xister@sgn{-}%
954 \xister@drawdigits@horizontal{00}{}{-}%
955 \let\pgfsetcolor\xister@pgfsetcolor
956 }
957 \let\xister@build\xister@build@vertical
958 \let\xister@build@v\xister@build@vertical
959 \let\xister@build@h\xister@build@horizontal
960 % \end{macrocode}
961 % \end{macro}
962 %
963 % \begin{macro}[internal]{\xister@fontfeatures,\xister@add@fontfeature}
964 % This macro should store the different font features which should be kept
965 % track of. It will be redefined programmatically but the default is quite
966 % easy, just track the font size.
967 % \begin{macrocode}
968 \protected\long\def\xister@add@fontfeature#1%
969 {%
970 \begingroup\expandafter\expandafter\expandafter\endgroup
971 \expandafter\ifx
972 \csname xister@add@fontfeature@\detokenize{#1}\endcsname
973 \relax
974 \PackageError{xistercian}{Unsupported font feature `\detokenize{#1}'.}{}%
975 \else
976 \csname xister@add@fontfeature@\detokenize{#1}\endcsname
977 \fi
978 }
979 \def\xister@fontfeatures{\unexpanded\expandafter{\f@size}/}
980 % \end{macrocode}
981 % We know that the colour hack breaks if \pkg{luacolor} is loaded, so if that
982 % is found to be the case we add the |color| feature to the list of things we
983 % need to track. But we only want to add it if it's not yet in the list, so we
984 % run a check we borrow from \pkg{expl3}.
985 % \begin{macrocode}
986 \ExplSyntaxOn
987 \AddToHook{begindocument/before}
988 {
989 \@ifpackageloaded { luacolor }
990 {
991 \exp_args:No \str_if_in:nnF \xister@fontfeatures { color }
992 { \xister@add@fontfeature{color} }
993 }
994 {}
995 }
996 \ExplSyntaxOff
997 % \end{macrocode}
998 % \end{macro}
999 %
1000 % \begin{macro}[internal]
1001 % {
1002 % \xister@add@fontfeature@encoding,
1003 % \xister@add@fontfeature@family,
1004 % \xister@add@fontfeature@series,
1005 % \xister@add@fontfeature@shape,
1006 % \xister@add@fontfeature@size,
1007 % }
1008 % These macros all just add a specific macro to the list of things contained
1009 % in |\xister@fontfeatures|, which determines what to consider deciding to
1010 % redraw.
1011 % \begin{macrocode}
1012 \def\xister@tmp#1#2%
1013 {%
1014 \protected\expandafter\def\csname xister@add@fontfeature@#2\endcsname
1015 {%
1016 \edef\xister@fontfeatures
1017 {%
1018 \unexpanded\expandafter
1019 {\xister@fontfeatures\unexpanded\expandafter{#1}}/%
1020 }%
1021 }%
1022 }
1023 \expandafter\xister@tmp\csname\@backslashchar color@.\endcsname{color}
1024 \xister@tmp\f@encoding{encoding}
1025 \xister@tmp\f@family {family}
1026 \xister@tmp\f@series {series}
1027 \xister@tmp\f@shape {shape}
1028 \xister@tmp\f@size {size}
1029 % \end{macrocode}
1030 % \end{macro}
1031 %
1032 % Now we define the keys
1033 % \begin{macrocode}
1034 \ekvifdefinedset{xister}
1035 {\PackageError{xistercian}{keyval conflict detected. Aborting}{}\endinput}{}
1036 % \end{macrocode}
1037 % We'll define a shorthand name and a long name for all the keys, so we set up
1038 % an auxiliary here for these definitions that'll just take two key names
1039 % instead of one for each definition.
1040 % \begin{macrocode}
1041 \def\xister@tmp#1#2#3%
1042 {%
1043 \protected\long\ekvdef{xister}{#1}{#3}%
1044 \ekvletkv{xister}{#2}{xister}{#1}%
1045 }
1046 \xister@tmp{wd}{width}{\edef\xister@x{\unexpanded{#1}}\xister@dbg@dim{#1}}
1047 \xister@tmp{ht}{height}{\edef\xister@y{\unexpanded{#1}}\xister@dbg@dim{#1}}
1048 \xister@tmp{bx}{bound-x}{\edef\xister@bx{\unexpanded{#1}}\xister@dbg@float{#1}}
1049 \xister@tmp{by}{bound-y}{\edef\xister@by{\unexpanded{#1}}\xister@dbg@float{#1}}
1050 \xister@tmp{bs}{baseline}{\edef\xister@bs{\unexpanded{#1}}\xister@dbg@float{#1}}
1051 \xister@tmp{sv}{stroke-v}{\edef\xister@tv{\unexpanded{#1}}\xister@dbg@dim{#1}}
1052 \xister@tmp{sh}{stroke-h}{\edef\xister@th{\unexpanded{#1}}\xister@dbg@dim{#1}}
1053 \xister@tmp{sdu}{stroke-du}
1054 {\edef\xister@tdu{\unexpanded{#1}}\xister@dbg@dim{#1}}
1055 \xister@tmp{sdd}{stroke-dd}
1056 {\edef\xister@tdd{\unexpanded{#1}}\xister@dbg@dim{#1}}
1057 \xister@tmp{ss}{stroke-s}
1058 {%
1059 \edef\xister@ts{\unexpanded{#1}}%
1060 \unless\ifx\xister@ts\@empty\xister@dbg@dim{#1}\fi
1061 }
1062 \xister@tmp{s}{strokes}
1063 {%
1064 \edef\xister@tv{\unexpanded{#1}}%
1065 \let\xister@th\xister@tv
1066 \let\xister@tdu\xister@tv
1067 \let\xister@tdd\xister@tv
1068 \let\xister@ts\xister@tv
1069 \xister@dbg@dim{#1}%
1070 }
1071 \xister@tmp{f}{font}{\edef\xister@font{\unexpanded{#1}}}
1072 \xister@tmp{o}{orientation}
1073 {%
1074 \begingroup\expandafter\expandafter\expandafter\endgroup
1075 \expandafter\ifx\csname xister@build@#1\endcsname\relax
1076 \PackageError{xister}%
1077 {Unaccepted orientation. Choices are horizontal/h or vertical/v}{}%
1078 \else
1079 \expandafter\let\expandafter\xister@build\csname xister@build@#1\endcsname
1080 \fi
1081 }
1082 \xister@tmp{fr}{fraction}
1083 {%
1084 \xister@if@slash{#1}%
1085 {\xister@fraction#1\xister@stop}%
1086 {%
1087 \let\xister@share@div\@empty
1088 \edef\xister@share@mul{\unexpanded{#1}}%
1089 \xister@dbg@float{#1}%
1090 }%
1091 }
1092 \xister@tmp{r}{redraw}
1093 {\let\xister@fontfeatures\@empty\ekvcsvloop\xister@add@fontfeature{#1}}
1094 \xister@tmp{r+}{redraw+}{\ekvcsvloop\xister@add@fontfeature{#1}}
1095 \ekvletkv{xister}{r +}{xister}{r+}
1096 \ekvletkv{xister}{redraw +}{xister}{redraw+}
1097 \protected\long\ekvdef{xister/5}{dot}
1098 {%
1099 \xister@five@triangle@false
1100 \xister@five@dot@true
1101 \edef\xister@five@dot{\unexpanded{#1}}%
1102 \xister@dbg@dim{#1}%
1103 }
1104 \protected\long\ekvdef{xister/5}{dash}
1105 {%
1106 \xister@five@triangle@false
1107 \xister@five@dot@false
1108 \edef\xister@five@dash{\unexpanded{#1}}%
1109 \xister@dbg@float{#1}%
1110 }
1111 \protected\ekvdefNoVal{xister/5}{triangle}{\xister@five@triangle@true}
1112 \protected\ekvdefNoVal{xister/5}{dot}
1113 {%
1114 \xister@five@triangle@false
1115 \xister@five@dot@true
1116 }
1117 \protected\ekvdefNoVal{xister/5}{dash}
1118 {%
1119 \xister@five@triangle@false
1120 \xister@five@dot@false
1121 }
1122 % \end{macrocode}
1123 % Starting here the |\xister@tmp| macro is no longer the shorthand for the
1124 % doubled definitions!
1125 % \begin{macrocode}
1126 \protected\ekvsetdef\xister@tmp{xister/5}
1127 \ekvlet{xister}{5}\xister@tmp
1128 \ekvlet{xister}{alternate-5}\xister@tmp
1129 \protected\long\ekvdef{xister/6}{dot}
1130 {%
1131 \xister@six@stroke@false
1132 \xister@six@dot@true
1133 \edef\xister@six@dot{\unexpanded{#1}}%
1134 \xister@dbg@dim{#1}%
1135 }
1136 \protected\long\ekvdef{xister/6}{dash}
1137 {%
1138 \xister@six@stroke@false
1139 \xister@six@dot@false
1140 \edef\xister@six@dash{\unexpanded{#1}}%
1141 \xister@dbg@float{#1}%
1142 }
1143 \protected\ekvdefNoVal{xister/6}{stroke}{\xister@six@stroke@true}
1144 \protected\ekvdefNoVal{xister/6}{dot}
1145 {%
1146 \xister@six@stroke@false
1147 \xister@six@dot@true
1148 }
1149 \protected\ekvdefNoVal{xister/6}{dash}
1150 {%
1151 \xister@six@stroke@false
1152 \xister@six@dot@false
1153 }
1154 \protected\ekvsetdef\xister@tmp{xister/6}
1155 \ekvlet{xister}{6}\xister@tmp
1156 \ekvlet{xister}{alternate-6}\xister@tmp
1157 \protected\ekvdefNoVal{xister/9}{rectangle}{\xister@nine@triangle@false}
1158 \protected\ekvdefNoVal{xister/9}{triangle}{\xister@nine@triangle@true}
1159 \protected\ekvsetdef\xister@tmp{xister/9}
1160 \ekvlet{xister}{9}\xister@tmp
1161 \ekvlet{xister}{alternate-9}\xister@tmp
1162 \protected\ekvdefNoVal{xister}{horizontal}
1163 {%
1164 \let\xister@build\xister@build@horizontal
1165 \def\xister@x{.775em}%
1166 \def\xister@y{1.13ex}%
1167 }
1168 \protected\ekvdefNoVal{xister}{vertical}
1169 {%
1170 \let\xister@build\xister@build@vertical
1171 \def\xister@x{.5em}%
1172 \def\xister@y{1.55ex}%
1173 }
1174 % \end{macrocode}
1175 % The |debug| option redefines the debug macros to the correct definition.
1176 % \begin{macrocode}
1177 \protected\ekvdefNoVal{xister}{debug}
1178 {%
1179 \xister@dbg@true
1180 \protected\long\def\xister@dbg@msg##1%
1181 {%
1182 \begingroup
1183 \newlinechar`\^^J
1184 \message{##1}%
1185 \endgroup
1186 }%
1187 \protected\long\def\xister@dbg@do##1%
1188 {\xister@dbg@msg{^^JPackage xistercian Debug: ##1...}}%
1189 \protected\long\def\xister@dbg@done{\xister@dbg@msg{ Done.^^J}}%
1190 \protected\long\def\xister@dbg@dim##1%
1191 {%
1192 \xister@dbg@do{Trying to use dimension `\unexpanded{##1}'}%
1193 \xister@TMPA=\dimexpr##1\relax
1194 \xister@dbg@done
1195 }%
1196 \protected\long\def\xister@dbg@float##1%
1197 {%
1198 \xister@dbg@do{Trying to use float `\unexpanded{##1}'}%
1199 \xister@TMPA=##1\z@
1200 \xister@dbg@done
1201 }%
1202 \protected\long\def\xister@dbg@div##1%
1203 {%
1204 \xister@dbg@do{Trying to use divisor `\unexpanded{##1}'}%
1205 \xister@TMPA=\dimexpr\z@/##1\relax
1206 \xister@dbg@done
1207 }%
1208 }
1209 % \end{macrocode}
1210 % and parse the package options (and since the used names |width|, |height|, and
1211 % |debug| are quite frequent we don't look at the global options).
1212 % \begin{macrocode}
1213 \ekvoProcessLocalOptions{xister}
1214 % \end{macrocode}
1215 %
1216 % After the package was loaded we add the two |redraw| variants without a value.
1217 % \begin{macrocode}
1218 \protected\ekvdefNoVal{xister}{r!}{\cistercianredraw}
1219 \protected\ekvdefNoVal{xister}{r} {\cistercianredrawlazy}
1220 \ekvletkvNoVal{xister}{redraw} {xister}{r}
1221 \ekvletkvNoVal{xister}{redraw!}{xister}{r!}
1222 % \end{macrocode}
1223 %
1224 % The |debug| option is only available as a package option, we let it throw an
1225 % error:
1226 % \begin{macrocode}
1227 \ekvdefNoVal{xister}{debug}
1228 {\PackageError{xister}{`debug' is only available as a load time option}{}}
1229 % \end{macrocode}
1230 %
1231 %
1232 % \subsection{User macros}
1233 %
1234 % \begin{macro}{\cisterciansetup}
1235 % Just as a simple way to pick options later on.
1236 % \begin{macrocode}
1237 \protected\ekvsetdef\cisterciansetup{xister}
1238 % \end{macrocode}
1239 % \end{macro}
1240 %
1241 % \begin{macro}{\cistercianstyle}
1242 % \begin{macro}[internal]{\xister@style}
1243 % We allow users to define a style they can call with a single key name inside
1244 % |\cisterciansetup|. To achieve that we just define a |NoVal| key that'll
1245 % call a nested |\cisterciansetup|, or a normal key if their style needs to
1246 % take a value.
1247 % \begin{macrocode}
1248 \protected\def\cistercianstyle
1249 {%
1250 \@ifstar
1251 {\xister@style\ekvifdefined{\long\ekvdef}}%
1252 {\xister@style\ekvifdefinedNoVal\ekvdefNoVal}%
1253 }
1254 \protected\long\def\xister@style#1#2#3#4%
1255 {%
1256 #1{xister}{#3}%
1257 {\PackageError{xistercian}{Key `#3' already defined}{}}%
1258 {\protected#2{xister}{#3}{\cisterciansetup{#4}}}%
1259 }
1260 % \end{macrocode}
1261 % \end{macro}
1262 % \end{macro}
1263 %
1264 % \begin{macro}{\cistercian}
1265 % \begin{macro}[internal]{\@cistercian}
1266 % The macro is equivalent to other \LaTeX\ counter formatting macros, so we
1267 % let it build the counter name and forward that to the canonically named
1268 % auxiliary macro |\@cistercian|.
1269 % \begin{macrocode}
1270 \newcommand\cistercian[1]{\expandafter\@cistercian\csname c@#1\endcsname}
1271 % \end{macrocode}
1272 % The internal just gets the current value of a counter and forwards it.
1273 % \begin{macrocode}
1274 \newcommand\@cistercian[1]{\expandafter\cisterciannum\expandafter{\the#1}}
1275 % \end{macrocode}
1276 % \end{macro}
1277 % \end{macro}
1278 %
1279 %
1280 % \begin{macro}{\cisterciannum}
1281 % \begin{macro}[internal]{\cisterciannum@pdf}
1282 % \begin{macrocode}
1283 \edef\cisterciannum
1284 {%
1285 \unexpanded{\xister@texorpdf}%
1286 \unexpanded\expandafter
1287 {\csname cisterciannum \endcsname\cisterciannum@pdf}%
1288 }
1289 \protected\expandafter\def\csname cisterciannum \endcsname#1{\xister@a#1@}
1290 \def\cisterciannum@pdf#1{CISTER#1}
1291 % \end{macrocode}
1292 % \end{macro}
1293 % \end{macro}
1294 %
1295 % \begin{macro}{\cistercianeval,\cisterciannumE}
1296 % The second macro is just there for backwards compatibility and deprecated.
1297 % \begin{macrocode}
1298 \newcommand\cistercianeval[1]
1299 {\expandafter\cisterciannum\expandafter{\the\numexpr#1\relax}}
1300 \let\cisterciannumE\cistercianeval
1301 % \end{macrocode}
1302 % \end{macro}
1303 %
1304 % \begin{macro}{\cistercianredraw,\cistercianredrawlazy}
1305 % \begin{macrocode}
1306 \protected\def\cistercianredraw
1307 {%
1308 \def\xister@last@font{\xister@last@font}%
1309 \xister@ensure@current
1310 }
1311 \protected\def\cistercianredrawlazy{\def\xister@last@font{\xister@last@font}}
1312 % \end{macrocode}
1313 % \end{macro}
1314 %
1315 %
1316 % \subsection{Parsing}
1317 %
1318 % \subsubsection{Small Auxiliaries}
1319 %
1320 % \begin{macro}[internal]
1321 % {\xister@gobbletoat,\xister@gobbletozero,\xister@gobblecopy,\xister@done}
1322 % These are just small functions gobbling some tokens.
1323 % \begin{macrocode}
1324 \def\xister@gobbletoat#1@{}
1325 \def\xister@gobbletozero#10{}
1326 \def\xister@gobblecopy0\rlap#1{}
1327 \def\xister@done#1\xister@symbols{}
1328 % \end{macrocode}
1329 % \end{macro}
1330 %
1331 % \begin{macro}[internal]{\xister@texorpdf}
1332 % \begin{macrocode}
1333 \let\xister@texorpdf\@firstoftwo
1334 \AddToHook{package/hyperref/after}
1335 {%
1336 \ifdefined\texorpdfstring
1337 \def\xister@texorpdf{\texorpdfstring}%
1338 \fi
1339 }
1340 \AddToHook{begindocument/before}
1341 {%
1342 \ifdefined\texorpdfstring
1343 \def\xister@texorpdf{\texorpdfstring}%
1344 \fi
1345 }
1346 % \end{macrocode}
1347 % \end{macro}
1348 %
1349 %
1350 % \subsubsection{Input Parsing}
1351 %
1352 % \begin{macro}[internal]{\xister@a,\xister@b,\xister@c,\xister@d}
1353 % First we have to make sure that we're in horizontal mode, else the |\rlap|s
1354 % used to insert the glyphs will create havoc. We also need to ensure that the
1355 % boxes contain the correct glyphs according to the current size and colour.
1356 % After that we check whether we have to step over a minus sign and go to the
1357 % next step.
1358 % \begin{macrocode}
1359 \def\xister@a#1%
1360 {%
1361 \leavevmode
1362 \xister@ensure@current
1363 \ifx-#1-\expandafter\xister@b
1364 \else\expandafter\xister@b\expandafter#1\fi
1365 }
1366 % \end{macrocode}
1367 % Next we check whether the remaining number is empty. If that is the case we
1368 % use |\the\numexpr\relax| to throw a missing number error and produce just a
1369 % zero stem. Else we do a dry run over the input number to see how many
1370 % leading zeros we must pad to get blocks of four. The two blocks of |@|s
1371 % serve as end markers since each step of both \cs{xister@c} grabs eight and
1372 % each of \cs{xister@symbols} will grab four digits. The \cs{xister@c} is
1373 % used to put enough zeros in front of our number such that it consists of
1374 % blocks of four digits.
1375 % \begin{macrocode}
1376 \def\xister@b#1@%
1377 {%
1378 \if\relax\detokenize{#1}\relax
1379 \expandafter\xister@gobbletozero\the\numexpr\relax
1380 \xister@symbols0000@@@@%
1381 \expandafter\@gobbletwo
1382 \fi
1383 \@firstofone{\xister@c#1@@@@@@@@\relax#1@@@@}%
1384 }
1385 \def\xister@c#1#2#3#4#5#6#7#8%
1386 {%
1387 \xister@gobbletoat
1388 #1\xister@d{}%
1389 #2\xister@d{000}%
1390 #3\xister@d{00}%
1391 #4\xister@d0%
1392 #5\xister@d{}%
1393 #6\xister@d{000}%
1394 #7\xister@d{00}%
1395 #8\xister@d0%
1396 @\xister@c
1397 }
1398 \def\xister@d#1#2@\xister@c#3\relax{\xister@symbols#1}
1399 % \end{macrocode}
1400 % \end{macro}
1401 %
1402 % \begin{macro}[internal]{\xister@symbols}
1403 % When this loop is done all arguments will be |@|, but we only check the
1404 % first here. We generate the symbols by overlaying up to five boxes, one for
1405 % each decade plus the zero stem. Each digit might be skipped if it is $0$.
1406 % Next grab the next four digits.
1407 % \begin{macrocode}
1408 \def\xister@symbols#1%
1409 {%
1410 \protected\def\xister@symbols##1##2##3##4%
1411 {%
1412 \xister@gobbletoat##1\xister@done @%
1413 \xister@gobbletozero##1\xister@gobblecopy0%
1414 \rlap{\copy\csname xister@digitbox@##1000\endcsname}%
1415 \xister@gobbletozero##2\xister@gobblecopy0%
1416 \rlap{\copy\csname xister@digitbox@##200\endcsname}%
1417 \xister@gobbletozero##3\xister@gobblecopy0%
1418 \rlap{\copy\csname xister@digitbox@##30\endcsname}%
1419 \xister@gobbletozero##4\xister@gobblecopy0%
1420 \rlap{\copy\csname xister@digitbox@##4\endcsname}%
1421 \copy#1%
1422 \xister@symbols
1423 }%
1424 }
1425 \expandafter\xister@symbols\csname xister@digitbox@0\endcsname
1426 % \end{macrocode}
1427 % \end{macro}
1428 %
1429 %
1430 % \subsection{Drawing the Digits}
1431 %
1432 % \begin{macro}[internal]{\xister@clip@v,\xister@clip@h}
1433 % Some of the digit glyphs need a bit of clipping to look nice. Let's define a
1434 % small auxiliary to select a clipping region.
1435 % \begin{macrocode}
1436 \newcommand*\xister@clip@v[1]
1437 {%
1438 \pgfpathrectanglecorners
1439 {\pgfpoint{\dimexpr\ifdim\xister@X<\z@-\fi\xister@Ts\relax}{#1}}%
1440 {\pgfpoint\xister@X\xister@Y}%
1441 \pgfusepath{clip}%
1442 }
1443 \newcommand*\xister@clip@h[1]
1444 {%
1445 \pgfpathrectanglecorners
1446 {\pgfpoint{#1}{-\dimexpr\ifdim\xister@Y<\z@-\fi\xister@Ts\relax}}%
1447 {\pgfpoint{-\xister@X}\xister@Y}%
1448 \pgfusepath{clip}%
1449 }
1450 % \end{macrocode}
1451 % \end{macro}
1452 %
1453 % \begin{macro}[internal]
1454 % {\xister@drawdigits@vertical,\xister@drawdigits@horizontal}
1455 % The digit glyphs. Since each numeral is build from the zero stem and some
1456 % appendix to it this only specifies the form of the appendices. The zero stem
1457 % is defined a bit down the road. |#1| will determine the decade, and |#2|
1458 % will be either~|-| or empty.
1459 % \begin{macrocode}
1460 \newcommand\xister@drawdigits@vertical[3]
1461 {%
1462 \xister@XY@share=\dimexpr\xister@share@mul\xister@Y\xister@share@div\relax
1463 \xister@drawdigit{1#1}%
1464 {%
1465 \pgfsetlinewidth{2\xister@Th}%
1466 \xister@TMPA=\dimexpr\xister@Y\xister@sgn\xister@Th\relax
1467 \pgfpathmoveto{\pgfpoint\z@\xister@TMPA}%
1468 \pgfpathlineto{\pgfpoint\xister@X\xister@TMPA}%
1469 }%
1470 \xister@drawdigit{2#1}%
1471 {%
1472 \pgfsetlinewidth{2\xister@Th}%
1473 \xister@TMPA=\dimexpr\xister@XY@share+#2\xister@Th\relax
1474 \pgfpathmoveto{\pgfpoint\z@\xister@TMPA}%
1475 \pgfpathlineto{\pgfpoint\xister@X\xister@TMPA}%
1476 }%
1477 \xister@drawdigit{3#1}%
1478 {%
1479 \xister@TMPB=#3\dimexpr\xister@Ts-\xister@Tdd\relax
1480 \xister@clip@v\xister@XY@share
1481 \pgfsetlinewidth{2\xister@Tdd}%
1482 \pgfpathmoveto{\pgfpoint\xister@TMPB\xister@XY@share}%
1483 \pgfpathlineto{\pgfpoint\xister@TMPB\xister@Y}%
1484 \pgfpathlineto{\pgfpoint\xister@X\xister@XY@share}%
1485 }%
1486 \xister@drawdigit{4#1}%
1487 {%
1488 \xister@clip@v\z@
1489 \xister@TMPB=#3\dimexpr\xister@Ts-\xister@Tdu\relax
1490 \pgfsetlinewidth{2\xister@Tdu}%
1491 \pgfpathmoveto{\pgfpoint\xister@TMPB\xister@Y}%
1492 \pgfpathlineto{\pgfpoint\xister@TMPB\xister@XY@share}%
1493 \pgfpathlineto{\pgfpoint\xister@X\xister@Y}%
1494 }%
1495 \xister@drawdigit{5#1}%
1496 {%
1497 \ifxister@five@triangle@
1498 \xister@clip@v\z@
1499 \xister@TMPB=%
1500 #3\dimexpr\xister@Ts-\xister@Tdu\relax
1501 \pgfsetlinewidth{2\xister@Tdu}%
1502 \pgfpathmoveto{\pgfpoint\xister@TMPB\xister@Y}%
1503 \pgfpathlineto{\pgfpoint\xister@TMPB\xister@XY@share}%
1504 \pgfpathlineto{\pgfpoint\xister@X\xister@Y}%
1505 \pgfusepath{stroke,clip}%
1506 \pgfsetlinewidth{2\xister@Th}%
1507 \xister@TMPA=\dimexpr\xister@Y\xister@sgn\xister@Th\relax
1508 \pgfpathmoveto{\pgfpoint\z@\xister@TMPA}%
1509 \pgfpathlineto{\pgfpoint\xister@X\xister@TMPA}%
1510 \else\ifxister@five@dot@
1511 \pgfpathcircle
1512 {\pgfpoint{\dimexpr\xister@X-#3\xister@Five@dot\relax}%
1513 {\dimexpr\xister@Y-#2\xister@Five@dot\relax}}%
1514 {\xister@Five@dot}%
1515 \pgfusepath{fill}%
1516 \else
1517 \xister@TMPB=\dimexpr\xister@X-#3\xister@Tv\relax
1518 \pgfsetlinewidth{2\xister@Tv}%
1519 \pgfpathmoveto{\pgfpoint\xister@TMPB\xister@Y}%
1520 \pgfpathlineto
1521 {%
1522 \pgfpoint
1523 \xister@TMPB
1524 {\dimexpr\xister@Y-#2\xister@five@dash\xister@Tv*2\relax}%
1525 }%
1526 \fi\fi
1527 }%
1528 \xister@drawdigit{6#1}%
1529 {%
1530 \pgfsetlinewidth{2\xister@Tv}%
1531 \xister@TMPB=\dimexpr\xister@X-#3\xister@Tv\relax
1532 \pgfpathmoveto{\pgfpoint\xister@TMPB\xister@Y}%
1533 \pgfpathlineto{\pgfpoint\xister@TMPB\xister@XY@share}%
1534 }%
1535 \xister@superimpose{7#1}%
1536 {%
1537 \rlap{\copy\csname xister@digitbox@1#1\endcsname}%
1538 \copy\csname xister@digitbox@6#1\endcsname
1539 }%
1540 \xister@superimpose{8#1}%
1541 {%
1542 \rlap{\copy\csname xister@digitbox@2#1\endcsname}%
1543 \copy\csname xister@digitbox@6#1\endcsname
1544 }%
1545 \ifxister@nine@triangle@
1546 \xister@drawdigit{9#1}%
1547 {%
1548 \xister@TMPA=.5\dimexpr\xister@XY@share+\xister@Y\relax
1549 \xister@TMPB=#3\dimexpr\xister@Ts-\xister@Tdd\relax
1550 \xister@clip@v\z@
1551 \pgfsetlinewidth{2\xister@Tdd}%
1552 \pgfpathmoveto{\pgfpoint\xister@TMPB\xister@XY@share}%
1553 \pgfpathlineto{\pgfpoint\xister@TMPB\xister@Y}%
1554 \pgfpathlineto{\pgfpoint\xister@X\xister@TMPA}%
1555 \pgfusepath{stroke}%
1556 \xister@TMPB=#3\dimexpr\xister@Ts-\xister@Tdu\relax
1557 \pgfsetlinewidth{2\xister@Tdu}%
1558 \pgfpathmoveto{\pgfpoint\xister@TMPB\xister@Y}%
1559 \pgfpathlineto{\pgfpoint\xister@TMPB\xister@XY@share}%
1560 \pgfpathlineto{\pgfpoint\xister@X\xister@TMPA}%
1561 }%
1562 \else
1563 \xister@superimpose{9#1}%
1564 {%
1565 \rlap{\copy\csname xister@digitbox@1#1\endcsname}%
1566 \rlap{\copy\csname xister@digitbox@2#1\endcsname}%
1567 \copy\csname xister@digitbox@6#1\endcsname
1568 }%
1569 \fi
1570 \unless\ifxister@six@stroke@
1571 \xister@drawdigit{6#1}%
1572 {%
1573 \ifxister@six@dot@
1574 \xister@TMPA=\dimexpr\xister@X-#3\xister@Six@dot\relax
1575 \pgfpathcircle
1576 {\pgfpoint\xister@TMPA
1577 {\dimexpr\xister@Y-#2\xister@Six@dot\relax}}%
1578 {\xister@Six@dot}%
1579 \pgfpathcircle
1580 {\pgfpoint\xister@TMPA
1581 {\dimexpr\xister@XY@share+#2\xister@Six@dot\relax}}%
1582 {\xister@Six@dot}%
1583 \pgfusepath{fill}%
1584 \else
1585 \xister@TMPB=\dimexpr\xister@X-#3\xister@Tv\relax
1586 \xister@TMPA=2\dimexpr#2\xister@six@dash\xister@Tv\relax
1587 \pgfsetlinewidth{2\xister@Tv}%
1588 \pgfpathmoveto{\pgfpoint\xister@TMPB\xister@Y}%
1589 \pgfpathlineto
1590 {\pgfpoint\xister@TMPB
1591 {\dimexpr\xister@Y-\xister@TMPA\relax}}%
1592 \pgfpathmoveto{\pgfpoint\xister@TMPB\xister@XY@share}%
1593 \pgfpathlineto
1594 {\pgfpoint\xister@TMPB
1595 {\dimexpr\xister@XY@share+\xister@TMPA\relax}}%
1596 \fi
1597 }%
1598 \fi
1599 }
1600 \newcommand\xister@drawdigits@horizontal[3]
1601 {%
1602 \xister@XY@share=-\dimexpr\xister@share@mul\xister@X\xister@share@div\relax
1603 \xister@drawdigit{1#1}%
1604 {%
1605 \pgfsetlinewidth{2\xister@Tv}%
1606 \xister@TMPA=\dimexpr#3\xister@Tv-\xister@X\relax
1607 \pgfpathmoveto{\pgfpoint\xister@TMPA\z@}%
1608 \pgfpathlineto{\pgfpoint\xister@TMPA\xister@Y}%
1609 }%
1610 \xister@drawdigit{2#1}%
1611 {%
1612 \pgfsetlinewidth{2\xister@Tv}%
1613 \xister@TMPA=\dimexpr\xister@XY@share-#3\xister@Tv\relax
1614 \pgfpathmoveto{\pgfpoint\xister@TMPA\z@}%
1615 \pgfpathlineto{\pgfpoint\xister@TMPA\xister@Y}%
1616 }%
1617 \xister@drawdigit{3#1}%
1618 {%
1619 \xister@TMPB=#2\dimexpr\xister@Ts-\xister@Tdu\relax
1620 \xister@clip@h\xister@XY@share
1621 \pgfsetlinewidth{2\xister@Tdu}%
1622 \pgfpathmoveto{\pgfpoint\xister@XY@share\xister@TMPB}%
1623 \pgfpathlineto{\pgfpoint{-\xister@X}\xister@TMPB}%
1624 \pgfpathlineto{\pgfpoint\xister@XY@share\xister@Y}%
1625 }%
1626 \xister@drawdigit{4#1}%
1627 {%
1628 \xister@clip@h\z@
1629 \xister@TMPB=#2\dimexpr\xister@Ts-\xister@Tdd\relax
1630 \pgfsetlinewidth{2\xister@Tdd}%
1631 \pgfpathmoveto{\pgfpoint\xister@X\xister@TMPB}%
1632 \pgfpathlineto{\pgfpoint\xister@XY@share\xister@TMPB}%
1633 \pgfpathlineto{\pgfpoint{-\xister@X}\xister@Y}%
1634 }%
1635 \xister@drawdigit{5#1}%
1636 {%
1637 \ifxister@five@triangle@
1638 \xister@clip@h\z@
1639 \xister@TMPB=#2\dimexpr\xister@Ts-\xister@Tdd\relax
1640 \pgfsetlinewidth{2\xister@Tdd}%
1641 \pgfpathmoveto{\pgfpoint{-\xister@X}\xister@TMPB}%
1642 \pgfpathlineto{\pgfpoint\xister@XY@share\xister@TMPB}%
1643 \pgfpathlineto{\pgfpoint{-\xister@X}\xister@Y}%
1644 \pgfusepath{stroke,clip}%
1645 \pgfsetlinewidth{2\xister@Tv}%
1646 \xister@TMPA=\dimexpr#3\xister@Tv-\xister@X\relax
1647 \pgfpathmoveto{\pgfpoint\xister@TMPA\z@}%
1648 \pgfpathlineto{\pgfpoint\xister@TMPA\xister@Y}%
1649 \else\ifxister@five@dot@
1650 \pgfpathcircle
1651 {\pgfpoint{\dimexpr#3\xister@Five@dot-\xister@X\relax}%
1652 {\dimexpr\xister@Y-#2\xister@Five@dot\relax}}%
1653 {\xister@Five@dot}%
1654 \pgfusepath{fill}%
1655 \else
1656 \pgfsetlinewidth{2\xister@Th}%
1657 \xister@TMPB=\dimexpr\xister@Y-#2\xister@Th\relax
1658 \pgfpathmoveto{\pgfpoint{-\xister@X}\xister@TMPB}%
1659 \pgfpathlineto
1660 {%
1661 \pgfpoint
1662 {\dimexpr#3\xister@five@dash\xister@Th*2-\xister@X\relax}%
1663 \xister@TMPB
1664 }%
1665 \fi\fi
1666 }%
1667 \xister@drawdigit{6#1}%
1668 {%
1669 \pgfsetlinewidth{2\xister@Th}%
1670 \xister@TMPB=\dimexpr\xister@Y-#2\xister@Th\relax
1671 \pgfpathmoveto{\pgfpoint{-\xister@X}\xister@TMPB}%
1672 \pgfpathlineto{\pgfpoint\xister@XY@share\xister@TMPB}%
1673 }%
1674 \xister@superimpose{7#1}%
1675 {%
1676 \rlap{\copy\csname xister@digitbox@1#1\endcsname}%
1677 \copy\csname xister@digitbox@6#1\endcsname
1678 }%
1679 \xister@superimpose{8#1}%
1680 {%
1681 \rlap{\copy\csname xister@digitbox@2#1\endcsname}%
1682 \copy\csname xister@digitbox@6#1\endcsname
1683 }%
1684 \ifxister@nine@triangle@
1685 \xister@drawdigit{9#1}%
1686 {%
1687 \xister@TMPA=.5\dimexpr\xister@XY@share-\xister@X\relax
1688 \xister@TMPB=#2\dimexpr\xister@Ts-\xister@Tdu\relax
1689 \xister@clip@h\z@
1690 \pgfsetlinewidth{2\xister@Tdu}%
1691 \pgfpathmoveto{\pgfpoint\xister@XY@share\xister@TMPB}%
1692 \pgfpathlineto{\pgfpoint{-\xister@X}\xister@TMPB}%
1693 \pgfpathlineto{\pgfpoint\xister@TMPA\xister@Y}%
1694 \pgfusepath{stroke}%
1695 \xister@TMPB=#2\dimexpr\xister@Ts-\xister@Tdd\relax
1696 \pgfsetlinewidth{2\xister@Tdd}%
1697 \pgfpathmoveto{\pgfpoint\xister@X\xister@TMPB}%
1698 \pgfpathlineto{\pgfpoint\xister@XY@share\xister@TMPB}%
1699 \pgfpathlineto{\pgfpoint\xister@TMPA\xister@Y}%
1700 }%
1701 \else
1702 \xister@superimpose{9#1}%
1703 {%
1704 \rlap{\copy\csname xister@digitbox@1#1\endcsname}%
1705 \rlap{\copy\csname xister@digitbox@2#1\endcsname}%
1706 \copy\csname xister@digitbox@6#1\endcsname
1707 }%
1708 \fi
1709 \unless\ifxister@six@stroke@
1710 \xister@drawdigit{6#1}%
1711 {%
1712 \ifxister@six@dot@
1713 \xister@TMPA=\dimexpr\xister@Y-#2\xister@Six@dot\relax
1714 \pgfpathcircle
1715 {\pgfpoint{\dimexpr#3\xister@Six@dot-\xister@X\relax}%
1716 \xister@TMPA}%
1717 {\xister@Six@dot}%
1718 \pgfpathcircle
1719 {\pgfpoint{\dimexpr\xister@XY@share-#3\xister@Six@dot\relax}%
1720 \xister@TMPA}%
1721 {\xister@Six@dot}%
1722 \pgfusepath{fill}%
1723 \else
1724 \pgfsetlinewidth{2\xister@Th}%
1725 \xister@TMPB=\dimexpr\xister@Y-#2\xister@Th\relax
1726 \xister@TMPA=2\dimexpr#3\xister@six@dash\xister@Th\relax
1727 \pgfpathmoveto{\pgfpoint{-\xister@X}\xister@TMPB}%
1728 \pgfpathlineto
1729 {\pgfpoint{\dimexpr\xister@TMPA-\xister@X\relax}%
1730 \xister@TMPB}%
1731 \pgfpathmoveto{\pgfpoint\xister@XY@share\xister@TMPB}%
1732 \pgfpathlineto
1733 {\pgfpoint{\dimexpr\xister@XY@share-\xister@TMPA\relax}%
1734 \xister@TMPB}%
1735 \fi
1736 }%
1737 \fi
1738 }
1739 % \end{macrocode}
1740 % Each digit has the same bounding box and baseline which is specified here.
1741 % |#1| will be the name, |#2| the digit specific path.
1742 % \begin{macrocode}
1743 \newcommand\xister@drawdigit[2]
1744 {%
1745 \expandafter\setbox\csname xister@digitbox@#1\endcsname=\hbox
1746 {%
1747 \begin{pgfpicture}%
1748 \pgfpathrectanglecorners
1749 {\pgfpoint{-\xister@bx\xister@X}{-\xister@by\xister@Y}}%
1750 {\pgfpoint{\xister@bx\xister@X}{\xister@by\xister@Y}}%
1751 \pgfusepath{use as bounding box}%
1752 #2%
1753 \pgfusepath{stroke}%
1754 \pgfsetbaseline{\xister@sgn\xister@bs\xister@Y}%
1755 \end{pgfpicture}%
1756 }%
1757 }
1758 % \end{macrocode}
1759 % \end{macro}
1760 %
1761 %
1762 % \begin{macro}[internal]
1763 % {\xister@drawzero@horizontal,\xister@drawzero@vertical}
1764 % \begin{macrocode}
1765 \newcommand*\xister@drawzero@vertical
1766 {%
1767 \xister@drawdigit{0}%
1768 {%
1769 \pgfsetlinewidth{2\xister@Ts}%
1770 \pgfpathmoveto{\pgfpoint\z@{-\xister@Y}}%
1771 \pgfpathlineto{\pgfpoint\z@\xister@Y}%
1772 }%
1773 }
1774 \newcommand*\xister@drawzero@horizontal
1775 {%
1776 \xister@drawdigit{0}%
1777 {%
1778 \pgfsetlinewidth{2\xister@Ts}%
1779 \pgfpathmoveto{\pgfpoint{-\xister@X}\z@}%
1780 \pgfpathlineto{\pgfpoint\xister@X\z@}%
1781 }%
1782 }
1783 % \end{macrocode}
1784 % \end{macro}
1785 %
1786 % \begin{macro}[internal]{\xister@superimpose}
1787 % Some digits can be build from a few of the other ones. This is faster than
1788 % drawing everything again, and this macro eases the process a bit.
1789 % \begin{macrocode}
1790 \newcommand\xister@superimpose[2]
1791 {\expandafter\setbox\csname xister@digitbox@#1\endcsname=\hbox{#2}}
1792 % \end{macrocode}
1793 % \end{macro}
1794 %
1795 %
1796 % \subsection{Rebuild the Glyphs}
1797 %
1798 % \begin{macro}[internal]{\xister@setlengths}
1799 % Lengths are set depending on the current font size and the sizes of
1800 % |\xister@font|. To keep the font changes local they are kept inside a group
1801 % and a full expansion is used to evaluate the user specified sizes while the
1802 % |\xister@font| is still active.
1803 % \begin{macrocode}
1804 \protected\def\xister@setlengths
1805 {%
1806 \begingroup
1807 \xister@font
1808 \edef\xister@tmp
1809 {%
1810 \endgroup
1811 \xister@X=\the\dimexpr.5\dimexpr\xister@x\relax\relax
1812 \xister@Y=\the\dimexpr.5\dimexpr\xister@y\relax\relax
1813 \xister@Th=\the\dimexpr.5\dimexpr\xister@th\relax\relax
1814 \xister@Tv=\the\dimexpr.5\dimexpr\xister@tv\relax\relax
1815 \xister@Tdu=\the\dimexpr.5\dimexpr\xister@tdu\relax\relax
1816 \xister@Tdd=\the\dimexpr.5\dimexpr\xister@tdd\relax\relax
1817 \xister@Five@dot=\the\dimexpr\xister@five@dot\relax
1818 \xister@Six@dot=\the\dimexpr\xister@six@dot\relax
1819 \ifx\xister@ts\@empty
1820 \xister@Ts=%
1821 \ifx\xister@build\xister@build@h\xister@Th\else\xister@Tv\fi
1822 \else
1823 \xister@Ts=\the\dimexpr.5\dimexpr\xister@ts\relax\relax
1824 \fi
1825 }%
1826 \xister@tmp
1827 }
1828 % \end{macrocode}
1829 % \end{macro}
1830 %
1831 % \begin{macro}[internal]{\xister@ensure@current}
1832 % The glyphs have to be rebuilt if the relevant font features changed (as
1833 % specified in \cs[no-index]{xister@fontfeatures}).
1834 % If all these font features match with whatever was active when we last built
1835 % the glyphs we do nothing, else we rebuild them.
1836 %
1837 % The |\edef| is just used to remove the |debug| code if it isn't necessary.
1838 % \begin{macrocode}
1839 \protected\edef\xister@ensure@current
1840 {%
1841 \unexpanded{\edef\xister@tmp{\xister@fontfeatures}}%
1842 \unexpanded{\unless\ifx\xister@tmp\xister@last@font}%
1843 \ifxister@dbg@
1844 \unexpanded
1845 {\xister@dbg@do{Font changed. Building glyphs for \xister@tmp}}%
1846 \fi
1847 \unexpanded
1848 {%
1849 \let\xister@last@font\xister@tmp
1850 \xister@build
1851 }%
1852 \ifxister@dbg@
1853 \unexpanded{\xister@dbg@done}%
1854 \fi
1855 \unexpanded{\fi}%
1856 }
1857 \AtBeginDocument{\xister@ensure@current}
1858 % \end{macrocode}
1859 % \end{macro}
1860 %
1861 % \clearpage
1862 % \PrintIndex