| 1 |
% \iffalse meta-comment |
| 2 |
% |
| 3 |
% File: engord.dtx |
| 4 |
% Version: 2016/05/16 v1.9 |
| 5 |
% Info: Provides English ordinal numbers |
| 6 |
% |
| 7 |
% Copyright (C) |
| 8 |
% 2000, 2003, 2006-2008, 2010 Heiko Oberdiek |
| 9 |
% 2016-2019 Oberdiek Package Support Group |
| 10 |
% https://github.com/ho-tex/oberdiek/issues |
| 11 |
% |
| 12 |
% This work may be distributed and/or modified under the |
| 13 |
% conditions of the LaTeX Project Public License, either |
| 14 |
% version 1.3c of this license or (at your option) any later |
| 15 |
% version. This version of this license is in |
| 16 |
% https://www.latex-project.org/lppl/lppl-1-3c.txt |
| 17 |
% and the latest version of this license is in |
| 18 |
% https://www.latex-project.org/lppl.txt |
| 19 |
% and version 1.3 or later is part of all distributions of |
| 20 |
% LaTeX version 2005/12/01 or later. |
| 21 |
% |
| 22 |
% This work has the LPPL maintenance status "maintained". |
| 23 |
% |
| 24 |
% The Current Maintainers of this work are |
| 25 |
% Heiko Oberdiek and the Oberdiek Package Support Group |
| 26 |
% https://github.com/ho-tex/oberdiek/issues |
| 27 |
% |
| 28 |
% The Base Interpreter refers to any `TeX-Format', |
| 29 |
% because some files are installed in TDS:tex/generic//. |
| 30 |
% |
| 31 |
% This work consists of the main source file engord.dtx |
| 32 |
% and the derived files |
| 33 |
% engord.sty, engord.pdf, engord.ins, engord.drv, engord-test1.tex. |
| 34 |
% |
| 35 |
% Distribution: |
| 36 |
% CTAN:macros/latex/contrib/oberdiek/engord.dtx |
| 37 |
% CTAN:macros/latex/contrib/oberdiek/engord.pdf |
| 38 |
% |
| 39 |
% Unpacking: |
| 40 |
% (a) If engord.ins is present: |
| 41 |
% tex engord.ins |
| 42 |
% (b) Without engord.ins: |
| 43 |
% tex engord.dtx |
| 44 |
% (c) If you insist on using LaTeX |
| 45 |
% latex \let\install=y\input{engord.dtx} |
| 46 |
% (quote the arguments according to the demands of your shell) |
| 47 |
% |
| 48 |
% Documentation: |
| 49 |
% (a) If engord.drv is present: |
| 50 |
% latex engord.drv |
| 51 |
% (b) Without engord.drv: |
| 52 |
% latex engord.dtx; ... |
| 53 |
% The class ltxdoc loads the configuration file ltxdoc.cfg |
| 54 |
% if available. Here you can specify further options, e.g. |
| 55 |
% use A4 as paper format: |
| 56 |
% \PassOptionsToClass{a4paper}{article} |
| 57 |
% |
| 58 |
% Program calls to get the documentation (example): |
| 59 |
% pdflatex engord.dtx |
| 60 |
% makeindex -s gind.ist engord.idx |
| 61 |
% pdflatex engord.dtx |
| 62 |
% makeindex -s gind.ist engord.idx |
| 63 |
% pdflatex engord.dtx |
| 64 |
% |
| 65 |
% Installation: |
| 66 |
% TDS:tex/generic/oberdiek/engord.sty |
| 67 |
% TDS:doc/latex/oberdiek/engord.pdf |
| 68 |
% TDS:source/latex/oberdiek/engord.dtx |
| 69 |
% |
| 70 |
%<*ignore> |
| 71 |
\begingroup |
| 72 |
\catcode123=1 % |
| 73 |
\catcode125=2 % |
| 74 |
\def\x{LaTeX2e}% |
| 75 |
\expandafter\endgroup |
| 76 |
\ifcase 0\ifx\install y1\fi\expandafter |
| 77 |
\ifx\csname processbatchFile\endcsname\relax\else1\fi |
| 78 |
\ifx\fmtname\x\else 1\fi\relax |
| 79 |
\else\csname fi\endcsname |
| 80 |
%</ignore> |
| 81 |
%<*install> |
| 82 |
\input docstrip.tex |
| 83 |
\Msg{************************************************************************} |
| 84 |
\Msg{* Installation} |
| 85 |
\Msg{* Package: engord 2016/05/16 v1.9 Provides English ordinal numbers (HO)} |
| 86 |
\Msg{************************************************************************} |
| 87 |
|
| 88 |
\keepsilent |
| 89 |
\askforoverwritefalse |
| 90 |
|
| 91 |
\let\MetaPrefix\relax |
| 92 |
\preamble |
| 93 |
|
| 94 |
This is a generated file. |
| 95 |
|
| 96 |
Project: engord |
| 97 |
Version: 2016/05/16 v1.9 |
| 98 |
|
| 99 |
Copyright (C) |
| 100 |
2000, 2003, 2006-2008, 2010 Heiko Oberdiek |
| 101 |
2016-2019 Oberdiek Package Support Group |
| 102 |
|
| 103 |
This work may be distributed and/or modified under the |
| 104 |
conditions of the LaTeX Project Public License, either |
| 105 |
version 1.3c of this license or (at your option) any later |
| 106 |
version. This version of this license is in |
| 107 |
https://www.latex-project.org/lppl/lppl-1-3c.txt |
| 108 |
and the latest version of this license is in |
| 109 |
https://www.latex-project.org/lppl.txt |
| 110 |
and version 1.3 or later is part of all distributions of |
| 111 |
LaTeX version 2005/12/01 or later. |
| 112 |
|
| 113 |
This work has the LPPL maintenance status "maintained". |
| 114 |
|
| 115 |
The Current Maintainers of this work are |
| 116 |
Heiko Oberdiek and the Oberdiek Package Support Group |
| 117 |
https://github.com/ho-tex/oberdiek/issues |
| 118 |
|
| 119 |
|
| 120 |
The Base Interpreter refers to any `TeX-Format', |
| 121 |
because some files are installed in TDS:tex/generic//. |
| 122 |
|
| 123 |
This work consists of the main source file engord.dtx |
| 124 |
and the derived files |
| 125 |
engord.sty, engord.pdf, engord.ins, engord.drv, engord-test1.tex. |
| 126 |
|
| 127 |
\endpreamble |
| 128 |
\let\MetaPrefix\DoubleperCent |
| 129 |
|
| 130 |
\generate{% |
| 131 |
\file{engord.ins}{\from{engord.dtx}{install}}% |
| 132 |
\file{engord.drv}{\from{engord.dtx}{driver}}% |
| 133 |
\usedir{tex/generic/oberdiek}% |
| 134 |
\file{engord.sty}{\from{engord.dtx}{package}}% |
| 135 |
% \usedir{doc/latex/oberdiek/test}% |
| 136 |
% \file{engord-test1.tex}{\from{engord.dtx}{test1}}% |
| 137 |
} |
| 138 |
|
| 139 |
\catcode32=13\relax% active space |
| 140 |
\let =\space% |
| 141 |
\Msg{************************************************************************} |
| 142 |
\Msg{*} |
| 143 |
\Msg{* To finish the installation you have to move the following} |
| 144 |
\Msg{* file into a directory searched by TeX:} |
| 145 |
\Msg{*} |
| 146 |
\Msg{* engord.sty} |
| 147 |
\Msg{*} |
| 148 |
\Msg{* To produce the documentation run the file `engord.drv'} |
| 149 |
\Msg{* through LaTeX.} |
| 150 |
\Msg{*} |
| 151 |
\Msg{* Happy TeXing!} |
| 152 |
\Msg{*} |
| 153 |
\Msg{************************************************************************} |
| 154 |
|
| 155 |
\endbatchfile |
| 156 |
%</install> |
| 157 |
%<*ignore> |
| 158 |
\fi |
| 159 |
%</ignore> |
| 160 |
%<*driver> |
| 161 |
\NeedsTeXFormat{LaTeX2e} |
| 162 |
\ProvidesFile{engord.drv}% |
| 163 |
[2016/05/16 v1.9 Provides English ordinal numbers (HO)]% |
| 164 |
\documentclass{ltxdoc} |
| 165 |
\usepackage{holtxdoc}[2011/11/22] |
| 166 |
\begin{document} |
| 167 |
\DocInput{engord.dtx}% |
| 168 |
\end{document} |
| 169 |
%</driver> |
| 170 |
% \fi |
| 171 |
% |
| 172 |
% |
| 173 |
% |
| 174 |
% \GetFileInfo{engord.drv} |
| 175 |
% |
| 176 |
% \title{The \xpackage{engord} package} |
| 177 |
% \date{2016/05/16 v1.9} |
| 178 |
% \author{Heiko Oberdiek\thanks |
| 179 |
% {Please report any issues at \url{https://github.com/ho-tex/oberdiek/issues}}} |
| 180 |
% |
| 181 |
% \maketitle |
| 182 |
% |
| 183 |
% \begin{abstract} |
| 184 |
% The package generates the suffix of English ordinal numbers. |
| 185 |
% It can be used with plain and \LaTeX\ formats. |
| 186 |
% \end{abstract} |
| 187 |
% |
| 188 |
% \tableofcontents |
| 189 |
% |
| 190 |
% \section{Usage} |
| 191 |
% |
| 192 |
% \begin{declcs}{engord}\,\M{\LaTeX\ counter name} |
| 193 |
% \end{declcs} |
| 194 |
% It prints the value of the \LaTeX\ counter as English |
| 195 |
% ordinal number. It can be used in the same way as |
| 196 |
% \cs{arabic}, \cs{roman}, or \cs{alph}. The command is |
| 197 |
% not available in \plainTeX. |
| 198 |
% |
| 199 |
% \begin{declcs}{engordnumber}\,\M{any \TeX\ number} |
| 200 |
% \end{declcs} |
| 201 |
% It prints the number as English ordinal number. |
| 202 |
% |
| 203 |
% \begin{declcs}{engordletters}\,|{#1}| |
| 204 |
% \end{declcs} |
| 205 |
% This command formats the English ordinal letters |
| 206 |
% after the number. It defaults to \cs{textsuperscript}. |
| 207 |
% |
| 208 |
% \begin{declcs}{engorderror}\,|{#1}| |
| 209 |
% \end{declcs} |
| 210 |
% It can be redefined, if an other error handling is |
| 211 |
% wanted. The argument is a negative number or zero. |
| 212 |
% |
| 213 |
% \begin{declcs}{engordraisetrue}\\ |
| 214 |
% \SpecialUsageIndex{\engordraisefalse}\cs{engordraisefalse} |
| 215 |
% \end{declcs} |
| 216 |
% These commands set the switch \cs{ifengordraise} that is |
| 217 |
% asked by the default \cs{engordletters} before raising the |
| 218 |
% ordinal letters. |
| 219 |
% |
| 220 |
% \subsection{Package options} |
| 221 |
% |
| 222 |
% \begin{description} |
| 223 |
% \item[\xoption{normal}:] \cs{engordraisefalse} |
| 224 |
% \item[\xoption{raise}:] \cs{engordraisetrue} |
| 225 |
% \end{description} |
| 226 |
% Default is \xoption{raise}. |
| 227 |
% |
| 228 |
% \subsection{Examples} |
| 229 |
% |
| 230 |
% \begin{itemize} |
| 231 |
% \item |
| 232 |
% |\usepackage[normal]{engord}|\\ |
| 233 |
% \begin{tabular}{@{}l@{ $\rightarrow$ }l@{}} |
| 234 |
% |\engordnumber{1}| & 1st\\ |
| 235 |
% |\engordnumber{12}| & 12th\\ |
| 236 |
% |\engordnumber{123}| & 123rd\\ |
| 237 |
% |\engord{page}| & 1st (if page has the value of one)\\ |
| 238 |
% \multicolumn{2}{@{}l}{\cs{engordraisetrue}}\\ |
| 239 |
% |\engordnumber{12}| & 12\textsuperscript{th} |
| 240 |
% \end{tabular} |
| 241 |
% \item |
| 242 |
% The default output of a counter can be redefined: |
| 243 |
% \begin{quote} |
| 244 |
% |\newcounter{mycounter}|\\ |
| 245 |
% |\renewcommand{\theengcounter}{\engord{mycounter}}| |
| 246 |
% \end{quote} |
| 247 |
% \item |
| 248 |
% Because the implementation of \cs{engord} and \cs{engordnumber} |
| 249 |
% is kept expandable, these commands can be used to make |
| 250 |
% command names with an appropriate definition of |
| 251 |
% \cs{engordletters}: |
| 252 |
% \begin{quote} |
| 253 |
% |\renewcommand*{\engordletters}[1]{#1}|\\ |
| 254 |
% |\@namedef{My\engordnumber{3}Command}{...}| |
| 255 |
% \end{quote} |
| 256 |
% This generates the command name `\cs{My4rdCommand}'. |
| 257 |
% Since version 1.2 the redefinition can be dropped if |
| 258 |
% the letters are not raised. |
| 259 |
% \item |
| 260 |
% If the letters should not be raised, use \LaTeX\ package |
| 261 |
% option \xoption{normal} or use |
| 262 |
% \begin{quote} |
| 263 |
% \cs{engordraisefalse} |
| 264 |
% \end{quote} |
| 265 |
% Also \cs{engordletters} could be redefined for this purpose: |
| 266 |
% \begin{quote} |
| 267 |
% |\renewcommand*{\engordletters}[1]{#1}| |
| 268 |
% \end{quote} |
| 269 |
% \end{itemize} |
| 270 |
% |
| 271 |
% \StopEventually{ |
| 272 |
% } |
| 273 |
% |
| 274 |
% \section{Implementation} |
| 275 |
% |
| 276 |
% \subsection{Reload check and identification} |
| 277 |
% |
| 278 |
% \begin{macrocode} |
| 279 |
%<*package> |
| 280 |
% \end{macrocode} |
| 281 |
% Reload check, especially if the package is not used with \LaTeX. |
| 282 |
% \begin{macrocode} |
| 283 |
\begingroup\catcode61\catcode48\catcode32=10\relax% |
| 284 |
\catcode13=5 % ^^M |
| 285 |
\endlinechar=13 % |
| 286 |
\catcode35=6 % # |
| 287 |
\catcode39=12 % ' |
| 288 |
\catcode44=12 % , |
| 289 |
\catcode45=12 % - |
| 290 |
\catcode46=12 % . |
| 291 |
\catcode58=12 % : |
| 292 |
\catcode64=11 % @ |
| 293 |
\catcode123=1 % { |
| 294 |
\catcode125=2 % } |
| 295 |
\expandafter\let\expandafter\x\csname [email protected]\endcsname |
| 296 |
\ifx\x\relax % plain-TeX, first loading |
| 297 |
\else |
| 298 |
\def\empty{}% |
| 299 |
\ifx\x\empty % LaTeX, first loading, |
| 300 |
% variable is initialized, but \ProvidesPackage not yet seen |
| 301 |
\else |
| 302 |
\expandafter\ifx\csname PackageInfo\endcsname\relax |
| 303 |
\def\x#1#2{% |
| 304 |
\immediate\write-1{Package #1 Info: #2.}% |
| 305 |
}% |
| 306 |
\else |
| 307 |
\def\x#1#2{\PackageInfo{#1}{#2, stopped}}% |
| 308 |
\fi |
| 309 |
\x{engord}{The package is already loaded}% |
| 310 |
\aftergroup\endinput |
| 311 |
\fi |
| 312 |
\fi |
| 313 |
\endgroup% |
| 314 |
% \end{macrocode} |
| 315 |
% Package identification: |
| 316 |
% \begin{macrocode} |
| 317 |
\begingroup\catcode61\catcode48\catcode32=10\relax% |
| 318 |
\catcode13=5 % ^^M |
| 319 |
\endlinechar=13 % |
| 320 |
\catcode35=6 % # |
| 321 |
\catcode39=12 % ' |
| 322 |
\catcode40=12 % ( |
| 323 |
\catcode41=12 % ) |
| 324 |
\catcode44=12 % , |
| 325 |
\catcode45=12 % - |
| 326 |
\catcode46=12 % . |
| 327 |
\catcode47=12 % / |
| 328 |
\catcode58=12 % : |
| 329 |
\catcode64=11 % @ |
| 330 |
\catcode91=12 % [ |
| 331 |
\catcode93=12 % ] |
| 332 |
\catcode123=1 % { |
| 333 |
\catcode125=2 % } |
| 334 |
\expandafter\ifx\csname ProvidesPackage\endcsname\relax |
| 335 |
\def\x#1#2#3[#4]{\endgroup |
| 336 |
\immediate\write-1{Package: #3 #4}% |
| 337 |
\xdef#1{#4}% |
| 338 |
}% |
| 339 |
\else |
| 340 |
\def\x#1#2[#3]{\endgroup |
| 341 |
#2[{#3}]% |
| 342 |
\ifx#1\@undefined |
| 343 |
\xdef#1{#3}% |
| 344 |
\fi |
| 345 |
\ifx#1\relax |
| 346 |
\xdef#1{#3}% |
| 347 |
\fi |
| 348 |
}% |
| 349 |
\fi |
| 350 |
\expandafter\x\csname [email protected]\endcsname |
| 351 |
\ProvidesPackage{engord}% |
| 352 |
[2016/05/16 v1.9 Provides English ordinal numbers (HO)]% |
| 353 |
% \end{macrocode} |
| 354 |
% |
| 355 |
% \subsection{Help commands for plain compatibility} |
| 356 |
% |
| 357 |
% \begin{macrocode} |
| 358 |
\begingroup\catcode61\catcode48\catcode32=10\relax% |
| 359 |
\catcode13=5 % ^^M |
| 360 |
\endlinechar=13 % |
| 361 |
\catcode123=1 % { |
| 362 |
\catcode125=2 % } |
| 363 |
\catcode64=11 % @ |
| 364 |
\def\x{\endgroup |
| 365 |
\expandafter\edef\csname EO@AtEnd\endcsname{% |
| 366 |
\endlinechar=\the\endlinechar\relax |
| 367 |
\catcode13=\the\catcode13\relax |
| 368 |
\catcode32=\the\catcode32\relax |
| 369 |
\catcode35=\the\catcode35\relax |
| 370 |
\catcode61=\the\catcode61\relax |
| 371 |
\catcode64=\the\catcode64\relax |
| 372 |
\catcode123=\the\catcode123\relax |
| 373 |
\catcode125=\the\catcode125\relax |
| 374 |
}% |
| 375 |
}% |
| 376 |
\x\catcode61\catcode48\catcode32=10\relax% |
| 377 |
\catcode13=5 % ^^M |
| 378 |
\endlinechar=13 % |
| 379 |
\catcode35=6 % # |
| 380 |
\catcode64=11 % @ |
| 381 |
\catcode123=1 % { |
| 382 |
\catcode125=2 % } |
| 383 |
\def\TMP@EnsureCode#1#2{% |
| 384 |
\edef\EO@AtEnd{% |
| 385 |
\EO@AtEnd |
| 386 |
\catcode#1=\the\catcode#1\relax |
| 387 |
}% |
| 388 |
\catcode#1=#2\relax |
| 389 |
} |
| 390 |
\TMP@EnsureCode{33}{12}% ! |
| 391 |
\TMP@EnsureCode{36}{3}% $ |
| 392 |
\TMP@EnsureCode{39}{12}% ' |
| 393 |
\TMP@EnsureCode{42}{12}% * |
| 394 |
\TMP@EnsureCode{46}{12}% . |
| 395 |
\TMP@EnsureCode{47}{12}% / |
| 396 |
\TMP@EnsureCode{60}{12}% < |
| 397 |
\TMP@EnsureCode{91}{12}% [ |
| 398 |
\TMP@EnsureCode{93}{12}% ] |
| 399 |
\TMP@EnsureCode{94}{7}% ^(superscript) |
| 400 |
\TMP@EnsureCode{96}{12}% ` |
| 401 |
\edef\EO@AtEnd{\EO@AtEnd\noexpand\endinput} |
| 402 |
% \end{macrocode} |
| 403 |
% |
| 404 |
% \begin{macro}{\EO@def} |
| 405 |
% Definitions, \cs{newcommand} does not exist in \plainTeX. |
| 406 |
% \begin{macrocode} |
| 407 |
\begingroup\expandafter\expandafter\expandafter\endgroup |
| 408 |
\expandafter\ifx\csname newcommand\endcsname\relax |
| 409 |
\def\EO@def{\def}% |
| 410 |
\else |
| 411 |
\def\EO@def#1{% |
| 412 |
\newcommand*{#1}{}% |
| 413 |
\def#1% |
| 414 |
}% |
| 415 |
\fi |
| 416 |
% \end{macrocode} |
| 417 |
% \end{macro} |
| 418 |
% \begin{macrocode} |
| 419 |
\begingroup\expandafter\expandafter\expandafter\endgroup |
| 420 |
\expandafter\ifx\csname RequirePackage\endcsname\relax |
| 421 |
\input infwarerr.sty\relax |
| 422 |
\input ltxcmds.sty\relax |
| 423 |
\else |
| 424 |
\RequirePackage{infwarerr}[2007/09/09]% |
| 425 |
\RequirePackage{ltxcmds}[2016/05/16]% |
| 426 |
\fi |
| 427 |
% \end{macrocode} |
| 428 |
% |
| 429 |
% \subsection{User macros} |
| 430 |
% |
| 431 |
% \begin{macro}{\ifengordraise} |
| 432 |
% The switch \cs{ifengordraise}, whether the ordinal letters |
| 433 |
% are raised or not. Default is raised because of compatibility. |
| 434 |
% \begin{macrocode} |
| 435 |
\ltx@newif\ifengordraise |
| 436 |
\engordraisetrue |
| 437 |
% \end{macrocode} |
| 438 |
% \end{macro} |
| 439 |
% In \LaTeX\ this also can be controlled by option \xoption{normal} |
| 440 |
% or \xoption{raise}. |
| 441 |
% \begin{macrocode} |
| 442 |
\begingroup\expandafter\expandafter\expandafter\endgroup |
| 443 |
\expandafter\ifx\csname DeclareOption\endcsname\relax |
| 444 |
\else |
| 445 |
\DeclareOption{normal}{\engordraisefalse}% |
| 446 |
\DeclareOption{raise}{\engordraisetrue}% |
| 447 |
\ProcessOptions*\relax |
| 448 |
\fi |
| 449 |
% \end{macrocode} |
| 450 |
% |
| 451 |
% \begin{macro}{\engordletters} |
| 452 |
% \cs{engordletters} is called with one argument, the english |
| 453 |
% ordinal letters, and contains the code to format them. It |
| 454 |
% defaults to \cs{textsuperscript} depending on \cs{ifengordraise}. |
| 455 |
% \begin{macrocode} |
| 456 |
\expandafter\ifx\csname engordletters\endcsname\relax |
| 457 |
\EO@def\engordletters{% |
| 458 |
\ifengordraise |
| 459 |
\expandafter\engordtextsuperscript |
| 460 |
\fi |
| 461 |
}% |
| 462 |
\fi |
| 463 |
% \end{macrocode} |
| 464 |
% \end{macro} |
| 465 |
% \begin{macro}{\engordtextsuperscript} |
| 466 |
% For \plainTeX\ the definition is quite ugly, redefine |
| 467 |
% \cs{engordtextsuperscript} if you have a better one. |
| 468 |
% \begin{macrocode} |
| 469 |
\expandafter\ifx\csname engordtextsuperscript\endcsname\relax |
| 470 |
\begingroup\expandafter\expandafter\expandafter\endgroup |
| 471 |
\expandafter\ifx\csname textsuperscript\endcsname\relax |
| 472 |
\def\engordtextsuperscript#1{% |
| 473 |
\relax |
| 474 |
\ifmmode |
| 475 |
^{\rm#1}% |
| 476 |
\else |
| 477 |
$^{\rm#1}$% |
| 478 |
\fi |
| 479 |
}% |
| 480 |
\else |
| 481 |
\def\engordtextsuperscript{\textsuperscript}% |
| 482 |
\fi |
| 483 |
\fi |
| 484 |
% \end{macrocode} |
| 485 |
% \end{macro} |
| 486 |
% \begin{macro}{\engorderror} |
| 487 |
% \cs{engorderror} is called, if the number is zero |
| 488 |
% or negative. |
| 489 |
% \begin{macrocode} |
| 490 |
\expandafter\ifx\csname engorderror\endcsname\relax |
| 491 |
\EO@def\engorderror#1{% |
| 492 |
#1\engordletters{!ERROR!}% |
| 493 |
\@PackageWarning{engord}{% |
| 494 |
`#1' is not an ordinal number% |
| 495 |
}% |
| 496 |
}% |
| 497 |
\fi |
| 498 |
% \end{macrocode} |
| 499 |
% \end{macro} |
| 500 |
% \begin{macro}{\engord} |
| 501 |
% \cs{engord} expects a \LaTeX\ counter name as argument and |
| 502 |
% calls \cs{engordnumber}. It is defined only, if \LaTeX\ is used. |
| 503 |
% \begin{macrocode} |
| 504 |
\begingroup\expandafter\expandafter\expandafter\endgroup |
| 505 |
\expandafter\ifx\csname newcounter\endcsname\relax |
| 506 |
\else |
| 507 |
\EO@def\engord#1{% |
| 508 |
\engordnumber{\value{#1}}% |
| 509 |
}% |
| 510 |
\fi |
| 511 |
% \end{macrocode} |
| 512 |
% \end{macro} |
| 513 |
% \begin{macro}{\engordnumber} |
| 514 |
% \cs{engordnumber} is the user command to print a number as |
| 515 |
% english ordinal number. The argument can be any |
| 516 |
% \TeX\ number like explicit numbers, register values, \dots |
| 517 |
% |
| 518 |
% In a safe way it converts the \TeX\ number argument |
| 519 |
% into a form that only consists of decimal digits. |
| 520 |
% \begin{macrocode} |
| 521 |
\EO@def\engordnumber#1{% |
| 522 |
\expandafter\EO@number\expandafter{\number#1}% |
| 523 |
} |
| 524 |
% \end{macrocode} |
| 525 |
% \end{macro} |
| 526 |
% |
| 527 |
% \subsection{Suffix generation} |
| 528 |
% |
| 529 |
% \begin{macro}{\EO@number} |
| 530 |
% \cs{EO@number} expects a number with decimal digits as |
| 531 |
% argument and looks at the size of the number and |
| 532 |
% the count of the digits: |
| 533 |
% \begin{macrocode} |
| 534 |
\def\EO@number#1{% |
| 535 |
\ifnum#1<1 % handle the error case |
| 536 |
\engorderror{#1}% |
| 537 |
\else |
| 538 |
\ifnum#1<21 % |
| 539 |
\EO@ord{#1}% |
| 540 |
\else |
| 541 |
\ifnum#1<100 % |
| 542 |
\EO@twodigits#1% |
| 543 |
\else |
| 544 |
\@ReturnAfterFi{% |
| 545 |
\EO@reverse#1\@nil{}\EO@afterreverse |
| 546 |
}% |
| 547 |
\fi |
| 548 |
\fi |
| 549 |
\fi |
| 550 |
} |
| 551 |
% \end{macrocode} |
| 552 |
% \end{macro} |
| 553 |
% \begin{macro}{\@ReturnAfterFi} |
| 554 |
% An internal help macro to prevent a too deep \cs{if} nesting. |
| 555 |
% \begin{macrocode} |
| 556 |
\long\def\@ReturnAfterFi#1\fi{\fi#1} |
| 557 |
% \end{macrocode} |
| 558 |
% \end{macro} |
| 559 |
% \begin{macro}{\EO@ord} |
| 560 |
% \cs{EO@ord} prints the number with ord letters.\\ |
| 561 |
% |#1|: decimal digits, |#1| $<$ 21 |
| 562 |
% \begin{macrocode} |
| 563 |
\def\EO@ord#1{% |
| 564 |
#1% |
| 565 |
\expandafter\engordletters |
| 566 |
\ifcase#1{th}\or |
| 567 |
{st}\or |
| 568 |
{nd}\or |
| 569 |
{rd}\else |
| 570 |
{th}% |
| 571 |
\fi |
| 572 |
} |
| 573 |
% \end{macrocode} |
| 574 |
% \end{macro} |
| 575 |
% \begin{macro}{\EO@twodigits} |
| 576 |
% \cs{EO@twodigits} expects a number with two digits,\\ |
| 577 |
% 20 $<$ number $<$ 100 |
| 578 |
% \begin{macrocode} |
| 579 |
\def\EO@twodigits#1#2{% |
| 580 |
#1\EO@ord{#2}% |
| 581 |
} |
| 582 |
% \end{macrocode} |
| 583 |
% \end{macro} |
| 584 |
% \begin{macro}{\EO@reverse} |
| 585 |
% \cs{EO@reverse} reverses the digits of the number.\\ |
| 586 |
% |#1|: next digit\\ |
| 587 |
% |#2|: rest of the digits\\ |
| 588 |
% |#3|: already reversed digits\\ |
| 589 |
% |#4|: next command to call with the reversed number |
| 590 |
% as argument |
| 591 |
% \begin{macrocode} |
| 592 |
\def\EO@reverse#1#2\@nil#3#4{% |
| 593 |
\ifx\\#2\\% |
| 594 |
#4{#1#3}% |
| 595 |
\else |
| 596 |
\@ReturnAfterFi{% |
| 597 |
\EO@reverse#2\@nil{#1#3}{#4}% |
| 598 |
}% |
| 599 |
\fi |
| 600 |
} |
| 601 |
% \end{macrocode} |
| 602 |
% \end{macro} |
| 603 |
% \begin{macro}{\EO@afterreverse} |
| 604 |
% \cs{EO@afterreverse} calls \cs{EO@reverseback} so that |
| 605 |
% \cs{EO@reverseback} can inspect the digits of the number. |
| 606 |
% \begin{macrocode} |
| 607 |
\def\EO@afterreverse#1{% |
| 608 |
\EO@reverseback#1\@nil |
| 609 |
} |
| 610 |
% \end{macrocode} |
| 611 |
% \end{macro} |
| 612 |
% \begin{macro}{\EO@reverseback} |
| 613 |
% \cs{EO@reverseback} reverses the reversion.\\ |
| 614 |
% |#1|: the last digit of the number\\ |
| 615 |
% |#2|: the second last digit of the number\\ |
| 616 |
% |#3|: first digits of the number in reversed order, |
| 617 |
% it is not empty, because \cs{EO@reverseback} is |
| 618 |
% only called with numbers $>$ 100. |
| 619 |
% \begin{macrocode} |
| 620 |
\def\EO@reverseback#1#2#3\@nil{% |
| 621 |
\EO@reverse#3\@nil{}\@firstofone |
| 622 |
\ifnum#2#1<21 % |
| 623 |
\EO@ord{#2#1}% |
| 624 |
\else |
| 625 |
#2\EO@ord{#1}% |
| 626 |
\fi |
| 627 |
} |
| 628 |
% \end{macrocode} |
| 629 |
% \end{macro} |
| 630 |
% |
| 631 |
% \begin{macrocode} |
| 632 |
\EO@AtEnd% |
| 633 |
% \end{macrocode} |
| 634 |
% |
| 635 |
% \begin{macrocode} |
| 636 |
%</package> |
| 637 |
% \end{macrocode} |
| 638 |
%% \section{Installation} |
| 639 |
% |
| 640 |
% \subsection{Download} |
| 641 |
% |
| 642 |
% \paragraph{Package.} This package is available on |
| 643 |
% CTAN\footnote{\CTANpkg{engord}}: |
| 644 |
% \begin{description} |
| 645 |
% \item[\CTAN{macros/latex/contrib/oberdiek/engord.dtx}] The source file. |
| 646 |
% \item[\CTAN{macros/latex/contrib/oberdiek/engord.pdf}] Documentation. |
| 647 |
% \end{description} |
| 648 |
% |
| 649 |
% |
| 650 |
% \paragraph{Bundle.} All the packages of the bundle `oberdiek' |
| 651 |
% are also available in a TDS compliant ZIP archive. There |
| 652 |
% the packages are already unpacked and the documentation files |
| 653 |
% are generated. The files and directories obey the TDS standard. |
| 654 |
% \begin{description} |
| 655 |
% \item[\CTANinstall{install/macros/latex/contrib/oberdiek.tds.zip}] |
| 656 |
% \end{description} |
| 657 |
% \emph{TDS} refers to the standard ``A Directory Structure |
| 658 |
% for \TeX\ Files'' (\CTANpkg{tds}). Directories |
| 659 |
% with \xfile{texmf} in their name are usually organized this way. |
| 660 |
% |
| 661 |
% \subsection{Bundle installation} |
| 662 |
% |
| 663 |
% \paragraph{Unpacking.} Unpack the \xfile{oberdiek.tds.zip} in the |
| 664 |
% TDS tree (also known as \xfile{texmf} tree) of your choice. |
| 665 |
% Example (linux): |
| 666 |
% \begin{quote} |
| 667 |
% |unzip oberdiek.tds.zip -d ~/texmf| |
| 668 |
% \end{quote} |
| 669 |
% |
| 670 |
% \subsection{Package installation} |
| 671 |
% |
| 672 |
% \paragraph{Unpacking.} The \xfile{.dtx} file is a self-extracting |
| 673 |
% \docstrip\ archive. The files are extracted by running the |
| 674 |
% \xfile{.dtx} through \plainTeX: |
| 675 |
% \begin{quote} |
| 676 |
% \verb|tex engord.dtx| |
| 677 |
% \end{quote} |
| 678 |
% |
| 679 |
% \paragraph{TDS.} Now the different files must be moved into |
| 680 |
% the different directories in your installation TDS tree |
| 681 |
% (also known as \xfile{texmf} tree): |
| 682 |
% \begin{quote} |
| 683 |
% \def\t{^^A |
| 684 |
% \begin{tabular}{@{}>{\ttfamily}l@{ $\rightarrow$ }>{\ttfamily}l@{}} |
| 685 |
% engord.sty & tex/generic/oberdiek/engord.sty\\ |
| 686 |
% engord.pdf & doc/latex/oberdiek/engord.pdf\\ |
| 687 |
% engord.dtx & source/latex/oberdiek/engord.dtx\\ |
| 688 |
% \end{tabular}^^A |
| 689 |
% }^^A |
| 690 |
% \sbox0{\t}^^A |
| 691 |
% \ifdim\wd0>\linewidth |
| 692 |
% \begingroup |
| 693 |
% \advance\linewidth by\leftmargin |
| 694 |
% \advance\linewidth by\rightmargin |
| 695 |
% \edef\x{\endgroup |
| 696 |
% \def\noexpand\lw{\the\linewidth}^^A |
| 697 |
% }\x |
| 698 |
% \def\lwbox{^^A |
| 699 |
% \leavevmode |
| 700 |
% \hbox to \linewidth{^^A |
| 701 |
% \kern-\leftmargin\relax |
| 702 |
% \hss |
| 703 |
% \usebox0 |
| 704 |
% \hss |
| 705 |
% \kern-\rightmargin\relax |
| 706 |
% }^^A |
| 707 |
% }^^A |
| 708 |
% \ifdim\wd0>\lw |
| 709 |
% \sbox0{\small\t}^^A |
| 710 |
% \ifdim\wd0>\linewidth |
| 711 |
% \ifdim\wd0>\lw |
| 712 |
% \sbox0{\footnotesize\t}^^A |
| 713 |
% \ifdim\wd0>\linewidth |
| 714 |
% \ifdim\wd0>\lw |
| 715 |
% \sbox0{\scriptsize\t}^^A |
| 716 |
% \ifdim\wd0>\linewidth |
| 717 |
% \ifdim\wd0>\lw |
| 718 |
% \sbox0{\tiny\t}^^A |
| 719 |
% \ifdim\wd0>\linewidth |
| 720 |
% \lwbox |
| 721 |
% \else |
| 722 |
% \usebox0 |
| 723 |
% \fi |
| 724 |
% \else |
| 725 |
% \lwbox |
| 726 |
% \fi |
| 727 |
% \else |
| 728 |
% \usebox0 |
| 729 |
% \fi |
| 730 |
% \else |
| 731 |
% \lwbox |
| 732 |
% \fi |
| 733 |
% \else |
| 734 |
% \usebox0 |
| 735 |
% \fi |
| 736 |
% \else |
| 737 |
% \lwbox |
| 738 |
% \fi |
| 739 |
% \else |
| 740 |
% \usebox0 |
| 741 |
% \fi |
| 742 |
% \else |
| 743 |
% \lwbox |
| 744 |
% \fi |
| 745 |
% \else |
| 746 |
% \usebox0 |
| 747 |
% \fi |
| 748 |
% \end{quote} |
| 749 |
% If you have a \xfile{docstrip.cfg} that configures and enables \docstrip's |
| 750 |
% TDS installing feature, then some files can already be in the right |
| 751 |
% place, see the documentation of \docstrip. |
| 752 |
% |
| 753 |
% \subsection{Refresh file name databases} |
| 754 |
% |
| 755 |
% If your \TeX~distribution |
| 756 |
% (\TeX\,Live, \mikTeX, \dots) relies on file name databases, you must refresh |
| 757 |
% these. For example, \TeX\,Live\ users run \verb|texhash| or |
| 758 |
% \verb|mktexlsr|. |
| 759 |
% |
| 760 |
% \subsection{Some details for the interested} |
| 761 |
% |
| 762 |
% \paragraph{Unpacking with \LaTeX.} |
| 763 |
% The \xfile{.dtx} chooses its action depending on the format: |
| 764 |
% \begin{description} |
| 765 |
% \item[\plainTeX:] Run \docstrip\ and extract the files. |
| 766 |
% \item[\LaTeX:] Generate the documentation. |
| 767 |
% \end{description} |
| 768 |
% If you insist on using \LaTeX\ for \docstrip\ (really, |
| 769 |
% \docstrip\ does not need \LaTeX), then inform the autodetect routine |
| 770 |
% about your intention: |
| 771 |
% \begin{quote} |
| 772 |
% \verb|latex \let\install=y\input{engord.dtx}| |
| 773 |
% \end{quote} |
| 774 |
% Do not forget to quote the argument according to the demands |
| 775 |
% of your shell. |
| 776 |
% |
| 777 |
% \paragraph{Generating the documentation.} |
| 778 |
% You can use both the \xfile{.dtx} or the \xfile{.drv} to generate |
| 779 |
% the documentation. The process can be configured by the |
| 780 |
% configuration file \xfile{ltxdoc.cfg}. For instance, put this |
| 781 |
% line into this file, if you want to have A4 as paper format: |
| 782 |
% \begin{quote} |
| 783 |
% \verb|\PassOptionsToClass{a4paper}{article}| |
| 784 |
% \end{quote} |
| 785 |
% An example follows how to generate the |
| 786 |
% documentation with pdf\LaTeX: |
| 787 |
% \begin{quote} |
| 788 |
%\begin{verbatim} |
| 789 |
%pdflatex engord.dtx |
| 790 |
%makeindex -s gind.ist engord.idx |
| 791 |
%pdflatex engord.dtx |
| 792 |
%makeindex -s gind.ist engord.idx |
| 793 |
%pdflatex engord.dtx |
| 794 |
%\end{verbatim} |
| 795 |
% \end{quote} |
| 796 |
% |
| 797 |
% \begin{History} |
| 798 |
% \begin{Version}{2000/05/23 v1.0} |
| 799 |
% \item |
| 800 |
% First public release, published in newsgroup \xnewsgroup{de.comp.text.tex}:\\ |
| 801 |
% \URL{``\link{Re: Ordinalzahlen in LaTeX?}''}^^A |
| 802 |
% {https://groups.google.com/group/de.comp.text.tex/msg/738e2cb4c51759d6} |
| 803 |
% \end{Version} |
| 804 |
% \begin{Version}{2003/04/28 v1.1} |
| 805 |
% \item |
| 806 |
% Bug fix for 30, 40, 50, \dots, 100, 130, \dots |
| 807 |
% \item |
| 808 |
% \cs{ordletters} renamed to documented \cs{engordletters}. |
| 809 |
% \end{Version} |
| 810 |
% \begin{Version}{2006/02/20 v1.2} |
| 811 |
% \item |
| 812 |
% Support for \plainTeX. |
| 813 |
% \item |
| 814 |
% Switch \cs{ifengordraise} added. |
| 815 |
% \item |
| 816 |
% Package options \xoption{raise} and \xoption{normal} added. |
| 817 |
% \item |
| 818 |
% DTX framework. |
| 819 |
% \end{Version} |
| 820 |
% \begin{Version}{2007/04/11 v1.3} |
| 821 |
% \item |
| 822 |
% Line ends sanitized. |
| 823 |
% \end{Version} |
| 824 |
% \begin{Version}{2007/04/26 v1.4} |
| 825 |
% \item |
| 826 |
% Use of package \xpackage{infwarerr}. |
| 827 |
% \end{Version} |
| 828 |
% \begin{Version}{2007/09/09 v1.5} |
| 829 |
% \item |
| 830 |
% Catcode section added. |
| 831 |
% \end{Version} |
| 832 |
% \begin{Version}{2007/09/20 v1.6} |
| 833 |
% \item |
| 834 |
% Short description fixed (George White). |
| 835 |
% \end{Version} |
| 836 |
% \begin{Version}{2008/08/11 v1.7} |
| 837 |
% \item |
| 838 |
% Code is not changed. |
| 839 |
% \item |
| 840 |
% URLs updated. |
| 841 |
% \end{Version} |
| 842 |
% \begin{Version}{2010/03/01 v1.8} |
| 843 |
% \item |
| 844 |
% Compatibility with \iniTeX. |
| 845 |
% \end{Version} |
| 846 |
% \begin{Version}{2016/05/16 v1.9} |
| 847 |
% \item |
| 848 |
% Documentation updates. |
| 849 |
% \end{Version} |
| 850 |
% \end{History} |
| 851 |
% |
| 852 |
% \PrintIndex |
| 853 |
% |
| 854 |
% \Finale |
| 855 |
\endinput |