summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex/was/icomma.dtx
blob: 712d1d9f8c40145960782581ad5929b1e8856df8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
%\CheckSum{28}
%
% \iffalse
%
% File `icomma.dtx'.
% Copyright (c) 2001, 2002 Walter Schmidt
%
% This program may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either version 1.2
% of this license or (at your option) any later version.
% The latest version of this license is in
%   http://www.latex-project.org/lppl.txt
% and version 1.2 or later is part of all distributions of LaTeX
% version 1999/12/01 or later.
%
% This program consists of the files icomma.dtx and icomma.ins
%
% \fi
%
% \iffalse
%
%<*driver>
\ProvidesFile{icomma.drv}
%</driver>
%<package>\ProvidesPackage{icomma}
  [2002/03/10 v2.0 (WaS)]
%<*driver>
\documentclass{ltxdoc}
\usepackage{url}
\CodelineNumbered
\begin{document}
 \DocInput{icomma.dtx}
\end{document}
%</driver>
% \fi
%
% \GetFileInfo{icomma.drv}
% \DeleteShortVerb{\|}
% \MakeShortVerb{\+}
%
% \title{The \textsf{icomma} package for \LaTeXe}
% \author{Walter Schmidt\thanks{{\ttfamily w.a.schmidt@gmx.net}}}
% \date{(\fileversion{} -- \filedate)}
% \maketitle\thispagestyle{empty}
%
% \noindent
% With ordinary \LaTeX{}, the comma cannot be used as a decimal separator
% in math mode, because it is treated as a punctuation character and
% \LaTeX\ adds some extra space after it.  This can be overcome by defining
% an `intelligent' comma, which `recognizes', whether it is used as
% a decimal separator or as a punctuation character.
%
% An appropriate definition was given in \cite{icomma} and \cite{icomma-err}.
% However, it relied on the particular encoding of the CM fonts, so 
% it would not always work with alternative math fonts such as Euler.
% The package \textsf{icomma} provides an enhanced variant of this
% `intelligent' comma.  It can be used with the default CM math fonts
% as well as with alterative math font sets. 
%
% After loading of the package, the comma will be typeset as a 
% punctuation character, if the next \emph{input} character 
% is a space; otherwise the comma is treated as a decimal separator.
% Thus, a decimal number is to be entered as, for instance,
% \begin{verse}
%   +1,234+
% \end{verse}
% whereas the mathematical expression $(x, y)$ is to be written
% with a space after the comma:
% \begin{verse}
%   \verb*|(x, y)|
% \end{verse}
%
% \section*{Bugs and problems}
% In case the `intelligent comma' is used together with the 
% \textsf{dcolumn} package, a comma to be \emph{printed} as the 
% decimal separator in a column of type +D+ is to be specified 
% as +{\mathord\mathcomma}+, rather than +{,}+, since the latter 
% leads to an error.  For instance:
% \begin{verse}
% +\begin{tabular}{... D{,}{\mathord\mathcomma}{2} ...}+
% \end{verse}
% Note that specifying the comma as the related \emph{input} character 
% works as usual.
%
% Generally, since the \textsf{icomma} package makes the comma `active', 
% further problems are not unlikely.
%
% \StopEventually{
% \section*{Credits}
% Special thanks to Bernd Raichle for fixing the deficiencies of version~1.
%
% \begin{thebibliography}{1}
%    \bibitem{icomma}
%        \textsc{Richard Hirsch}.
%        Dezimalkomma beim \TeX{}satz in deutsch.
%        \textit{Die \TeX{}nische Kom\"odie 1/1994} 
%        (July 1994), 42--45.
%    \bibitem{icomma-err}
%        \textsc{Peter Schmitt}.
%        Dezimalkomma beim \TeX{}satz in deutsch.
%        \textit{Die \TeX{}nische Kom\"odie 4/1997} 
%        (Feb.\ 1998), 50.
% \end{thebibliography}
% }
% 
% \section*{The package code}
% At +\begin{document}+, we memorize the +\mathcode+ of the `punctuation' comma, 
% in the +\mathcomma+ macro,
% and we make the comma in math mode active:
%    \begin{macrocode}
%<*package>
\AtBeginDocument{%
  \mathchardef\mathcomma\mathcode`\,%
  \mathcode`\,="8000 %
}
%    \end{macrocode}
% The active comma checks the next input character.
% If this is a space , the active comma simply returns
% the saved +\mathcomma+; otherwise, +\mathord\mathcomma+ is returned,
% so that no space will be added:
%    \begin{macrocode}
{\catcode`,=\active
  \gdef,{\futurelet\@let@token\sm@rtcomma}
}
\def\sm@rtcomma{%
  \ifx\@let@token\@sptoken \else
  \ifx\@let@token\space \else
    \mathord\fi\fi \mathcomma}
%</package>
%    \end{macrocode}
%
% The next line of code prevents DocStrip from adding the
% character table to the generated package:
%    \begin{macrocode}
\endinput
%    \end{macrocode}
% \Finale
%% \CharacterTable
%%  {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
%%   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
%%   Digits        \0\1\2\3\4\5\6\7\8\9
%%   Exclamation   \!     Double quote  \"     Hash (number) \#
%%   Dollar        \$     Percent       \%     Ampersand     \&
%%   Acute accent  \'     Left paren    \(     Right paren   \)
%%   Asterisk      \*     Plus          \+     Comma         \,
%%   Minus         \-     Point         \.     Solidus       \/
%%   Colon         \:     Semicolon     \;     Less than     \<
%%   Equals        \=     Greater than  \>     Question mark \?
%%   Commercial at \@     Left bracket  \[     Backslash     \\
%%   Right bracket \]     Circumflex    \^     Underscore    \_
%%   Grave accent  \`     Left brace    \{     Vertical bar  \|
%%   Right brace   \}     Tilde         \~}
%%