diff options
author | Karl Berry <karl@freefriends.org> | 2006-01-11 23:55:29 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2006-01-11 23:55:29 +0000 |
commit | 48243fdbbe15cb58c4136497707e37637e7d4100 (patch) | |
tree | 9de6f823e6a2520490bab3ea3f0828852d1a8db3 /Master/texmf-dist/source/latex/ncctools/ncccomma.dtx | |
parent | f7ffde8f769cd6f1d473ae231d219b99b3fa5263 (diff) |
trunk/Master/texmf-dist/source/latex/ncctools
git-svn-id: svn://tug.org/texlive/trunk@408 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/source/latex/ncctools/ncccomma.dtx')
-rw-r--r-- | Master/texmf-dist/source/latex/ncctools/ncccomma.dtx | 100 |
1 files changed, 100 insertions, 0 deletions
diff --git a/Master/texmf-dist/source/latex/ncctools/ncccomma.dtx b/Master/texmf-dist/source/latex/ncctools/ncccomma.dtx new file mode 100644 index 00000000000..8126358aadd --- /dev/null +++ b/Master/texmf-dist/source/latex/ncctools/ncccomma.dtx @@ -0,0 +1,100 @@ +% \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> +\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 |