Debian Codegraph @

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

raw
1 %\iffalse
2 %<*package>
3 %% \CharacterTable
4 %% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
5 %% Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
6 %% Digits \0\1\2\3\4\5\6\7\8\9
7 %% Exclamation \! Double quote \" Hash (number) \#
8 %% Dollar \$ Percent \% Ampersand \&
9 %% Acute accent \' Left paren \( Right paren \)
10 %% Asterisk \* Plus \" Comma \,
11 %% Minus \- Point \. Solidus \/
12 %% Colon \: Semicolon \; Less than \<
13 %% Equals \= Greater than \> Question mark \?
14 %% Commercial at \@ Left bracket \[ Backslash \\
15 %% Right bracket \] Circumflex \^ Underscore \_
16 %% Grave accent \` Left brace \{ Vertical bar \|
17 %% Right brace \} Tilde \~}
18 %</package>
19 %\fi
20 % \iffalse
21 % Doc-Source file to use with LaTeX2e
22 % Copyright (C) 2017-18 Sebastian Friedl
23 %
24 % This work is subject to the LaTeX Project Public License, Version 1.3c or -- at
25 % your option -- any later version of this license.
26 % The work consists of the files textualicomma.dtx, textualicomma.ins,
27 % textualicomma-doc.dtx and the derived file textualicomma.sty
28 %
29 % This work has the LPPL maintenance status 'maintained'.
30 % Current maintainer of the work is Sebastian Friedl.
31 % \fi
32 %
33 %
34 %
35 % \changes{1.0}{2017/12/03}{Initial release}
36 % \changes{1.1}{2018/08/23}{Take care of dependencies and requirements}
37 %
38 %
39 % \subsubsection*{Initialization}
40 % \begin{macrocode}
41 \ProvidesPackage{textualicomma}%
42 [2018/08/23 v1.1 Use textual comma characters as decimal separators]
43 \NeedsTeXFormat{LaTeX2e}
44 % \end{macrocode}
45 %
46 %
47 %
48 % \bigskip
49 % \subsubsection*{Load dependencies and check requirements}
50 % Load the \sty{amstext} package to enable escaping to horizontal mode:
51 % \begin{macrocode}
52 \RequirePackage{amstext}
53 % \end{macrocode}
54 %
55 % Check whether "\rmfamily", "\sffamily" and "\ttfamily" are available:
56 % \begin{macrocode}
57 \AtBeginDocument{%
58 \ifx\rmfamily\@undefined%
59 \PackageError{textualicomma}%
60 {\noexpand\rmfamily is undefined. textualicomma doesn't work}%
61 {textualicomma requires the \noexpand\rmfamily command to be
62 defined; otherwise, this package won't work properly}%
63 \PackageWarning{textualicomma}{Emergency stop}%
64 \stop%
65 \fi%
66 \ifx\sffamily\@undefined%
67 \PackageError{textualicomma}%
68 {\noexpand\sffamily is undefined. textualicomma doesn't work}%
69 {textualicomma requires the \noexpand\sffamily command to be
70 defined; otherwise, this package won't work properly}%
71 \PackageWarning{textualicomma}{Emergency stop}%
72 \stop%
73 \fi%
74 \ifx\ttfamily\@undefined%
75 \PackageError{textualicomma}%
76 {\noexpand\ttfamily is undefined. textualicomma doesn't work}%
77 {textualicomma requires the \noexpand\ttfamily command to be
78 defined; otherwise, this package won't work properly}%
79 \PackageWarning{textualicomma}{Emergency stop}%
80 \stop%
81 \fi%
82 }
83 % \end{macrocode}
84 %
85 %
86 %
87 % \subsubsection*{Package options}
88 % Provide a \opt{sffamily} option for using the sans serif font:
89 % \begin{macrocode}
90 \newif\if@txticmma@sffamily
91 \@txticmma@sffamilyfalse
92 \DeclareOption{sffamily}{\@txticmma@sffamilytrue}
93 % \end{macrocode}
94 %
95 % Provide a \opt{ttfamily} option for using the typewriter font:
96 % \begin{macrocode}
97 \newif\if@txticmma@ttfamily
98 \@txticmma@ttfamilyfalse
99 \DeclareOption{ttfamily}{\@txticmma@ttfamilytrue}
100 % \end{macrocode}
101 %
102 % Process all options passed to \sty{textualicomma}:
103 % \begin{macrocode}
104 \ProcessOptions
105 % \end{macrocode}
106 %
107 %
108 %
109 % \subsubsection*{Configuration}
110 % Use the roman text font family by default:
111 % \begin{macrocode}
112 \def\txticmma@ffamily{\rmfamily}
113 % \end{macrocode}
114 %
115 % If one of the \opt{sffamily} or \opt{ttfamily} options has been used, changes are applied:
116 % \begin{macrocode}
117 \if@txticmma@sffamily\def\txticmma@ffamily{\sffamily}\fi
118 \if@txticmma@ttfamily\def\txticmma@ffamily{\ttfamily}\fi
119 % \end{macrocode}
120 %
121 % \begin{macro}{\textualicommafont}
122 % Provide a command for switching the font family inside the document:
123 % \begin{macrocode}
124 \def\textualicommafont#1{\def\txticmma@ffamily{#1}}
125 % \end{macrocode}
126 % \end{macro}
127 %
128 %
129 %
130 % \subsubsection*{Defining the \enquote{textual intelligent comma}}
131 % At the very beginning, provide access to the textual comma character.
132 % Also, define a math character referring to the comma contained in the math font,
133 % to be used in enumerations:
134 % \begin{macrocode}
135 \AtBeginDocument{%
136 \def\m@thtextcomma{\text{\txticmma@ffamily,}}
137 \mathchardef\mathcomma\mathcode`\,%
138 \mathcode`\,="8000 %
139 }
140 % \end{macrocode}
141 %
142 % Make the comma character active and map it to the \enquote*{smart comma}:
143 % \begin{macrocode}
144 {\catcode`,=\active
145 \gdef,{\futurelet\@let@token\sm@rtcomma}
146 }
147 % \end{macrocode}
148 %
149 % Last but not least, define the \enquote*{smart comma} \dots
150 % \begin{macrocode}
151 \def\sm@rtcomma{%
152 \ifx\@let@token\@sptoken\m@thtextcomma\protect\,\else
153 \ifx\@let@token\space \else
154 \m@thtextcomma\fi\fi}
155 % \end{macrocode}
156 %
157 % \dots\ and allow changing the period's font:
158 % \begin{macrocode}
159 \DeclareMathSymbol{.}{\mathalpha}{operators}{`.}
160 % \end{macrocode}
161 %
162 %
163 %
164 % \subsubsection*{Famous last words}
165 % That's enough code. "\endinput".
166 % \begin{macrocode}
167 \endinput
168 % \end{macrocode}