Debian Codegraph @

texmf-dist/source/latex/ncctools/ncccomma.dtx

raw
1 % \iffalse
2 %%
3 %% File: ncccomma.dtx Copyright (C) 2005 by Alexander I. Rozhenko
4 %%
5 %<package>\NeedsTeXFormat{LaTeX2e}
6 %<package>\ProvidesPackage{ncccomma}
7 %<package> [2005/02/10 v1.0 Smart Math Comma Package (NCC)]
8 %
9 % \changes{v1.0}{2005/02/10}{Initial version}
10 %
11 %<*driver>
12 \let\makeindex\relax
13 \documentclass{ltxdoc}
14 \usepackage{ncccomma}
15 \GetFileInfo{ncccomma.sty}
16 \begin{document}
17 \title{The \textsf{ncccomma} package\thanks{This file
18 has version number \fileversion, last
19 revised \filedate.}}
20 \author{Alexander I. Rozhenko\\[email protected]}
21 \date{\filedate}
22 \maketitle
23 \DocInput{ncccomma.dtx}
24 \end{document}
25 %</driver>
26 % \fi
27 %
28 % The package implements the smart comma in math mode.
29 % Let us compare this solution with the concurrent solution from
30 % the |icomma| package by Walter Schmidt:
31 % \begin{itemize}
32 % \item In |icomma|, a comma in math works as the
33 % punctuation mark if a space goes after it. Otherwise,
34 % it work as an ordinary character;
35 % \item In |ncccomma|, a comma in math works as an ordinary
36 % character if a decimal character goes after it.
37 % Otherwise, it works as a punctuation mark.
38 % \end{itemize}
39 % The solution used in this package is more expansive because
40 % we compare the next character with up to ten decimal chars.
41 % But this solution needs less number of spaces to be inserted into
42 % original document (the space is only necessary in the place
43 % of a comma delimiting something and a decimal number).
44 %
45 % \DescribeMacro{\mathcomma}
46 % The original math comma is saved in the |\mathcomma| macro.
47 % This macro is useful together with the |dcolumn| package.
48 % If a comma should be \emph{printed} as the
49 % decimal separator in a column of type |D|, it must be specified
50 % as |{\mathcomma}|, rather than |{,}|, since the latter
51 % leads to an error. For example:
52 % \begin{quote}
53 % |\begin{tabular}{D{,}{\mathcomma}{-1}}|
54 % \end{quote}
55 %
56 % \DescribeMacro{\ordcommalist}
57 % The list of decimal characters is saved in the |\ordcommalist|.
58 % It initial definition is
59 % \begin{quote}
60 % |\newcommand\ordcommalist{0123456789}|
61 % \end{quote}
62 % You can redefine it if necessary.
63 %
64 % \StopEventually{}
65 %
66 % \section{The Implementation}
67 %
68 % We save the original comma in |\mathcomma| and then specify
69 % the comma to be an active char in math.
70 % \begin{macrocode}
71 %<*package>
72 \mathchardef\mathcomma\mathcode`\,
73 \mathcode`\,="8000
74 % \end{macrocode}
75 % No we define the meaning of comma using the well-known trick with
76 % upper case.
77 % \begin{macrocode}
78 \bgroup
79 \uccode`\~`\,%
80 \uppercase{%
81 \egroup
82 \def~}{\futurelet\@let@token\NCC@comma}
83 % \end{macrocode}
84 % The smart comma compares the next char with a character of the
85 % |\ordcommalist| in cycle. This cycle is a bit expansive,
86 % but it is the payment for smartness.
87 % \begin{macrocode}
88 \newcommand\ordcommalist{0123456789}
89 \def\NCC@comma{%
90 \let\@tempb\@empty
91 \expandafter\@tfor\expandafter\@tempa\expandafter:\expandafter=%
92 \ordcommalist\do{%
93 \expandafter\ifx\@tempa\@let@token
94 \let\@tempb\mathord \@break@tfor
95 \fi
96 }%
97 \@tempb\mathcomma
98 }
99 %</package>
100 % \end{macrocode}
101 \endinput