summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/ncctools/source/ncccomma.dtx
diff options
context:
space:
mode:
Diffstat (limited to 'macros/latex/contrib/ncctools/source/ncccomma.dtx')
-rw-r--r--macros/latex/contrib/ncctools/source/ncccomma.dtx101
1 files changed, 101 insertions, 0 deletions
diff --git a/macros/latex/contrib/ncctools/source/ncccomma.dtx b/macros/latex/contrib/ncctools/source/ncccomma.dtx
new file mode 100644
index 0000000000..8488370b2f
--- /dev/null
+++ b/macros/latex/contrib/ncctools/source/ncccomma.dtx
@@ -0,0 +1,101 @@
+% \iffalse
+%%
+%% File: ncccomma.dtx Copyright (C) 2005 by Alexander I. Rozhenko
+%%
+%<package>\NeedsTeXFormat{LaTeX2e}
+%<package>\ProvidesPackage{ncccomma}
+%<package> [2005/02/10 v1.0 Smart Math Comma Package (NCC)]
+%
+% \changes{v1.0}{2005/02/10}{Initial version}
+%
+%<*driver>
+\let\makeindex\relax
+\documentclass{ltxdoc}
+\usepackage{ncccomma}
+\GetFileInfo{ncccomma.sty}
+\begin{document}
+\title{The \textsf{ncccomma} package\thanks{This file
+ has version number \fileversion, last
+ revised \filedate.}}
+\author{Alexander I. Rozhenko\\rozhenko@oapmg.sscc.ru}
+\date{\filedate}
+\maketitle
+\DocInput{ncccomma.dtx}
+\end{document}
+%</driver>
+% \fi
+%
+% The package implements the smart comma in math mode.
+% Let us compare this solution with the concurrent solution from
+% the |icomma| package by Walter Schmidt:
+% \begin{itemize}
+% \item In |icomma|, a comma in math works as the
+% punctuation mark if a space goes after it. Otherwise,
+% it work as an ordinary character;
+% \item In |ncccomma|, a comma in math works as an ordinary
+% character if a decimal character goes after it.
+% Otherwise, it works as a punctuation mark.
+% \end{itemize}
+% The solution used in this package is more expansive because
+% we compare the next character with up to ten decimal chars.
+% But this solution needs less number of spaces to be inserted into
+% original document (the space is only necessary in the place
+% of a comma delimiting something and a decimal number).
+%
+% \DescribeMacro{\mathcomma}
+% The original math comma is saved in the |\mathcomma| macro.
+% This macro is useful together with the |dcolumn| package.
+% If a comma should be \emph{printed} as the
+% decimal separator in a column of type |D|, it must be specified
+% as |{\mathcomma}|, rather than |{,}|, since the latter
+% leads to an error. For example:
+% \begin{quote}
+% |\begin{tabular}{D{,}{\mathcomma}{-1}}|
+% \end{quote}
+%
+% \DescribeMacro{\ordcommalist}
+% The list of decimal characters is saved in the |\ordcommalist|.
+% It initial definition is
+% \begin{quote}
+% |\newcommand\ordcommalist{0123456789}|
+% \end{quote}
+% You can redefine it if necessary.
+%
+% \StopEventually{}
+%
+% \section{The Implementation}
+%
+% We save the original comma in |\mathcomma| and then specify
+% the comma to be an active char in math.
+% \begin{macrocode}
+%<*package>
+\mathchardef\mathcomma\mathcode`\,
+\mathcode`\,="8000
+% \end{macrocode}
+% No we define the meaning of comma using the well-known trick with
+% upper case.
+% \begin{macrocode}
+\bgroup
+ \uccode`\~`\,%
+ \uppercase{%
+\egroup
+ \def~}{\futurelet\@let@token\NCC@comma}
+% \end{macrocode}
+% The smart comma compares the next char with a character of the
+% |\ordcommalist| in cycle. This cycle is a bit expansive,
+% but it is the payment for smartness.
+% \begin{macrocode}
+\newcommand\ordcommalist{0123456789}
+\def\NCC@comma{%
+ \let\@tempb\@empty
+ \expandafter\@tfor\expandafter\@tempa\expandafter:\expandafter=%
+ \ordcommalist\do{%
+ \expandafter\ifx\@tempa\@let@token
+ \let\@tempb\mathord \@break@tfor
+ \fi
+ }%
+ \@tempb\mathcomma
+}
+%</package>
+% \end{macrocode}
+\endinput