summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Master/texmf-dist/source/latex/numprint/Makefile101
-rw-r--r--Master/texmf-dist/source/latex/numprint/nbaseprt.dtx662
-rw-r--r--Master/texmf-dist/source/latex/numprint/numprint.dtx4604
-rw-r--r--Master/texmf-dist/source/latex/numprint/numprint.ins28
-rw-r--r--Master/texmf-dist/source/latex/numprint/numprint032.dtx1532
5 files changed, 6927 insertions, 0 deletions
diff --git a/Master/texmf-dist/source/latex/numprint/Makefile b/Master/texmf-dist/source/latex/numprint/Makefile
new file mode 100644
index 00000000000..1f5fbf23792
--- /dev/null
+++ b/Master/texmf-dist/source/latex/numprint/Makefile
@@ -0,0 +1,101 @@
+
+SRCDIR=numprint
+INSTALLDIR=`kpsewhich --expand-path='$$TEXMFLOCAL'`/tex/latex/numprint
+DOCDIR=`kpsewhich --expand-path='$$TEXMFLOCAL'`/doc/latex/numprint
+#VERSION=`latex getversion | grep '^VERSION' | sed 's/^VERSION \\(.*\\)\\.\\(.*\\)/\\1_\\2/g'`
+VERSION=`latex getversion | grep '^VERSION' | sed 's/^VERSION //' | sed 's/\\([0-9]*\\)\\.\\([0-9a-z]*\\)/\\1_\\2/g'`
+
+
+.SUFFIXES: .sty .ins .dtx .dvi .ps .pdf
+
+.ins.sty:
+ latex $<
+
+.dtx.pdf:
+ pdflatex $<
+ pdflatex $<
+ makeindex -s gind.ist $(*D)/$(*F)
+ makeindex -s gglo.ist -o $(*D)/$(*F).gls $(*D)/$(*F).glo
+ pdflatex $<
+
+.dvi.ps:
+ dvips -o $(*D)/$(*F).ps $(*D)/$(*F)
+
+
+all: numprint.sty numprint.pdf numprinttest.dvi \
+ nbaseprt.pdf nbaseprttest.dvi
+
+numprinttest.dvi: numprinttest.tex numprint.sty
+ latex numprinttest
+
+nbaseprttest.dvi: nbaseprttest.tex nbaseprt.sty
+ latex nbaseprttest
+
+
+
+clean:
+ @-rm -f numprint.glo numprint.gls numprint.idx numprint.ilg
+ @-rm -f numprint.ind numprint.aux numprint.log numprint.toc
+ @-rm -f numprinttest.log numprinttest.aux
+ @-rm -f nbaseprt.glo nbaseprt.gls nbaseprt.idx nbaseprt.ilg
+ @-rm -f nbaseprt.ind nbaseprt.aux nbaseprt.log nbaseprt.toc
+ @-rm -f nbaseprttest.log nbaseprttest.aux
+ @-rm -f *~
+
+distclean: clean
+ @-rm -f numprint.sty numprint.pdf numprint.ps numprint032.sty
+ @-rm -f numprinttest.dvi numprinttest.ps
+ @-rm -f nbaseprt.sty nbaseprt.pdf nbaseprt.ps nbaseprt032.sty
+ @-rm -f nbaseprttest.dvi nbaseprttest.ps
+
+tar: all clean
+ echo Lege numprint-$(VERSION).tar.gz an
+ -rm -f numprint-$(VERSION).tar.gz
+ tar czCf .. numprint-$(VERSION).tar.gz \
+ $(SRCDIR)/README \
+ $(SRCDIR)/ChangeLog.numprint \
+ $(SRCDIR)/ChangeLog.nbaseprt \
+ $(SRCDIR)/Makefile \
+ $(SRCDIR)/numprint.dtx \
+ $(SRCDIR)/nbaseprt.dtx \
+ $(SRCDIR)/numprint.ins \
+ $(SRCDIR)/numprint.pdf \
+ $(SRCDIR)/nbaseprt.pdf \
+ $(SRCDIR)/numprint032.dtx \
+ $(SRCDIR)/numprinttest.tex \
+ $(SRCDIR)/nbaseprttest.tex \
+ $(SRCDIR)/getversion.tex \
+ $(SRCDIR)/numprint.xml \
+ $(SRCDIR)/nbaseprt.xml
+ rm -f getversion.log
+
+texlive: all clean
+ rm -rf texmf
+ mkdir -p texmf/tex/latex/numprint
+ mkdir -p texmf/doc/latex/numprint
+ mkdir -p texmf/source/latex/numprint
+ cp numprint.sty nbaseprt.sty numprint032.sty texmf/tex/latex/numprint
+ cp numprint.dtx numprint.ins numprint.xml texmf/source/latex/numprint
+ cp nbaseprt.dtx nbaseprt.ins nbaseprt.xml texmf/source/latex/numprint
+ cp numprint032.dtx Makefile texmf/source/latex/numprint
+ cp README ChangeLog.numprint ChangeLog.nbaseprt texmf/doc/latex/numprint
+ cp numprinttest.tex numprint.pdf texmf/doc/latex/numprint
+ cp nbaseprttest.tex nbaseprt.pdf texmf/doc/latex/numprint
+
+zip: all clean texlive
+ -@rm -f numprint-$(VERSION).zip
+ zip -r numprint-$(VERSION).zip texmf
+ rm -r texmf/
+ rm -f getversion.log
+
+install: all
+ if [ ! -d $(INSTALLDIR) ]; then mkdir -p $(INSTALLDIR); fi
+ if [ ! -d $(DOCDIR) ]; then mkdir -p $(DOCDIR); fi
+ install -m644 numprint.sty numprint032.sty nbaseprt.sty $(INSTALLDIR)
+ install -m644 numprint.pdf numprinttest.tex $(DOCDIR)
+ install -m644 nbaseprt.pdf nbaseprttest.tex $(DOCDIR)
+ install -m644 README ChangeLog.numprint ChangeLog.nbaseprt $(DOCDIR)
+ texhash
+
+numprint.sty: numprint.ins numprint.dtx
+nbaseprt.sty: numprint.ins nbaseprt.dtx
diff --git a/Master/texmf-dist/source/latex/numprint/nbaseprt.dtx b/Master/texmf-dist/source/latex/numprint/nbaseprt.dtx
new file mode 100644
index 00000000000..801a534c3a1
--- /dev/null
+++ b/Master/texmf-dist/source/latex/numprint/nbaseprt.dtx
@@ -0,0 +1,662 @@
+% \iffalse meta comment
+% File: nbaseprt.dtx Copyright (C) 2004 Harald Harders
+% \fi
+%
+% \iffalse
+%
+%<*driver>
+\listfiles
+\documentclass[ngerman,english,a4paper]{ltxdoc}
+\usepackage[T1]{fontenc}
+\IfFileExists{nbaseprt.sty}{%
+ \usepackage{nbaseprt}
+}{%
+ \GenericWarning{nbaseprt.dtx}{Package file nbaseprt.sty not found
+ (Documentation will be messed up!^^J^^A
+ Generate nbaseprt.sty by (La)TeXing numprint.ins, process
+ nbaseprt.dtx again)^^J}\stop
+}
+\IfFileExists{eco.sty}{%
+ \usepackage{eco}
+ \renewcommand*\ttdefault{cmtt}
+}{%
+ \GenericWarning{nbaseprt.dtx}{Package file eco.sty not found
+ (Documentation will be less clear than possible)}
+}
+\usepackage{longtable}
+\usepackage{mathcomp}
+\usepackage{babel}
+\usepackage{url}
+\usepackage{color}
+\IfFileExists{booktabs.sty}{\usepackage{booktabs}}{%
+ \GenericWarning{nbaseprt.dtx}{Package file booktabs.sty not
+ found. Documentation formatting will be poor}%
+ \def\toprule\hline
+ \def\midrule\hline
+ \def\bottomrule\hline}
+\GetFileInfo{nbaseprt.sty}
+\title{The nbaseprt package}
+\author{Harald Harders\\\texttt{h.harders@tu-bs.de}}
+\date{Version \fileversion, \filedate; printed \today}
+\newlength{\tempdima}%
+\makeatletter
+\renewenvironment{table}[1][]{%
+ \@float{table}[#1]%
+ \centering%
+ \setlength{\tempdima}{\abovecaptionskip}%
+ \setlength{\abovecaptionskip}{\belowcaptionskip}%
+ \setlength{\belowcaptionskip}{\tempdima}%
+ }{%
+\end@float
+}
+\def\meta@font@select{\normalfont\itshape}
+\makeatother
+%%
+\EnableCrossrefs
+\CodelineIndex
+\DoNotIndex{\def,\edef,\let,\newcommand,\newenvironment,\newcounter}
+\DoNotIndex{\setcounter,\space,\if,\else,\fi,\empty,\@empty,\ifx,\fi}
+\DoNotIndex{\ifnum,\fi,\expandafter,\csname,\endcsname,\the}
+\DoNotIndex{\MessageBreak,\message,\newlength,\newif,\xdef,\newcount}
+\DoNotIndex{\begingroup,\endgroup,\,,\@tempcnta,\@tempdima,\advance}
+\DoNotIndex{\ensuremath,\filedate,\fileversion,\docdate}
+\DoNotIndex{\mathit,\mathrm,\mathsf,\nprt@tmp,\nprt@tmpnum,\relax}
+\DoNotIndex{\protect,\renewcommand,\setlength,\settowidth,\stepcounter}
+\DoNotIndex{\string}
+\CodelineNumbered
+\RecordChanges
+\CheckSum{343}
+\begin{document}
+ \DocInput{nbaseprt.dtx}
+\end{document}
+%</driver>
+% \fi
+%
+% \changes{0.11}{2004/12/14}{Usage of \texttt{eco.sty} in
+% \texttt{nbaseprttest.tex} only if available}%
+% \changes{0.10}{2004/08/08}{Total new implementation}%
+%
+% \maketitle
+% \begin{abstract}
+% \noindent
+% This package prints integer numbers in different bases (octal,
+% decimal, hexadecimal, binary) similarly to the |numprint| package.
+% But here, the number of digits within one group depends on the
+% base.
+%
+% \textbf{This version of |nbaseprt.sty| is a BETA VERSION.
+% The main command \cs{nbaseprint} will stay stable but
+% all configuration commands and the output of
+% \cs{nbaseprint} may change in future.
+% Please give me feedback what can be improved and if the
+% abbreviations for the different number bases are correct.}
+% \end{abstract}
+%
+% \tableofcontents
+%
+% \section*{Copyright}
+% Copyright 2004 Harald Harders.
+%
+% This program can be redistributed and/or modified under the terms
+% of the LaTeX Project Public License Distributed from CTAN
+% archives in directory macros/latex/base/lppl.txt; either
+% version 1 of the License, or any later version.
+%
+%
+% \section{Load the package}
+%
+% To use this package place
+% \begin{verbatim}
+%\usepackage{nbaseprt}\end{verbatim}
+% in the preamble of your document.
+% The |nbaseprt| package calls the |numprint| package and parses all
+% package options to it.
+% Please read the documentation for the |numprint| package for
+% details.
+% If you want to use both the |numprint| and the |nbaseprt| package
+% either load |numprint| first given all options, e.g.,
+% \begin{verbatim}
+%\usepackage[autolanguage,nosepfour]{numprint}
+%\usepackage{nbaseprt}\end{verbatim}
+% or only load the |nbaseprt| package, giving it the options for
+% |numprint|:
+% \begin{verbatim}
+%\usepackage[autolanguage,nosepfour]{nbaseprt}\end{verbatim}
+%
+%
+% \section{Print numbers}
+%
+% \DescribeMacro{\nbaseprint}%
+% Numbers are printed using the \cs{nbaseprint\marg{number}} command.
+% Which number base is used is determined by parsing the
+% \meta{number}.
+%
+% The type can be given by preceding the number by ``|0x|'', ``|0o|'',
+% ``|0d|'', or ``|0b|'' (or the uppercase characters) for hexadecimal,
+% octal, decimal, or binary numbers, respectively.
+% For example,
+% \begin{verbatim}
+%$\nbaseprint{0x1A0E3F}$, $\nbaseprint{0o377377}$,
+%$\nbaseprint{0d192314}$, $\nbaseprint{0b11010110}$\end{verbatim}
+%
+% Alternatively, hexadecimal and octal numbers can be given by
+% appending ``h'', ``H'', ``o'', or ``O'':
+% \begin{verbatim}
+%$\nbaseprint{1A0E3Fh}$, $\nbaseprint{377377o}$\end{verbatim}
+%
+% If neither is given, the number defaults to decimal.
+%
+% The format of the printed numbers is similar to the possible input
+% formats.
+% By default, the numbers are preceded by ``|0x|'', ``|0o|'',
+% ``|0d|'', or ``|0b|'', e.g.
+%
+% \begin{quotation}
+% $\nbaseprint{0x1A0E3F}$, $\nbaseprint{0o377377}$,
+% $\nbaseprint{0d192314}$, $\nbaseprint{0b11010110}$
+% \end{quotation}
+%
+% \DescribeMacro{\nbaseposttext}%
+% You can change this by using \cs{nbaseposttext}.
+% This leads to
+% \begin{quotation}
+% \nbaseposttext
+% $\nbaseprint{0x1A0E3F}$, $\nbaseprint{0o377377}$,
+% $\nbaseprint{0d192314}$, $\nbaseprint{0b11010110}$
+% \end{quotation}
+%
+% \DescribeMacro{\nbasepretext}%
+% You can switch back to the default behaviour using \cs{nbasepretext}
+% or by using \cs{nbaseposttext} inside a group.
+%
+%
+% If you want to print negative numbers the sign may be written before
+% or after ``|0x|'', ``|0o|'', ``|0d|'', or ``|0b|''.
+% Some examples:
+% \begin{verbatim}
+%$\nbaseprint{-0x1A0E3F}$, $\nbaseprint{0o-377377}$,
+%$\nbaseprint{0d+-192314}$, $\nbaseprint{0b\pm 11010110}$\end{verbatim}
+% which lead to
+% \begin{quotation}
+% $\nbaseprint{-0x1A0E3F}$, $\nbaseprint{0o-377377}$,
+% $\nbaseprint{0d+-192314}$, $\nbaseprint{0b\pm 11010110}$
+% \end{quotation}
+% In the printout, the sign always is written after the base-specific
+% string. (is this correct?)
+%
+%
+% \section{Customization}
+%
+% \subsection{Padding a number on the left side}%
+%
+% \DescribeMacro{\nplpadding}%
+% \DescribeMacro{\npnolpadding}%
+% Sometimes it is desireable to have a number of a fixed length with
+% the missing digits filled with a character (mostly the character
+% ``0'', so this is the default).
+% This can be achieved calling
+% \cs{nplpadding\oarg{character}\marg{digits}} borrowed from the
+% |numprint| package.
+% For example,
+% \begin{verbatim}
+%\nplpadding{6}%
+%$\nbaseprint{0xA03E}$, $\nbaseprint{0o1234}$\end{verbatim}
+% leads to \begingroup
+% ``\nplpadding{6}$\nbaseprint{0xA03E}$, $\nbaseprint{0o1234}$''
+% \endgroup
+%
+% \cs{npnolpadding} switches padding off.
+%
+%
+% \section{International support}%
+% \label{sec:international}%
+%
+% |nbaseprt| uses the thousand separator from |numprint|.
+% Since this package uses the German ``\cs{,}'' by default |nbaseprt|
+% does this, too.
+% Using the package option |autolanguage| this can be fixed.
+% If you are using this option without the |babel| package the
+% settings are switched to English at \cs{begin\{document\}}:
+% separator ``\texttt{,}''.
+% If using |babel| the separator is changed automatically when
+% switching to a supported language.
+%
+% If you do not want to use the |autolanguage| option you may use the
+% |numprint| command \cs{npthousandsep} command to change the
+% separator.
+%
+%
+% \section{Print aligned numbers in tabulars}%
+% \label{sec:tabular}%
+%
+% Sorry, not programmed, yet.
+%
+%
+%
+% \appendix
+%
+% \section{Lists of options and commands}
+%
+% This section contains lists of all package options resp.\ available
+% commands.
+% Items that belong together and may be exclusive are printed in
+% groups together.
+%
+% \subsection{Package options}%
+% \label{sec:package-options}%
+%
+% |nbaseprt| supports all options of the |numprint| package.
+% In this list, only the ones that are new or have a different meaning
+% are listed.
+%
+% \begingroup
+% \newcommand*\default{$^{*}$}%
+% The default values are marked by \default.
+% \begin{longtable}[l]{%
+% @{}>{\ttfamily}p{0.30\linewidth}@{}p{0.70\linewidth}@{}}
+% np& Define the shortcuts \cs{np} for \cs{numprint} and \cs{nbp}
+% for \cs{nbaseprint}.
+% \end{longtable}
+% \endgroup
+%
+% \subsection{Commands}
+%
+% Commands that begin with \cs{np} are borrowed from |numprint|.
+% Here, the new commands and |numprint| commands that have a special
+% meaning for |nbaseprt| are listed here.
+%
+% \begin{longtable}[l]{%
+% @{}>{\ttfamily \char`\\}p{0.3\linewidth}@{}p{0.7\linewidth}@{}}
+% npaddplus& Add a plus to a number without a sign.\\
+% npnoaddplus& Don't do that.\\[\medskipamount]
+% nbp& Shortcut for \cs{nbaseprint} (only available with package
+% option~\texttt{np}).\\
+% nbaseprint& Typesets a number (the package's main
+% command).\\[\medskipamount]
+% npthousandsep& Change the separator between the digit
+% groups.\\[\medskipamount]
+% nplpadding& Declare up to how many digits the number will be padded at
+% the lefthand side. \\
+% npnolpadding& Switch off padding. \\[\medskipamount]
+% nbaserpretext& Switches on to precede the number by ``0x'',
+% ``0o'', or ``0d''. \\
+% nbaserposttext& Switches on to append ``h'', ``o'', or nothing to
+% the number.
+% \end{longtable}
+%
+%
+% \section{To do}
+%
+% \begin{itemize}
+% \item Add table support.
+% \item Better customization for the pre and the post text.
+% \item Parse the argument for invalid numbers.
+% \item Proof output format of numbers.
+% \end{itemize}
+%
+%
+% \StopEventually{\PrintChanges \PrintIndex}
+%
+% \section{The implementation}
+% \iffalse
+%<*package>
+% \fi
+% Heading of the package:
+% \begin{macrocode}
+\NeedsTeXFormat{LaTeX2e}
+\ProvidesPackage{nbaseprt}
+ [2004/12/14 v0.11 Print numbers with numerical bases (HH)]
+% \end{macrocode}
+% Warning, that this is a beta version.
+% \begin{macrocode}
+\typeout{^^J*************************************************************}
+\PackageWarningNoLine{nbaseprt}{This version of nbaseprt.sty is a BETA
+ VERSION.\MessageBreak
+ The main command \string\nbaseprint\space will stay stable
+ but\MessageBreak
+ all configuration commands and the output of\MessageBreak
+ \string\nbaseprint\space may change in future.\MessageBreak
+ Please give me feedback what can be improved and if\MessageBreak
+ the abbreviations for the different number bases are\MessageBreak
+ correct}
+\typeout{*************************************************************^^J}
+% \end{macrocode}
+% Pass all unknown options to |numprint.sty| to avoid conflicts when
+% loading |numprint| seperately.
+% \begin{macrocode}
+\DeclareOption{np}{%
+ \newcommand*\nbp{\nbaseprint}%
+ \PassOptionsToPackage{np}{numprint}%
+}
+\DeclareOption*{\PassOptionsToPackage{\CurrentOption}{numprint}}
+\ProcessOptions\relax
+% \end{macrocode}
+% Load package |numprint| because |nbaseprt| shares some commands with
+% it.
+% \begin{macrocode}
+\RequirePackage{numprint}
+% \end{macrocode}
+% Easier if-then clauses.
+% \begin{macrocode}
+\RequirePackage{ifthen}
+% \end{macrocode}
+% Dummy definitions to get an error in case of incompatibility with
+% other packages.
+% \begin{macrocode}
+\newcommand*\nbprt@base{}
+\newcommand*\nbprt@number{}
+% \end{macrocode}
+% \begin{macro}{\nbprt@testbase}
+% Test which numeric base is used in the argument of \cs{nbaseprt}.
+% \begin{macrocode}
+\newcommand*\nbprt@testbase{}
+\def\nbprt@testbase#1#2#3\@empty{%
+% \end{macrocode}
+% Test if number begins with ``|0x|'', ``|0X|'', or ``|"|'' which all mean
+% that it is given as hexadecimal number.
+% \begin{macrocode}
+ \ifthenelse{\equal{#1#2}{0x}\or\equal{#1#2}{0X}\or\equal{#1}{"}}{%
+ \gdef\nbprt@base{hex}%
+% \end{macrocode}
+% Store the rest of the argument as number in \cs{nbprt@number}.
+% \begin{macrocode}
+ \ifthenelse{\equal{#1}{"}}{%
+ \edef\nbprt@number{#2#3}%
+ }{%
+ \edef\nbprt@number{#3}%
+ }%
+ }{%
+% \end{macrocode}
+% Test if number begins with ``|0o|'', ``|0O|'', or ``|'|'' which all
+% mean that it is given as octal number.
+% \begin{macrocode}
+ \ifthenelse{\equal{#1#2}{0o}\or\equal{#1#2}{0O}\or\equal{#1}{'}}{%
+ \gdef\nbprt@base{oct}%
+% \end{macrocode}
+% Store the rest of the argument as number in \cs{nbprt@number}.
+% \begin{macrocode}
+ \ifthenelse{\equal{#1}{'}}{%
+ \edef\nbprt@number{#2#3}%
+ }{%
+ \edef\nbprt@number{#3}%
+ }%
+ }{%
+% \end{macrocode}
+% Test if number begins with ``|0d|'' or ``|0D|'' which means that it
+% is given as decimal number.
+% \begin{macrocode}
+ \ifthenelse{\equal{#1#2}{0d}\or\equal{#1#2}{0D}}{%
+ \gdef\nbprt@base{dec}%
+% \end{macrocode}
+% Store the rest of the argument as number in \cs{nbprt@number}.
+% \begin{macrocode}
+ \edef\nbprt@number{#3}%
+ }{%
+% \end{macrocode}
+% Test if number begins with ``|0b|'' or ``|0B|'' which means that it
+% is given as decimal number.
+% \begin{macrocode}
+ \ifthenelse{\equal{#1#2}{0b}\or\equal{#1#2}{0B}}{%
+ \gdef\nbprt@base{bin}%
+% \end{macrocode}
+% Store the rest of the argument as number in \cs{nbprt@number}.
+% \begin{macrocode}
+ \edef\nbprt@number{#3}%
+ }{%
+% \end{macrocode}
+% If none of the above is the case the number defaults to decimal.
+% \begin{macrocode}
+ \def\nbprt@base{dec}%
+ \edef\nbprt@number{#1#2#3}%
+% \end{macrocode}
+% But there are also other possibilities to mark the number as
+% hexadecimal or octal, by appending ``|h|'', ``|H|'', ``|o|'', or
+% ``|O|''.
+% These tests are performed by seperate macros.
+% \begin{macrocode}
+ \nbprt@ishex#1#2#3h\@empty\@empty
+ \nbprt@isHex#1#2#3H\@empty\@empty
+ \nbprt@isoct#1#2#3o\@empty\@empty
+ \nbprt@isOct#1#2#3O\@empty\@empty
+ }%
+ }%
+ }%
+ }%
+% \end{macrocode}
+% Test for a sign before the number.
+% \begin{macrocode}
+ \expandafter\nbprt@testsign\nbprt@number\@empty\@empty\@empty
+% \end{macrocode}
+% Reset \cs{nbprt@string} that holds the number in formatted form.
+% \begin{macrocode}
+ \def\nbprt@string{}%
+% \end{macrocode}
+% Reset the counters that help formatting the number.
+% \begin{macrocode}
+ \@tempcnta=0
+ \@tempcntb=0
+% \end{macrocode}
+% Parse the number, done by \cs{nbprt@parsenum}.
+% \begin{macrocode}
+ \expandafter\nbprt@parsenum\nbprt@number\@empty
+% \end{macrocode}
+% If left padding is switched on, add the leading characters to gain
+% the specified length.
+% See \cs{nbprt@parsenum} for explanation of the algorithm.
+% \begin{macrocode}
+ \whiledo{\the\@tempcntb<\nprt@lpaddigits}{%
+ \ifnum\@tempcnta=\csname nbprt@digitgroup@\nbprt@base\endcsname\relax
+ \edef\nbprt@string{\nprt@separator@before\nbprt@string}%
+ \@tempcnta=0
+ \fi
+ \edef\nbprt@string{\nprt@lpadchar\nbprt@string}%
+ \advance\@tempcntb 1
+ \advance\@tempcnta 1
+ }%
+% \end{macrocode}
+% Print the text that marks the base of the number before the number
+% itself.
+% \begin{macrocode}
+ \ifnbprt@pretext
+ \csname nbprt@pretext@\nbprt@base\endcsname
+ \nbprt@presep
+ \fi
+% \end{macrocode}
+% Print the sign (use routine of |numprint|).
+% \begin{macrocode}
+ \nprt@printsign{mantissa}\nbprt@sign\@empty
+% \end{macrocode}
+% Print the modified number with separators.
+% \begin{macrocode}
+ \nbprt@string
+% \end{macrocode}
+% Print the text that marks the base of the number after the number
+% itself.
+% \begin{macrocode}
+ \ifnbprt@pretext
+ \else
+ \nbprt@postsep
+ \csname nbprt@posttext@\nbprt@base\endcsname
+ \fi
+}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\nbprt@testsign}
+% \begin{macrocode}
+\def\nbprt@testsign#1#2#3\@empty{%
+% ``#1'', ``#2'', ``#3'':
+ \nprt@IfCharInString{#1}{\nprt@signlist}{%
+ \edef\nbprt@number{#2#3}%
+ \edef\nbprt@sign{#1}%
+ \ifx\nbprt@sign\nprt@plus@test
+ \def\nprt@tmp{#2}%
+ \ifx\nprt@tmp\nprt@minus@test
+ \edef\nbprt@sign{+-}%
+ \edef\nbprt@number{#3}%
+ \fi
+ \else
+ \ifx\nbprt@sign\nprt@plusminus@test
+ \edef\nbprt@sign{+-}%
+ \fi
+ \fi
+ }{%
+ \edef\nbprt@number{#1#2#3}%
+ }%
+}
+% \end{macrocode}
+% \end{macro}
+% Test if the number is marked as hexadecimal by appending an ``|h|''.
+% \begin{macrocode}
+\def\nbprt@ishex#1h#2\@empty{%
+% \end{macrocode}
+% If |#2| is |h|, the number has ended with an |h| because this macro
+% has been called with an appended |h| in addition to the |h| that is
+% the last character of the number.
+% \begin{macrocode}
+ \ifthenelse{\equal{#2}{h}}{%
+% \end{macrocode}
+% Set the base and redefine the number.
+% \begin{macrocode}
+ \def\nbprt@base{hex}%
+ \edef\nbprt@number{#1}%
+ }{}%
+}
+% \end{macrocode}
+% Test if the number is marked as hexadecimal by appending an ``|H|''.
+% \begin{macrocode}
+\def\nbprt@isHex#1H#2\@empty{%
+ \ifthenelse{\equal{#2}{H}}{%
+ \def\nbprt@base{hex}%
+ \edef\nbprt@number{#1}%
+ }{}%
+}
+% \end{macrocode}
+% Test if the number is marked as octal by appending an ``|o|'' or an
+% ''|O|''.
+% \begin{macrocode}
+\def\nbprt@isoct#1o#2\@empty{%
+ \ifthenelse{\equal{#2}{o}}{%
+ \def\nbprt@base{oct}%
+ \edef\nbprt@number{#1}%
+ }{}%
+}
+\def\nbprt@isOct#1O#2\@empty{%
+ \ifthenelse{\equal{#2}{O}}{%
+ \def\nbprt@base{oct}%
+ \edef\nbprt@number{#1}%
+ }{}%
+}
+% \end{macrocode}
+% \begin{macro}{\nbprt@parsenum}
+% Parses the given number and generates the formatted string in
+% \cs{nbprt@string}, working recursively.
+% |#1| is the first character in the left number, |#2| is the rest.
+% \begin{macrocode}
+\def\nbprt@parsenum#1#2\@empty{%
+% \end{macrocode}
+% If |#2| is not \cs{@empty} call \cs{nbprt@parsenum} recursively to
+% parse the number backwards.
+% \begin{macrocode}
+ \ifthenelse{\equal{#2}{\@empty}}{}{%
+ \expandafter\nbprt@parsenum#2\@empty
+ }%
+% \end{macrocode}
+% Test if \cs{@tempcnta} has reached the number of digits that are
+% printed as group for the given number base (stored in
+% \cs{nbprt@digitgroup@}\meta{\cs{nbprt@base}}).
+% \begin{macrocode}
+ \ifnum\@tempcnta=\csname nbprt@digitgroup@\nbprt@base\endcsname\relax
+% \end{macrocode}
+% Precede the formatted number by the separator
+% \cs{nprt@separator@before}, taken from |numprint.sty|.
+% \begin{macrocode}
+ \edef\nbprt@string{\nprt@separator@before\nbprt@string}%
+% \end{macrocode}
+% Reset the number of handled characters in this group.
+% \begin{macrocode}
+ \@tempcnta=0
+ \fi
+% \end{macrocode}
+% Precede the formatted number by the current character while forcing
+% uppercase hexadecimal numbers.
+% \begin{macrocode}
+ \edef\nbprt@string{%
+ \uppercase{\ifmmode\mathrm{#1}\else#1\fi}%
+ \nbprt@string}%
+% \end{macrocode}
+% Count this digit for the current group (\cs{@tempcnta}) and for the
+% total number of digits (\cs{@tempcntb}).
+% \begin{macrocode}
+ \advance\@tempcntb 1
+ \advance\@tempcnta 1
+}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\nbasepretext}
+% Provide a command that switches to marking the numbers before the
+% number itself.
+% \begin{macrocode}
+\newif\ifnbprt@pretext
+\newcommand*\nbasepretext{\nbprt@pretexttrue}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\nbaseposttext}
+% Provide a command that switches to marking the numbers after the
+% number itself.
+% \begin{macrocode}
+\newcommand*\nbaseposttext{\nbprt@pretextfalse}
+% \end{macrocode}
+% \end{macro}
+% Provide the commands that print the text before or after the number.
+% \begin{macrocode}
+\def\nbprt@pretext@hex{0\ifmmode\mathrm{x}\else x\fi}%
+\def\nbprt@pretext@oct{0\ifmmode\mathrm{o}\else o\fi}%
+\def\nbprt@pretext@dec{0\ifmmode\mathrm{d}\else d\fi}%
+\def\nbprt@pretext@bin{0\ifmmode\mathrm{b}\else b\fi}%
+\def\nbprt@presep{\,}%
+\def\nbprt@posttext@hex{\ifmmode\mathrm{h}\else h\fi}%
+\def\nbprt@posttext@oct{\ifmmode\mathrm{o}\else o\fi}%
+\def\nbprt@posttext@dec{\ifmmode\mathrm{d}\else d\fi}%
+\def\nbprt@posttext@bin{\ifmmode\mathrm{b}\else b\fi}%
+\def\nbprt@postsep{\,}%
+% \end{macrocode}
+% By default, use the marker before the number.
+% \begin{macrocode}
+\nbasepretext
+% \end{macrocode}
+% Define how many numbers are grouped together, depending on the
+% number base.
+% \begin{macrocode}
+\def\nbprt@digitgroup@hex{2}%
+\def\nbprt@digitgroup@oct{3}%
+\def\nbprt@digitgroup@dec{3}%
+\def\nbprt@digitgroup@bin{4}%
+% \end{macrocode}
+% \begin{macro}{\nbaseprint}
+% Define the man command \cs{nbaseprint} which takes the printed
+% number as mandatory argument.
+% \begin{macrocode}
+\DeclareRobustCommand*\nbaseprint[1]{%
+% \end{macrocode}
+% First, expand the number to allow to use macros in the argument.
+% \begin{macrocode}
+ \edef\nbprt@number{#1}%
+% \end{macrocode}
+% Test if the number begins with a sign.
+% \begin{macrocode}
+ \def\nbprt@sign{}%
+ \expandafter\nbprt@testsign\nbprt@number\@empty\@empty\@empty
+% \end{macrocode}
+% Call \cs{nbprt@testbase} which tests for the number base and prints
+% the number.
+% \begin{macrocode}
+ \expandafter\nbprt@testbase\nbprt@number\@empty\@empty\@empty
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \iffalse
+%</package>
+% \fi
+% \Finale
+
diff --git a/Master/texmf-dist/source/latex/numprint/numprint.dtx b/Master/texmf-dist/source/latex/numprint/numprint.dtx
new file mode 100644
index 00000000000..0889a36fa92
--- /dev/null
+++ b/Master/texmf-dist/source/latex/numprint/numprint.dtx
@@ -0,0 +1,4604 @@
+% \iffalse meta comment
+% File: numprint.dtx Copyright (C) 2000--2005 Harald Harders
+% \fi
+%
+% \iffalse
+%
+%<*driver>
+\listfiles
+\documentclass[ngerman,english,a4paper]{ltxdoc}
+\usepackage[T1]{fontenc}
+\IfFileExists{numprint.sty}{%
+ \usepackage[warning,debug,autolanguage,boldmath,np]{numprint}
+}{%
+ \GenericWarning{numprint.dtx}{Package file numprint.sty not found
+ (Documentation will be messed up!^^J^^A
+ Generate numprint.sty by (La)TeXing numprint.ins, process
+ numprint.dtx again)^^J}\stop
+}
+\IfFileExists{eco.sty}{%
+ \usepackage{eco}
+ \renewcommand*\ttdefault{cmtt}
+}{%
+ \GenericWarning{numprint.dtx}{Package file eco.sty not found
+ (Documentation will be less clear than possible)}
+}
+\usepackage{longtable}
+\usepackage{mathcomp}
+\usepackage{babel}
+\usepackage{url}
+\usepackage{color}
+\IfFileExists{booktabs.sty}{\usepackage{booktabs}}{%
+ \GenericWarning{numprint.dtx}{Package file booktabs.sty not
+ found. Documentation formatting will be poor}%
+ \def\toprule\hline
+ \def\midrule\hline
+ \def\bottomrule\hline}
+\GlossaryPrologue{\section*{{Change History}}%
+ \markboth{{Change History}}{{Change History}}%
+ Since the version~1.00 is an entirely new implementation, the Change
+ History prior version~1.00 has been lost in this document. Have a
+ look to \texttt{numprint032.dtx} or \texttt{README} to get it.
+}
+\GetFileInfo{numprint.sty}
+\title{The numprint package}
+\author{Harald Harders\\\texttt{h.harders@tu-bs.de}}
+\date{Version \fileversion, \filedate; printed \today}
+\npdecimalsign{.}%
+\newlength{\tempdima}%
+\makeatletter
+\renewenvironment{table}[1][]{%
+ \@float{table}[#1]%
+ \centering%
+ \setlength{\tempdima}{\abovecaptionskip}%
+ \setlength{\abovecaptionskip}{\belowcaptionskip}%
+ \setlength{\belowcaptionskip}{\tempdima}%
+ }{%
+\end@float
+}
+\def\meta@font@select{\normalfont\itshape}
+\makeatother
+%%
+\EnableCrossrefs
+\CodelineIndex
+\DoNotIndex{\def,\edef,\let,\newcommand,\newenvironment,\newcounter}
+\DoNotIndex{\setcounter,\space,\if,\else,\fi,\empty,\@empty,\ifx,\fi}
+\DoNotIndex{\ifnum,\fi,\expandafter,\csname,\endcsname,\the}
+\DoNotIndex{\MessageBreak,\message,\newlength,\newif,\xdef,\newcount}
+\DoNotIndex{\begingroup,\endgroup,\,,\@tempcnta,\@tempdima,\advance}
+\DoNotIndex{\ensuremath,\filedate,\fileversion,\docdate}
+\DoNotIndex{\mathit,\mathrm,\mathsf,\nprt@tmp,\nprt@tmpnum,\relax}
+\DoNotIndex{\protect,\renewcommand,\setlength,\settowidth,\stepcounter}
+\DoNotIndex{\string}
+\CodelineNumbered
+\RecordChanges
+\CheckSum{2116}
+\begin{document}
+ \DocInput{numprint.dtx}
+\end{document}
+%</driver>
+% \fi
+%
+% \changes{1.35}{2005/07/11}{Support not to separate percent sign from
+% number}%
+% \changes{1.30}{2004/08/11}{Add the commands \cs{lenprint} and
+% \cs{cntprint} that print lengths and counters.}%
+% \changes{1.22}{2004/08/08}{Use \cs{npunitcommand} to typeset units}%
+% \changes{1.21}{2004/08/01}{Add support for Portuguese}%
+% \changes{1.20}{2004/07/27}{Remove the reduction in font sizes in
+% documentation}%
+% \changes{1.20}{2004/07/27}{Allow \cs{numprint\{-e5\}} in addition to
+% \cs{numprint\{e5\}}}%
+% \changes{1.20}{2004/07/27}{Add padding a number on the left side}%
+% \changes{1.13}{2004/04/01}{Small fix in documentation}%
+% \changes{1.12}{2004/02/12}{Adapt Makefile to \TeX Live}%
+% \changes{1.11}{2003/11/09}{Avoid use of \cs{fileversion} etc.}%
+% \changes{1.00}{2003/10/07}{Total new implementation}%
+%
+% \maketitle
+% \begin{abstract}
+% \noindent
+% This package prints numbers with a separator every three digits and
+% convert numbers given as |12345.6e789| to
+% {\npstylegerman\numprint{12345,6e789}}.
+% Numbers are printed in the current mode (text or math) in order to use
+% the correct font.
+%
+% Many things, including the decimal sign, the thousand separator, as
+% well as the product sign can be changed by the user, e.g., to reach
+% \numprint{12,345.6e789}.
+% If requested, numprint can round numbers to a given number of digits.
+%
+% If an optional argument is given it is printed upright as unit.
+% Numbers can be rounded to a given number of digits.
+%
+% The package supports an automatic, language-dependent change of the
+% number format.
+%
+% Tabular alignment using the |tabular|(|*|), |array|, |tabularx|, and
+% |longtable| environments (similar to the |dcolumn| and |rccol| packages)
+% is supported using all features of numprint. Additional text can be
+% added before and after the formatted number.
+%
+% If you want to print numbers with different bases (octal,
+% hexadecimal, etc.) use the |nbaseprt| package which comes with the
+% |numprint| package.
+% \end{abstract}
+%
+% \tableofcontents
+%
+% \section*{Copyright}
+% Copyright 2000--2005 Harald Harders.
+%
+% This program can be redistributed and/or modified under the terms
+% of the LaTeX Project Public License Distributed from CTAN
+% archives in directory macros/latex/base/lppl.txt; either
+% version 1 of the License, or any later version.
+%
+% \section*{Remarks}
+%
+% \begingroup
+% \itshape
+% \sloppypar
+% The \cs{fourdigitsep}, \cs{fourdigitnosep},
+% \cs{addmissingzero}, \cs{noaddmissingzero}, \cs{digits},
+% \marginpar{\raggedleft\bfseries\Huge !}%
+% \cs{nodigits}, \cs{exponentsdigits}, and \cs{noexponentdigits}
+% commands have been renamed to \cs{npfourdigitsep},
+% \cs{npfourdigitnosep}, \cs{npaddmissingzero},
+% \cs{npnoaddmissingzero}, \cs{npdigits}, \cs{npnodigits},
+% \cs{npexponentsdigits}, resp.\ \cs{npnoexponentdigits}.
+%
+% From version 1.00 to 1.10, the column types have been changed; see
+% section~\ref{sec:tabular}.
+% \marginpar{\raggedleft\bfseries\Huge !}%
+% If you want to preserve the old column types, use the package option
+% |oldcolumntypes|.
+% \endgroup
+%
+% For typesetting this documentation, the usage of different font
+% shapes has been reduced as much as possible in order to save disk
+% memory and download times.
+% Thus, for nearly all characters, the design size 10\,pt has been
+% used.
+% This reduced the size of the PDF file for version 1.10 from 858\,KB
+% to 396\,KB.
+% Please excuse that shortcoming in the typography.
+%
+%
+% \section{Load the package}
+%
+% To use this package place
+% \begin{verbatim}
+%\usepackage{numprint}\end{verbatim}
+% in the preamble of your document.
+% No options are necessary but some are available.
+% They are mentioned where their usage is described and in
+% section~\ref{sec:package-options}.
+%
+% \section{Print numbers in text and math mode}
+%
+% \DescribeMacro{\numprint}%
+% This package provides the command
+% \cs{numprint\oarg{unit}\marg{number}} that prints the \meta{number}
+% given in the required argument.
+% The number is printed in the current mode (math or text mode) so
+% that an eventual chosen difference between mathematical and text
+% numbers stays visible (e.g., by using the eco package).
+%
+% Numbers may contain of these characters:
+% ``|+-\pm0123456789.,eEdD|''.
+% Spaces, ``\cs{,}'' as well as ``\texttt{\~}'' in the argument are
+% ignored.
+% Either a ``|,|'' or a ''|.|'' can be used as decimal sign.
+% By default, no thousand separators are allowed in the
+% argument.\footnote{Section~\ref{sec:custom-parsing} describes how
+% this can be changed.}
+% ``|E|'', ``|e|'', ``|D|'', or ``|d|''\footnote{This is useful for
+% FORTRAN produced numbers.} is converted to an exponential format
+% (e.g., $x\cdot 10^{y}$ or $x\times 10^{y}$, depending on the
+% format settings described later).
+% ``|\pm|'' and ``|+-|'' produce a $\pm$.
+%
+% For example, typing
+% \begin{verbatim}
+%\numprint{-123456}; \numprint{\pm 123456}; \numprint{+-3,1415927e-3.1}\end{verbatim}
+% leads to ``\numprint{-123456}; \numprint{\pm 123456};
+% \numprint{+-3,1415927e-3.1}''.
+% Notice that ``|.|'' and ``|,|'' can be mixed within one number and
+% are converted to the chosen decimal sign for the output.
+%
+% The number is printed in the active mode (text mode resp.\ math
+% mode).
+% This may be important if the digits are different in text and math
+% mode as in this document that uses old-style figures in text and
+% lining figures in math mode.\footnote{This is only the case if the
+% \texttt{eco} package is available on your system.}
+% See the difference between
+% ``\numprint{123456.134e123}'' and ``$\numprint{123456.134e123}$'',
+% produced by
+% \begin{verbatim}
+%``\numprint{123456.134e123}'' and ``$\numprint{123456.134e123}$''\end{verbatim}
+%
+% If no number is given before the exponential characters ``|e|'',
+% ``|E|'', ``|d|'', resp.\ ``|D|'', a pure exponential format is
+% generated.
+% For example, typing
+% \begin{verbatim}
+%\numprint{e4.3242}\end{verbatim}
+% leads to ``\numprint{e4.3242}''.
+% This also works with given signs, e.g.,
+% \begin{verbatim}
+%\numprint{-e4.3242}, \numprint{+-e4.3242} \end{verbatim}
+% leads to ``\numprint{-e4.3242}, \numprint{+-e4.3242}''.
+%
+% Since \cs{numprint} expands the argument before typesetting it you
+% may also use commands inside the argument, e.g.,
+% \begin{verbatim}
+%\def\numberbefore{1234}%
+%\def\totalnumber{\numberbefore.5678}%
+%\numprint{\totalnumber}\end{verbatim}
+% leads to
+% ``{\def\numberbefore{1234}\def\totalnumber
+% {\numberbefore.5678}\numprint{\totalnumber}}''.
+%
+% If the optional argument is given it is printed as a \meta{unit} in
+% math mode with an upright font (\verb|\mathrm|), e.g.,
+% \begin{verbatim}
+%\numprint[N/mm^2]{-123456}\end{verbatim}
+% leads to ``\numprint[N/mm^2]{-123456}''.
+%
+% \changes{1.00}{2003/10/07}{Automatically don't separate degree sign
+% from number}%
+% By default, the space between the number and the unit is \cs{,}.
+% One exception is the degree symbol which is typeset without a
+% distance to the number, e.g., $\numprint[\tcdegree]{360}$ in
+% contrast to $\numprint[\tccelsius]{273,15}$ (only a single degree
+% symbol is typeset without a separator).
+% The |numprint| package detects this automatically if the
+% \cs{tcdegree} command of the |mathcomp| package, the \cs{textdegree}
+% command of the |textcomp| package, or the \cs{degree} command of the
+% |gensymb| package is used, e.g.,
+% \begin{verbatim}
+%\numprint[\tcdegree]{360}, \numprint[\degree]{360}\end{verbatim}
+% Unfortunately, typing in the ``\texttt{\textdegree}'' sign directly
+% cannot be detected (any help welcome).
+%
+% \changes{1.32}{2004/09/13}{Improve documentation about
+% \texttt{textcomp} symbols}%
+% If you want to use one of the |textcomp| symbols \textcelsius\
+% (\cs{textcelsius}), \textohm\ (\cs{textohm}), \textmu\
+% (\cs{textmu}), or \textperthousand\ (\cs{textperthousand})\ you have
+% to load either the |mathcomp| or the |gensymb| package because the
+% unit is printed in math mode.
+% If you decide to use the |textomp| package use \cs{tc\meta{name}}
+% instead of \cs{text\meta{name}}, e.g., \cs{tccelsius} instead of
+% \cs{textcelsius}.
+% If using |gensymb| just use \cs{\meta{name}}, e.g.,
+% \cs{celsius}.\footnote{If you still use \cs{text\meta{name}}
+% numprint uses \cs{tc\meta{name}} or \cs{\meta{name}} and generates a
+% warning if one of these commands is available, and produces an error
+% if not.}
+%
+%
+% \DescribeMacro{\np}
+% Since it is timeconsuming to type in the long command \cs{numprint}
+% for every number in a text the shortcut \cs{np} can be defined by
+% specifying the package option~\texttt{np}.
+%
+% By default, numbers are written in the format
+% \begingroup
+% \npstyledefault
+% \numprint{12345,12345e12345},
+% \endgroup
+% for instance.
+% This means, decimal sign ``\texttt{,}'', thousand
+% separator ``\cs{,}'', and product sign
+% ``\texttt{\{\}\cs{cdot}\{\}}''.
+% This accords to German number formats and is a result of the history
+% of this package.
+% How you can change this is described in the following sections.
+% Especially, have a look at the |autolanguage| package option in
+% section~\ref{sec:international}.
+%
+%
+% \subsection{Print counters and lengths}
+%
+% If you want to print a counter or a length, you may of course use
+% \begin{verbatim}
+%\numprint{\arabic{page}}\end{verbatim}
+% resp.
+% \begin{verbatim}
+%\makeatletter
+%\numprint[pt]{\strip@pt\textwidth}
+%\makeatother\end{verbatim}
+% But these methods are not really nice.
+%
+% \DescribeMacro{\cntprint}%
+% For printing counters, you may use
+% \cs{cntprint\oarg{unit}\marg{counter}} where \meta{unit} is an
+% optional unit that is printed as by \cs{numprint}.
+% \meta{counter} is the name of a \LaTeX\ counter, for example,
+% \begin{verbatim}
+%$\cntprint{page}$\end{verbatim}
+% leads to ``$\cntprint{page}$''.
+%
+% \DescribeMacro{\lenprint}%
+% Lengths can be printed using \cs{lenprint\oarg{unit}\marg{length}}.
+% \meta{length} is the macro containing a \LaTeX\ length or a \TeX\
+% dimension, e.g., \cs{textwidth}.
+% \meta{unit} is a different thing here.
+% If the unit is not given \cs{lenprint} uses \LaTeX's standard and
+% prints the length in |pt|:
+% \begin{verbatim}
+%$\lenprint{\textwidth}$\end{verbatim}
+% leads to ``$\lenprint{\textwidth}$''.
+% Giving |pt| does not change anything.
+% But if you use other units, e.g., |mm|, |cm|, or |in|, the length is
+% written using the given unit:
+% \begin{verbatim}
+%$\lenprint[pt]{\textwidth}$,
+%$\lenprint[in]{\textwidth}$,
+%$\lenprint[bp]{\textwidth}$,
+%$\lenprint[mm]{\textwidth}$,
+%$\lenprint[cm]{3\textwidth}$\end{verbatim}
+% gives ``$\lenprint[pt]{\textwidth}$,
+% $\lenprint[in]{\textwidth}$,
+% $\lenprint[bp]{\textwidth}$,
+% $\lenprint[mm]{\textwidth}$,
+% $\lenprint[cm]{3\textwidth}$''.
+%
+% As you can see in the example, it is also possible to specify a
+% factor in the argument, e.g. |3\textwidth|.
+% When printing lengths, it is often desirable not to print all
+% decimal places.
+% |numprint| can round numbers, described in section~\ref{sec:round}.
+%
+% \cs{lenprint} knows the units |pt|, |bp|, |in|, |ft|, |mm|, |cm|,
+% |m|, and |km|.
+% Section~\ref{sec:more-units} describes how to add or change units.
+%
+%
+% \section{Customization}
+%
+% \subsection{Eliminate separators for four-digit numbers}
+%
+% At least in German it is common not to add a separator to four-digit
+% numbers in non-technical texts, e.g., to typeset
+% {\npfourdigitnosep``\numprint{1234}''} instead of ``\numprint{1234}'',
+% but longer numbers are separated: ``\numprint{12345}''.
+% If a number, in contrast, has less than five digits on one side of
+% the decimal sign but five or more digits on the other side,
+% separators are inserted on both sides, e.g.,
+% {\npfourdigitnosep``\numprint{1234,1234}'' but
+% ``\numprint{1234,12345}''}.
+%
+% \DescribeMacro{\npfourdigitsep}%
+% \DescribeMacro{\npfourdigitnosep}%
+% This behaviour can be achieved using the command
+% \cs{npfourdigitnosep}.
+% If using this switch inside a group the change is local.
+% You can switch back to separating with \cs{npfourdigitsep}.
+% An example:
+% \begin{verbatim}
+%\npfourdigitnosep$\numprint{1234.1234}$, $\numprint{12345.12345}$ --
+%\npfourdigitsep$\numprint{1234.1234}$, $\numprint{12345.12345}$\end{verbatim}
+% Leads to
+% {``\npfourdigitnosep$\numprint{1234.1234}$, $\numprint{12345.12345}$ --
+% \npfourdigitsep$\numprint{1234.1234}$, $\numprint{12345.12345}$''.}
+% Default values can be set by the package options |sepfour| and
+% |nosepfour|.
+%
+%
+% \subsection{Add missing zeros before or after decimal sign}
+%
+% \DescribeMacro{\npaddmissingzero}%
+% \DescribeMacro{\npnoaddmissingzero}%
+% Sometimes people let out a leading zero or a zero after the
+% decimalsign, e.g., ``|123.|'' or ``|.123|''.
+% Numprint can add the left out zero, when \cs{addmissingzero} is
+% used.
+% If, however, no decimal sign is given, e.g., ``|123|'', no decimal
+% sign or zero is appended.
+% Adding zeros can be switched off with \cs{noaddmissingzero}.
+% The corresponding package options are |addmissingzero| and
+% |noaddmissinzero|.
+% The default is |addmissingzero|.
+%
+%
+% \subsection{Add a plus sign}%
+% \changes{1.00}{2003/10/07}{Support for adding a plus to a number}%
+%
+% \DescribeMacro{\npaddplus}%
+% \DescribeMacro{\npnoaddplus}%
+% Using the \cs{npaddplus} command or the package option |addplus|, a
+% plus sign can be added to a number that is specified without a
+% sign.
+% This can be switched off using \cs{npnoaddplus} resp.\ |noaddplus|.
+%
+% \DescribeMacro{\npaddplusexponent}%
+% \DescribeMacro{\npnoaddplusexponent}%
+% The commands \cs{npaddplusexponent} and \cs{npnoaddplusexponent}
+% resp.\ the package options |addplusexponent| and |noaddplusexponent|
+% do the same for the exponents that the commands/options described
+% above do for the number.
+%
+%
+% \subsection{Rounding numbers}%
+% \label{sec:round}%
+%
+% \DescribeMacro{\nprounddigits}%
+% \DescribeMacro{\nproundexpdigits}%
+% \DescribeMacro{\npnoround}%
+% \DescribeMacro{\npnoroundexp}%
+% By default, as many digits are printed after the decimal sign, as
+% the \cs{numprint} command gets as argument.
+% This behaviour can be changed to print a given number of digits
+% where the number is rounded resp.\ filled with zeros.
+%
+% This can be switched on using the
+% \cs{nprounddigits\marg{digits}} command for ordinary
+% numbers and the \cs{nproundexpdigits\marg{digits}}
+% command for exponents.
+% Rounding is switched off with \cs{npnoround} resp.\
+% \cs{npnoroundexp}.
+% For example,
+% \begin{verbatim}
+%\nprounddigits{2}$\numprint{1.123}$, $\numprint{1.149}$,
+%$\numprint{1}$, $\numprint{9.999}$ $\numprint{-9.999}$ --
+%\npnoround$\numprint{1.123}$, $\numprint{1.149}$,
+%$\numprint{1}$, $\numprint{9.999}$, $\numprint{-9.999}$\end{verbatim}
+% leads to
+% ``\nprounddigits{2}$\numprint{1.123}$, $\numprint{1.149}$,
+% $\numprint{1}$, $\numprint{9.999}$ $\numprint{-9.999}$ --
+% \npnoround$\numprint{1.123}$, $\numprint{1.149}$,
+% $\numprint{1}$, $\numprint{9.999}$, $\numprint{-9.999}$''
+%
+%
+% \subsection{Padding a number on the left side}%
+%
+% \DescribeMacro{\nplpadding}%
+% \DescribeMacro{\npnolpadding}%
+% Sometimes it is desireable to have a number of a fixed length with
+% the missing digits filled with a character (mostly the character
+% ``0'', so this is the default).
+% This can be achieved calling
+% \cs{nplpadding\oarg{character}\marg{digits}}.
+% This affects only the mantissa, the part after the decimal sign and
+% signs are not counted!
+% If the orginal number has more digits than \meta{digits} no
+% characters will be inserted.
+% For example,
+% \begin{verbatim}
+%\nplpadding{6}%
+%$\numprint{1234}$, $\numprint{-1234}$,
+%$\numprint{12345678}$, $\numprint{1234.5678}$ --
+%\nplpadding[x]{6}%
+%$\numprint{1234}$, $\numprint{-1234}$,
+%$\numprint{12345678}$, $\numprint{1234.5678}$\end{verbatim}
+% leads to \begingroup
+% ``\nplpadding{6}$\numprint{1234}$, $\numprint{-1234}$,
+% $\numprint{12345678}$, $\numprint{1234.5678}$ --
+% \nplpadding[x]{6}$\numprint{1234}$, $\numprint{-1234}$,
+% $\numprint{12345678}$, $\numprint{1234.5678}$''
+% \endgroup
+%
+% \cs{npnolpadding} switches padding off.
+%
+%
+% \subsection{Replace zeros by other characters}
+%
+% \DescribeMacro{\npreplacenull}%
+% \DescribeMacro{\npprintnull}%
+% For amounts of money, sometimes a zero after the decimal sign is
+% replaced by different symbols, as for example ``---''.
+% This can be done by calling the command
+% \cs{npreplacenull\marg{replacement}}, e.g.,
+% \begin{verbatim}
+%\npreplacenull{\mbox{---}}\end{verbatim}
+% Here, \cs{mbox} guarantees that ``---'' is printed in text
+% mode.\footnote{You should better use \texttt{amsmath} and the
+% command \cs{text} which preserves the correct text size, too.}
+%
+% It can be switched off using \cs{npprintnull}.
+%
+%
+% \subsection{Change the format of units}
+%
+% \DescribeMacro{\npunitcommand}%
+% By default, the unit is printed in math mode with an upright font.
+% This is reached by using the \cs{npunitcommand} macro which by
+% default is defined as follows:
+% \begin{verbatim}
+%\newcommand*\npunitcommand[1]{\ensuremath{\mathrm{#1}}}\end{verbatim}
+% If you want to change this, redefine the \cs{npunitcommand}.
+% You really should use either \cs{ensuremath} or
+% \cs{text}\footnote{Provided by \texttt{amsmath}.} to ensure math or
+% text mode respectively.
+% \cs{npunitcommand} has to take one mandatory argument.
+%
+% For example, a blue unit is reached by
+% \begin{verbatim}
+%\renewcommand*\npunitcommand[1]{\ensuremath{\color{blue}\mathrm{#1}}}\end{verbatim}
+% And here is the result:
+% \begingroup
+% \renewcommand*\npunitcommand[1]{\ensuremath{\color{blue}\mathrm{#1}}}%
+% \numprint[N/mm^2]{300}
+% \endgroup
+%
+%
+% \section{Add more units to \cs{lenprint}}%
+% \label{sec:more-units}%
+%
+% \DescribeMacro{\npdefunit}%
+% The command \cs{npdefunit\marg{unitname}\marg{unit}\marg{scale}} can
+% be used to define new units or to redefine existing ones.
+% For example, |mm| is defined as follows:
+% \begin{verbatim}
+%\npdefunit{mm}{mm}{0.35145980351}\end{verbatim}
+% The first argument \meta{unitname} is the \LaTeX\ internal name that
+% will be given as unit in the \cs{lenprint} command.
+% The second argument \meta{unit} is the text that will be printed
+% out.
+%
+% The \meta{scale} arises from the fact that the default unit
+% $\mathrm{pt}$ is defined as $\np[pt]{1} = 1/\np[in]{72,27} =
+% \np[in]{0,01383700013}$ and $\np[in]{1} = \np[mm]{25,4}$.
+% Thus, $\np[pt]{1} = \np{0,01383700013} \times \np[mm]{25,4} =
+% \np[mm]{0.35145980351}$.
+% For defining a new unit, the factor from $\mathrm{pt}$ to the
+% desired unit has to be calculated and given as third argument of
+% \cs{npdefunit}.
+% To redefine a unit with unchanged scale, use |*| instead.
+% For example,
+% \begin{verbatim}
+%\npdefunit{in}{\!''}{*}\end{verbatim}
+% redefines |in| to print $\mathrm{''}$ as unit instead of the default
+% $\mathrm{in}$.
+% The \cs{!} is used to remove the separator between number and unit
+% (\cs{,}) again.
+% This only works correctly if \cs{,} and \cs{!} use the same
+% measure.
+% \begin{verbatim}
+%$\lenprint[in]{\textwidth}$,
+%\npdefunit{in}{\!''}{*}%
+%$\lenprint[in]{\textwidth}$\end{verbatim}
+% leads to \begingroup
+% ``$\lenprint[in]{\textwidth}$,
+% \npdefunit{in}{\!''}{*}$\lenprint[in]{\textwidth}$''.
+% \endgroup
+%
+%
+%
+% \section{International support}%
+% \label{sec:international}%
+% \changes{1.00}{2003/10/07}{Automatic support for different number
+% formats in different languages}%
+%
+% As mentioned above, |numprint| uses German settings for numbers:
+% thousand separator ``\cs{,}'', decimal sign ``\texttt{,}'', product
+% sign ``\cs{cdot}'', unit separator \cs{,}, and no degree separator,
+% by default.
+% This will stay stable for compatibility with older versions even if
+% its unlogical since the default language of \LaTeX\ is English.
+%
+% Using the package option |autolanguage| this can be fixed.
+% If you are using this option without the |babel| package the
+% settings are switched to English at \cs{begin\{document\}}:
+% thousand separator ``\texttt{,}'', decimal sign ``\texttt{.}'',
+% product sign ``\cs{times}'', unit separator \cs{,}, and no degree
+% separator,
+%
+% \DescribeMacro{\selectlanguage}
+% If you are using the |babel| package in conjunction with the
+% |autolanguage| package option, the behaviour of \cs{numprint} alters
+% with the active language.
+% If you, for instance, use
+% \begin{verbatim}
+%\selectlanguage{ngerman}\end{verbatim}
+% the German settings are selected.
+% If you then switch back to English, the English settings are active
+% again.
+%
+% The current version supports English, German, and Portuguese.
+% Unfortunately, I don't really know how to write numbers in other
+% languages than German.
+% I am quite sure that the English version also is correct.
+% But please help me to add other languages.
+%
+% As long as |numprint| does not support your language you may add the
+% definitions by yourself.
+% How this can be done is described in
+% section~\ref{sec:advanced:international}.
+%
+%
+% \section{Print aligned numbers in tabulars}%
+% \label{sec:tabular}%
+% \changes{1.10}{2003/10/12}{New tabular alignment mechanism}%
+%
+% Aligning numbers in tabulars is providede by the \texttt{dcolumn}
+% and \texttt{rccol} packages.
+% But they have two disadvantages.
+% First, they do not support typesetting numbers in the same way as
+% \cs{numprint} does.
+% Second, they force the numbers to be typeset in math mode.
+% Thus, this packages provides own mechanisms to gain aligned
+% numbers.
+%
+% In former versions up to 1.00, the align mechanism in tabulars has
+% been somehow weak because the author had to repeat the \cs{numprint}
+% call in every table cell.
+% This has been improved in version~1.10.
+% For compatibility reasons, the old column types |n| and |N| have
+% been preserved if you specify the |oldcolumntypes| package option;
+% they will be discussed in section~{sec:column:old}.
+%
+%
+% \subsection{The new column types}%
+% \label{sec:column:new}%
+%
+% \DescribeMacro{column type n}
+% The |numprint| package provides the column type |n| that takes two
+% mandatory arguments.
+% They define the number of digits before and the number of digits
+% after the decimal sign.
+% The results can be seen in the left column of the tabular below.
+% You can use this column type as the normal column types, e.g.,
+% \begin{verbatim}
+% \begin{tabular}{n{3}{4}n{4}{2}}\end{verbatim}
+% The numbers are printed in a reserved space with the necessary width
+% for the specified numbers, aligned at the decimal sign.
+% If a column contains numbers that have an exponent it is appended
+% left-aligned while the width of the column is extended by the
+% required space.
+% This is shown in the first column in the example below.
+%
+% If you, in addition, want to reserve space for digits in the
+% exponent you can insert one (specify numbers of digits before the
+% decimal sign) or two (number of digits before and after the decimal
+% sign) optional arguments, as can be seen in columns 2 and 3 in the
+% example below.
+% If you reserve space for the exponent, too long exponents may exceed
+% the tabular cell (as can be seen in the second column).
+%
+% This example tabular\footnote{The tabulars are ugly here. But the
+% only important thing is to show the effects of the alignments.}
+%\par\medskip\noindent
+% {\tabcolsep0mm\small
+% \begin{tabular}{|n{5}{3}|n[3]{5}{3}|n[3][1]{5}{3}|N{5}{3}|}
+% \hline
+% 123.45e12& 123.45e12& 123.45e12& 123.45e12 \\
+% 12345.678e123& 12345.678e123& 12345.678e123& 12345.678e123 \\
+% 123.45e12.3& 123.45e12.3& 123.45e12.3& 123.45e12.3 \\
+% 12345.678e123.3& 12345.678e123.3& 12345.678e123.3& 12345.678e123.3 \\
+% \hline
+% \end{tabular}}
+% \par\medskip\noindent
+% is produced by the following code:
+% \begin{verbatim}
+%\tabcolsep0mm\small
+%\begin{tabular}{|n{5}{3}|n[3]{5}{3}|n[3][1]{5}{3}|N{5}{3}|}
+% \hline
+% 123.45e12& 123.45e12& 123.45e12 & 123.45e12 \\
+% 12345.678e123& 12345.678e123& 12345.678e123& 12345.678e123 \\
+% 123.45e12.3& 123.45e12.3& 123.45e12.3& 123.45e12.3 \\
+% 12345.678e123.3& 12345.678e123.3& 12345.678e123.3& 12345.678e123.3 \\
+% \hline
+%\end{tabular}\end{verbatim}
+% The |n| column type prints the number in math mode.
+% Thus, the first three columns in the example are printed with lining
+% figures.
+% \DescribeMacro{column type N}
+% To print numbers in text mode, you can use the |N| column type as
+% shown in column four of the tabular.\footnote{If you use a tabular
+% environment that prints its arguments in math mode, e.g., the
+% \texttt{array} environment, also \texttt{N} prints the numbers in
+% math mode.}
+% It takes the same arguments as the |n| column type.
+%
+% You may put additional text into tabular cells.
+% The numprint package uses an algorithm to determine which part is
+% the number and which is additional text.
+% In order to preserve spaces and to use characters as text that could
+% also be part of a number (e.g., digits or the characters ``e'',
+% ``E'', ``d'', or ``D'') you have to enclose the text in
+% braces, for example ``\texttt{\{hello\} 1234}'' instead of
+% ``\texttt{hello 1234}''.
+% (In some rare cases, even two pairs of braces is necessary.
+% This is the case if you want to use a single character that may also
+% be used in a number, e.g., ``\texttt{\{\{3\}\}
+% 1234}''.\footnote{It is the same if the text starts with one of some
+% special commands that normally don't occur at the beginning of
+% tabular cells, \cs{end}, \cs{tabularnewline}, \cs{nprt@end},
+% \cs{endtabular}, \cs{csname}, and \cs{relax}.})
+% If you don't use these enclosing braces strange results may appear.
+% For preceding text, you have to ensure that it has the same width
+% for all lines of the same column.
+% Have a look at the following example:
+%\begin{verbatim}
+%\begin{tabular}{n{2}{1}n{2}{1}n{2}{1}n[1]{2}{1}}
+% \toprule
+% {without braces}&
+% {with braces}&
+% {with braces and box}&
+% \multicolumn{1}{l}{with braces, exp, and box}
+% \\
+% \midrule
+% abc def 12,3e3 rt&
+% {abc def } 12,3e3 { rt}&
+% {\npmakebox[abc def ][l]{abc def }} 12,3e3 { rt}&
+% {\npmakebox[abc def ][l]{abc def }} 12,3e3 { rt}
+% \\
+% more 45,1 txt&
+% {more } 45,1 { txt}&
+% {\npmakebox[abc def ][l]{more }} 45,1 { txt}&
+% {\npmakebox[abc def ][l]{more }} 45,1 { txt}
+% \\
+% \midrule
+% not blue 45,1 txt&
+% {\color{blue}blue } 45,1 { txt}&
+% {\color{blue}\npmakebox[abc def ][l]{blue }} 45,1 { txt}&
+% {\color{blue}\npmakebox[abc def ][l]{blue }} 45,1 { txt}
+% \\
+% \bottomrule
+%\end{tabular}
+%\end{verbatim}
+% The result looks as follows:
+% \par\medskip\noindent
+%{\footnotesize
+%\begin{tabular}{n{2}{1}n{2}{1}n{2}{1}n[1]{2}{1}}
+% \toprule
+% {without braces}&
+% {with braces}&
+% {with braces and box}&
+% \multicolumn{1}{l}{with braces, exp, and box}
+% \\
+% \midrule
+% abc def 12,3e3 rt&
+% {abc def } 12,3e3 { rt}&
+% {\npmakebox[abc def ][l]{abc def }} 12,3e3 { rt}&
+% {\npmakebox[abc def ][l]{abc def }} 12,3e3 { rt}
+% \\
+% more 45,1 txt&
+% {more } 45,1 { txt}&
+% {\npmakebox[abc def ][l]{more }} 45,1 { txt}&
+% {\npmakebox[abc def ][l]{more }} 45,1 { txt}
+% \\
+% \midrule
+% not blue 45,1 txt&
+% {\color{blue}blue } 45,1 { txt}&
+% {\color{blue}\npmakebox[abc def ][l]{blue }} 45,1 { txt}&
+% {\color{blue}\npmakebox[abc def ][l]{blue }} 45,1 { txt}
+% \\
+% \bottomrule
+%\end{tabular}}
+% \par\medskip\noindent
+% In the first column, the texts before and after the number are
+% not enlosed by braces.
+% Then, strange results appear:
+% In the first line, ``\texttt{de}'' is interpreted as number.
+% Thus, it is printed in math mode, and the rest of the cell,
+% ``\texttt{f 12,3e3 rt}'' is printed as text, again.
+% In the second line, the part ``\texttt{e 45,1}'' is printed as
+% number.
+%
+% This strange behaviour can be avoided by enclosing the texts by
+% braces, as mentioned above and shown in the second column.
+% Thus, the texts are printed correctly.
+% A space in the enclosed texts can separate the text from the number,
+% as done in the example.
+% Since the left texts have different widths the alignment of the
+% numbers is broken, here.
+%
+% This can be fixed by putting the contents in boxes, using the
+% \cs{makebox} or \cs{npmakebox} command, as shown in the third
+% column.
+% \DescribeMacro{\npmakebox}
+% The \cs{npmakebox} has a similar syntax as the \cs{makebox} command
+% but uses a text instead of a length to determine the width of the
+% box: \cs{npmakebox\oarg{text 1}\oarg{justification}\marg{text 2}}.
+% The command determines which width \meta{text 1} would have and
+% typesets \meta{text 2} into a box of this width.
+%
+% If you put the preceding text in each line in such a box the number
+% will be aligned as desired.
+%
+% Still, the text on the right-hand side of the numbers is not
+% aligned.
+% This can be fixed by specifying the number of digits of the
+% exponent, as shown in the fourth column.
+%
+% The third line is a little bit different from the others.
+% Here, not only text is inserted but also a command that changes the
+% output of the numbers.
+% Even such commands have to be enclosed by braces.
+%
+% \DescribeMacro{\multicolumn}
+% For producing tabular cells that don't contain a number, you either
+% have to enclose the cell contents by braces or to use the
+% \cs{multicolumn} command as shown in the first line of the example
+% above.
+%
+% If you want to print a line in bold letters using the \cs{boldmath}
+% command in math resp.\ \cs{bfseries} in text mode the alignment is
+% not correct anymore.
+% This is due to the fact that the bold letters are wider than the
+% normal ones.
+% You can avoid that problem if the font family provides a bold font
+% shape that has the same width as the normal one.
+% For the Computer Modern fonts, such a font shape exists.
+% In text mode, you can access it by using
+% \changes{1.10}{2003/10/12}{Define math version \texttt{npbold}}%
+% \begin{verbatim}
+% \fontseries{b}\selectfont\end{verbatim}
+% \DescribeMacro{\mathversion}
+% \DescribeMacro{\npboldmath}
+% If you also want to use that font in math mode, you may use the math
+% version |npbold| by using \cs{mathversion\{npbold\}} or
+% \cs{npboldmath}.
+% In order to save memory, these commands and the |npbold| math
+% version are only available if you call |numprint.sty| using the
+% |boldmath| package option.
+%
+% An example:
+% \begin{verbatim}
+%\begin{tabular}{lN{12}{3}n{12}{3}}
+% \toprule
+% normal:&
+% 123456123456.123e12&
+% 123456123456.123e12
+% \\
+% bold:&
+% {\fontseries{b}\selectfont} 123456123456.123e12&
+% {\npboldmath} 123456123456.123e12
+% \\
+% bold extended:&
+% {\bfseries} 123456123456.123e12&
+% {\boldmath} 123456123456.123e12
+% \\
+% \bottomrule
+%\end{tabular}\end{verbatim}
+% This produces:
+% \par\medskip\noindent
+%{\small
+%\begin{tabular}{lN{12}{3}n{12}{3}}
+% \toprule
+% normal:&
+% 123456123456.123e12&
+% 123456123456.123e12
+% \\
+% bold:&
+% {\fontseries{b}\selectfont} 123456123456.123e12&
+% {\npboldmath} 123456123456.123e12
+% \\
+% bold extended:&
+% {\bfseries} 123456123456.123e12&
+% {\boldmath} 123456123456.123e12
+% \\
+% \bottomrule
+%\end{tabular}}
+%\par\medskip
+%
+% If you want to add the same text or commands to all lines of a
+% tabular column, you can use the ``|>|'' specifier in the declaration
+% of the tabular column, as usual.
+% You have to enclose its argument in an additional pair of braces, as
+% shown in the example below.
+% Unfortunately, the ``|<|'' specifier does not work properly.
+% \DescribeMacro{\npafternum}
+% Therefore, the \cs{npafternum} command is defined that takes one
+% argument which is printed after the number.
+% The following example shows text before and after the number:
+% \begin{verbatim}
+%\begin{tabular}{%
+% >{{before \npafternum{ after}}}n[2]{12}{3}%
+% >{{\nprounddigits{4}}}n{3}{4}%
+% >{{\color{blue}}}n{12}{3}}
+% \toprule
+% 123456123456.123e12&
+% 12.12345&
+% 123456.23e1
+% \\
+% 12345.123e12&
+% 12.1&
+% 14561234.562e12
+% \\
+% \bottomrule
+%\end{tabular}\end{verbatim}
+% This produces:
+% \par\medskip\noindent
+%{\small
+%\begin{tabular}{%
+% >{{before \npafternum{ after}}}n[2]{12}{3}%
+% >{{\nprounddigits{3}}}n{3}{3}%
+% >{{\color{blue}}}n{8}{3}}
+% \toprule
+% 123456123456.123e12&
+% 12.12353&
+% 123456.23e1
+% \\
+% 12345.123e12&
+% 12.1&
+% 14561234.562e12
+% \\
+% \bottomrule
+%\end{tabular}}
+%\par\medskip
+% As can be seen in the second column, numbers can be rounded in
+% special columns by inserting \cs{nproundigits} into a ``|>|''
+% specification.
+% This can be said for all other commands that influence the format of
+% numbers, too.
+%
+% \DescribeMacro{\npunit}
+% Normally, units should not be typeset in the cells of a tabular.
+% But if this is needed, it may be realized using the \cs{npunit}
+% command, as shown here:
+% \begin{verbatim}
+%\begin{tabular}{>{{\npunit{N/mm^2}}}n{5}{3}}
+% \toprule
+% 12345.123\\
+% 12.12\\
+% {\npunit{psi}} 234.4\\
+% 4.3\\
+% \bottomrule
+%\end{tabular}\end{verbatim}
+% This produces:
+% \par\medskip\noindent
+%{\small
+%\begin{tabular}{>{{\npunit{N/mm^2}}}n{5}{3}}
+% \toprule
+% 12345.123\\
+% 12.12\\
+% {\npunit{psi}} 234.4\\
+% 4.3\\
+% \bottomrule
+%\end{tabular}}
+%\par\medskip
+%
+% The tabular alignment of the |numprint| package has been tested with
+% the |tabular|, |tabular*|, |array|, |tabularx|~\cite{carlisle1999a},
+% and |longtable|~\cite{carlisle2000a} environments.
+% It may or may not run with other packages and environments.
+%
+%
+% \subsection{The old column types}%
+% \label{sec:column:old}%
+%
+% \newcolumntype{m}[2]{>{\npdigits{#1}{#2}$}l<{$}}%
+% \newcolumntype{M}[3]{>{\npdigits{#1}{#2}\npexponentdigits{#3}$}l<{$}}%
+%
+% \DescribeMacro{column type N}
+% If the |oldcolumntype| package option is specified the column types
+% |n| and |N| are defined differently than described in the previous
+% section.
+% \DescribeMacro{column type n}
+% The |n| column type alignes the base number to the decimal sign, the
+% |N| column type additionaly alignes the exponent.
+%
+% Use these commands as follows:
+% \begin{verbatim}
+%\tabcolsep0mm
+%\begin{tabular}{|n{5}{3}|N{5}{3}{3}|}
+% \hline
+% \numprint{123.45e12}& \numprint{123.45e12}\\
+% \numprint{12345.678e123}& \numprint{12345.678e123}\\
+% \numprint{123.45e12.3}& \numprint{123.45e12.3}\\
+% \numprint{12345.678e123.3}& \numprint{12345.678e123.3}\\
+% \hline
+%\end{tabular}\end{verbatim}
+% This leads to\par\medskip\noindent
+% {\tabcolsep0mm
+% \begin{tabular}{|m{5}{3}|M{5}{3}{3}|}
+% \hline
+% \numprint{123.45e12}& \numprint{123.45e12}\\
+% \numprint{12345.678e123}& \numprint{12345.678e123}\\
+% \numprint{123.45e12.3}& \numprint{123.45e12.3}\\
+% \numprint{12345.678e123.3}& \numprint{12345.678e123.3}\\
+% \hline
+% \end{tabular}}
+% \medskip
+%
+% The first argument defines the number of digits before the decimal
+% sign, the second the number after.
+% In case of the type \verb|N| the third option defines the number of
+% digits before the decimal sign in the exponent.
+% It is not possible to define the numbers of digits after the decimal
+% sign in the exponent; they are set to zero.
+% Notice that the command \verb|\numprint| has to be written again in
+% each tabular entry, using the old column types.
+%
+%
+% \subsection{Alignment in normal text}%
+%
+% The alignment of the numbers in tabulars is realized by writing the
+% number inside a box with the specified width.
+% This functionality can also be used outside tabular environments.
+% \DescribeMacro{\npdigits}
+% The \cs{npdigits\marg{before}\marg{after}} command switches on the
+% alignment of numbers printed by \cs{numprint}.
+% The first argument defines the number of digits before the decimal
+% sign while the second argument defines the number of digits after
+% it for the mantissa.
+% \DescribeMacro{\npexponentdigits}
+% Since exponents are normally integer numbers the syntax of the
+% corresponding \cs{npexponentdigits} command is slightly different.
+% Its syntax is \cs{npexponentdigits\oarg{after}\marg{before}}.
+% The mandatory argument defines the number of digits before the
+% decimal sign of the exponent.
+% If no optional argument is given, the number of digits after the
+% decimal sign is set to zero.
+% If it is given it defines the number of digits after the decimal
+% sign.
+%
+% If the \cs{npdigits} or \cs{npexponentdigits} commands have been
+% used inside a group the values are reset at the end of the group.
+% \DescribeMacro{\npnodigits}
+% \DescribeMacro{\npnoexponentdigits}
+% Alignment can also be switched off using the \cs{npnodigits} resp.\
+% \cs{npnoexponentdigits} commands.
+%
+%
+% \section{Error messages etc.}
+%
+% By default, \cs{numprint} produces an error message if the argument
+% uses some invalid characters or if the number format is invalid.
+% Some people use \cs{numprint} to do strange things and thus use
+% invalid arguments designedly.
+% These people may switch off these error messages by using the
+% package option |warning|.
+%
+% If you want some debug messages to be written into the log file, use
+% the package option |debug|.
+%
+%
+% \section{Advanced customization}%
+% \label{sec:advanced}%
+%
+% \subsection{Changing the output}%
+%
+% Most of the things described in this section are not necessary to be
+% done by hand because the feature ``automatic language support'',
+% described in section~\ref{sec:international} does this
+% automatically.
+%
+% \subsubsection{Without the \textmd{\texttt{autolanguage}} option}
+%
+% \DescribeMacro{\npthousandsep}%
+% \DescribeMacro{\npthousandthpartsep}%
+% \DescribeMacro{\npdecimalsign}%
+% \DescribeMacro{\npproductsign}%
+% By using the commands
+% \cs{npdecimalsign\marg{Sign}},
+% \cs{npthousandsep\marg{Separator}},
+% \cs{npthousandthpartsep\marg{Separator}}, and
+% \cs{npproductsign\marg{Sign}},\footnote{These command did
+% not have the
+% ``np'' in older versions. This had to be changed in order to avoid
+% an incompatibiliby with the french language of babel.} several
+% separators and symbols can be changed, e.g.,
+% \begin{verbatim}
+%\npdecimalsign{\ensuremath{\cdot}}\npthousandsep{,}\npproductsign{*}%
+%\numprint{-123456}; \numprint{3,1415927e-3.2}\end{verbatim}
+% leads to ``{\npdecimalsign{\ensuremath{\cdot}}%
+% \npthousandsep{,}\npproductsign{*}%
+% \numprint{-123456}; \numprint{3,1415927e-3.2}}''.
+%
+% The \cs{npthousandsep} both changes the separators before and after
+% the decimal sign.
+% If you want to use different separators, you have to call
+% \cs{npthousandthpartsep} \emph{after} \cs{npthousandsep}.
+%
+% The separators as well as the decimal sign are typeset in the same
+% mode as the number itself (math or text).
+% If you want to guarantee a special mode, you have to use
+% \cs{ensuremath} for math or either \cs{mbox}, \cs{textrm}, or
+% \cs{text}\footnote{Provided by \texttt{amsmath}.} for text mode.
+%
+% The product sign, in contrast, is always printed in math mode.
+% Thus, you don't have to add \cs{ensuremath} to use math commands.
+%
+% \DescribeMacro{\global}%
+% If using these commands inside a group (|{|\ldots|}|,
+% \cs{begingroup}\ldots\cs{endgroup}, or an environment)
+% the behaviour of the \verb|\numprint| command is changed
+% only locally (inside the current group).
+% By preceding \verb|\global| the change can be made global inside a
+% group.
+% For example:
+% \begin{verbatim}
+%Local:
+%\numprint{123e4},
+%{\npproductsign{\cdot}\numprint{123e4}},
+%\numprint{123e4}.
+%Global:
+%\numprint{123e4},
+%{\global\npproductsign{\cdot}\numprint{123e4}},
+%\numprint{123e4}\end{verbatim}
+% leads to the following:
+%
+% \noindent Local:
+% \numprint{123e4},
+% {\npproductsign{\cdot}\numprint{123e4}},
+% \numprint{123e4}.
+% Global:
+% \numprint{123e4},
+% {\npproductsign{\cdot}\numprint{123e4},
+% \numprint{123e4}}
+%
+% The current version has the following defaults:
+% \begin{verbatim}
+%\npthousandsep{\,}
+%\npdecimalsign{,}
+%\npproductsign{\cdot}
+%\npunitseparator{\,}\end{verbatim}
+%
+% \DescribeMacro{\npunitseparator}%
+% The space between the number and the unit is ``\cs{,}'' by
+% default. It can be changed using the command
+% \cs{npunitseparator\marg{Separator}},
+% e.g.,
+% \begin{verbatim}
+%\npunitseparator{~}\end{verbatim}
+%
+% \DescribeMacro{\npdegreeseparator}%
+% By default, no space is added between the number an a degree symbol.
+% You may specify a separator for that using
+% \cs{npdegreeseparator\marg{Separator}}.
+%
+% \DescribeMacro{\nppercentseparator}%
+% By default, the same space as for normal units is added between the
+% number an a percent sign.
+% You may specify a different separator for that using
+% \cs{nppercentseparator\marg{Separator}}.
+%
+%
+%
+% \subsubsection{With the \textmd{\texttt{autolanguage}} option}%
+% \label{sec:advanced:international}%
+%
+% If you are using the |autolanguage| option changes made with the
+% commands described in the previous section get lost at the next
+% change of the language or at \cs{begin\{document\}}.
+% Thus, they cannot be used with this option in the way described
+% there.
+%
+% Thus, you have to redefine the commands that set the
+% language-dependent numprint settings.
+% For each known language, a command \cs{npstyle\meta{language}} is
+% defined that does the changes, e.g., \cs{npstyleenglish} for
+% English.
+% \DescribeMacro{\npstyleenglish}
+% This command is defined as follows:
+% \begin{verbatim}
+%\newcommand*\npstyleenglish{%
+% \npthousandsep{,}%
+% \npdecimalsign{.}%
+% \npproductsign{\times}%
+% \npunitseparator{\,}%
+% \npdegreeseparator{}%
+% \nppercentseparator{\nprt@unitsep}%
+%}\end{verbatim}
+%
+% If you want to use different settings for this language, you have
+% two possibilities:
+% \begin{enumerate}
+% \item
+% Copy the definition for \cs{npstyle\meta{language}} from the style
+% file and change it according to your wishes, for
+% example:\footnote{Notice that you have to use \cs{renewcommand*}
+% instead of \cs{newcommand*}.}
+% \begin{verbatim}
+%\renewcommand*\npstyleenglish{%
+% \npthousandsep{,}%
+% \npdecimalsign{{\cdot}}%
+% \npproductsign{\times}%
+% \npunitseparator{\,}%
+% \npdegreeseparator{}%
+% \nppercentseparator{\nprt@unitsep}%
+%}\end{verbatim}
+% \item
+% Another way to add different settings to a language is to use
+% \cs{g@addto@macro} to append commands to an existing
+% \cs{npstyle\meta{language}} command, e.g.,
+% \begin{verbatim}
+%\makeatletter
+%\g@addto@macro\npstyleenglish{%
+% \nppercentseparator{}%
+%}%
+%\makeatother\end{verbatim}
+% This has the advantage that changes in the original command are not
+% lost by using a copy.
+% The disadvantage is that some commands may be called twice which is
+% slightly slower.
+% \end{enumerate}
+% The changes take effect when the style command is called the next
+% time; this is when the language is changed the next time or at
+% \cs{begin\{document\}}.
+%
+%
+% If the language you are using is not yet supported by |numprint| you
+% may add support for it in the preamble of your document.
+%
+% \DescribeMacro{\npaddtolanguage}
+% The simplest case is a language that uses the same settings as one
+% of the languages, already supported.
+% If, for instance, you want to use Danish with the same settings as
+% German, you just have to add
+% \begin{verbatim}
+%\npaddtolanguage{danish}{german}\end{verbatim}
+% to the preamble of your document.
+%
+% If you, instead, want to use different settings, define a
+% corresponding style command.
+% Let's take Danish as an example, again.
+% Define a command \cs{npstyledanish} which defines
+% everything you want to change against the default (I choose some
+% strange values for clearness):
+% \begin{verbatim}
+%\newcommand*\npstyledanish{%
+% \npthousandsep{.}%
+% \npdecimalsign{\ensuremath{\cdot}}%
+% \npproductsign{*}%
+% \npunitseparator{~}%
+% \npdegreeseparator{}%
+% \nppercentseparator{\nprt@unitsep}%
+%}\end{verbatim}
+% In addition, append the call of this command to the
+% language-switching command for Danish:
+% \begin{verbatim}
+%\npaddtolanguage{danish}{danish}\end{verbatim}
+%
+%
+% \subsection{Changing the argument parsing}%
+% \label{sec:custom-parsing}%
+%
+% It has been said above that thousand separators are not allowed in
+% the argument of the \cs{numprint} command.
+% This can be customized by the user.
+%
+% For most elements in the input, \cs{numprint} uses lists that
+% contain the corresponding characters.
+% \DescribeMacro{\nprt@dotlist}
+% The macro \cs{nprt@dotlist} contains the characters interpreted as
+% decimal signs.
+% It is defined as followed:
+% \begin{verbatim}
+%\newcommand*\nprt@dotlist{.,}\end{verbatim}
+% If you, for example, only want to allow the dot as decimal sign,
+% redefined the list:
+% \begin{verbatim}
+%\renewcommand*\nprt@dotlist{.}\end{verbatim}
+% If you want to do this in your document rather than in the
+% configureation file \texttt{numprint.cfg}---see
+% section~\ref{sec:configuration}--- you have to enclose this by
+% \cs{makeatletter} and \cs{makeatother}.
+%
+% \DescribeMacro{\nprt@explist}%
+% The \cs{nprt@explist} command contains the characters interpreted as
+% delimiter between mantissa and exponent.
+% By default it contains ``\texttt{eEdD}''.
+% Redefine it as \cs{nprt@dotlist}.
+%
+% \DescribeMacro{\nprt@ignorelist}%
+% The \cs{nprt@ignorelist} command contains a list of characters that
+% are ignored in the input (in addition to spaces, ``\cs{,}'', and
+% ``\texttt{\~}'').
+% It is empty by default.
+% If you, for example, only want to allow dots as decimal sign and
+% commas may occur as thousand separators in the input, you may use
+% following redefinition:
+% \begin{verbatim}
+%\renewcommand*\nprt@dotlist{.}
+%\renewcommand*\nprt@ignorelist{,}\end{verbatim}
+% Then, ``\texttt{,}'' is ignored in the input and ``\texttt{.}'' is
+% interpreted as decimal sign.
+% For example,
+% \begin{verbatim}
+%\makeatletter
+%{\renewcommand*\nprt@dotlist{.}%
+%\renewcommand*\nprt@ignorelist{,}%
+%\numprint{12,234.123,45e1,2,3.0}}
+%\makeatother\end{verbatim}
+% leads to
+% \makeatletter%
+% {\def\nprt@dotlist{.}\def\nprt@ignorelist{,}``\numprint{12,234.123,45e1,2,3.0}}''.
+% \makeatother
+%
+% \DescribeMacro{\nprt@signlist}%
+% The \cs{nprt@signlist} command contains the list of known signs.
+% By default, it is set to ``\texttt{+-}\cs{pm}''.
+% You may change the list of accepted signs by redefining
+% \cs{nprt@signlist}.
+% If, for instance, the letter ``\texttt{*}'' is intended to be a
+% sign, just type in
+% \begin{verbatim}
+%\renewcommand*\nprt@signlist{+-\pm *}\end{verbatim}
+% This character is typeset when using it as sign.
+% But this indicates one problem: The sign might differ between text
+% and math mode, as show in the following example:
+% {\makeatletter\def\nprt@signlist{+-\pm *}\makeatother
+% In text mode, \cs{numprint\{*1234\}} occurs as ``\numprint{*1234}''
+% while is is typeset as ``$\numprint{*1234}$'' in math mode.}
+% To avoid that, you may define a command that prints the sign.
+% This command must have a name according to
+% \cs{nprt@list@\meta{sign}}.
+% \DescribeMacro{\nprt@sign@*}%
+% In this case, you have to define \cs{nprt@list@*}.
+% Since the sign might be arbitrary characters, you should define the
+% command as follows:
+% \begin{verbatim}
+%\expandafter\newcommand\csname nprt@sign@*\endcsname{\ensuremath{*}}\end{verbatim}
+% {\makeatletter\expandafter\def\csname nprt@sign@*\endcsname{\ensuremath{*}}%
+% \def\nprt@signlist{+-\pm *}\makeatother
+% With this command, \cs{numprint\{*1234\}} occurs as
+% ``\numprint{*1234}'' in text mode and as ``$\numprint{*1234}$'' in
+% math mode.}
+%
+% Because of this mechanism to print a sign, it is not possible to use
+% other macro names than \cs{pm} for signs.\footnote{\cs{pm} is
+% handled separately.}
+% You have to use single characters as the shown ``\texttt{*}''.
+%
+%
+% \section{Some tricks}
+%
+% \subsection{Let the signs depend on the mode}
+%
+% \DescribeMacro{\nprt@sign@+}%
+% \DescribeMacro{\nprt@sign@-}%
+% \DescribeMacro{\nprt@sign@+-}%
+% The default signs are typeset in math mode independently of the mode
+% the number ist printed.
+% If you are using a font in which the sings of text and math mode
+% differ much, this may be unsatisfactory.
+% Then, you can typeset different signs for text and math mode.
+% Therefore, it is used that the default signs use the same macros as
+% user signs, described in section~\ref{sec:custom-parsing}.
+% They are defined as follows:
+% \begin{verbatim}
+%\expandafter\newcommand\csname nprt@sign@+\endcsname{\ensuremath{+}}
+%\expandafter\newcommand\csname nprt@sign@-\endcsname{\ensuremath{-}}
+%\expandafter\newcommand\csname nprt@sign@+-\endcsname{\ensuremath{\pm}}\end{verbatim}
+% If you, for instance, don't want to use the math minus for numbers
+% in text mode but another character, you may redefine
+% \cs{nprt@sign@-}:
+% \begin{verbatim}
+%\expandafter\renewcommand\csname nprt@sign@-\endcsname{%
+% \ifmmode -\else ---\fi}\end{verbatim}
+%{\makeatletter\expandafter\def\csname nprt@sign@-\endcsname
+% {\ifmmode -\else---\fi}\makeatother
+% With this definition, \cs{numprint\{-1234\}} leads to
+% ``\numprint{-1234}'' resp.\ ``$\numprint{-1234}$'' in text resp.\
+% math mode.}
+%
+%
+% \subsection{Typing negative numbers in red}%
+% \label{sec:negative-red}%
+%
+% If you want to print negative number in red colors, you can use the
+% \cs{nprt@sign@-} command, too.
+% The following example shows how to do it:
+% \begin{verbatim}
+%\usepackage{color}
+%\makeatletter
+%\expandafter\renewcommand\csname nprt@sign@-\endcsname{%
+% \color{red}\ensuremath{-}}
+%\makeatother\end{verbatim}
+% With this definition,
+% \begin{verbatim}
+%\numprint{1234}, \numprint{-1234},
+%\numprint{1234e-123}, \numprint{-1234e123}.\end{verbatim}
+% {\makeatletter\expandafter\def\csname nprt@sign@-\endcsname
+% {\color{red}\ensuremath{-}}\makeatother
+% leads to ``\numprint{1234}, \numprint{-1234}, \numprint{1234e-123},
+% \numprint{-1234e123}.''}\footnote{Wheather you can see the effect in
+% the output depends on the viewer; in PostScript and PDF the red
+% color works, in many dvi viewers, it doesn't.}
+% To avoid a negative exponent beeing printed in red for a positive
+% mantissa, a hack is included in the page which is described in
+% appendix~\ref{sec:code:main}, page~\pageref{page:code:color}.
+%
+%
+%
+% \subsection{Configuration file}%
+% \label{sec:configuration}%
+%
+% If your \LaTeX\ installation provides a file \texttt{numprint.cfg}
+% in the \TeX\ search path, it is loaded by \texttt{numprint.sty} as
+% last action.
+% Thus, you may add all changes and extensions, new languages for
+% instance, into this file.
+%
+%
+% \appendix
+%
+% \section{Compatiblity to older versions}
+%
+% In most cases, the user macros of this package (the macros not
+% containing a ``|@|'' in their name) should be compatible to older
+% versions.
+% The parsing of the argument has been improved that some arguments of
+% \cs{numprint} may be accepted or not in contrast to the older
+% version.
+%
+% The spacing of aligned numbers has also been corrected.
+% Thus, this is be incompatible to the older version if you are using
+% alignment in the exponent or math environmens other than
+% \cs{textstyle}.
+%
+%
+% \section{Lists of options and commands}
+%
+% This section contains lists of all package options resp.\ available
+% commands.
+% Items that belong together and may be exclusive are printed in
+% groups together.
+%
+% \subsection{Package options}%
+% \label{sec:package-options}%
+%
+% \begingroup
+% \newcommand*\default{$^{*}$}%
+% The default values are marked by \default.
+% \begin{longtable}[l]{%
+% @{}>{\ttfamily}p{0.30\linewidth}@{}p{0.70\linewidth}@{}}
+% warning& Produce warnings rather than error messages. \\
+% error\default& Produce warnings rather than error
+% messages. \\[\medskipamount]
+% autolanguage& Switch the settings language dependent.\\
+% noautolanguage\default& Fixed settings.\\[\medskipamount]
+% sepfour\default& Separator for four-digit numbers.\\
+% nosepfour& No separator for four-digit numbers.\\[\medskipamount]
+% addmissingzero\default& Add missings zeros before or after the
+% decimal sign.\\
+% noaddmissingzero& Don't do that.\\[\medskipamount]
+% addplus& Add a plus to a number without a sign.\\
+% noaddplus\default& Don't do that.\\[\medskipamount]
+% addplusexponent& Add a plus to a number without a sign.\\
+% noaddplusexponent\default& Don't do that.\\[\medskipamount]
+% oldcolumntypes& Define the old column types that need to use the
+% \cs{numprint} inside the tabular.\\
+% newcolumntypes\default& Use the new column types.\\[\medskipamount]
+% boldmath& Define the \texttt{npbold} math version.\\[\medskipamount]
+% np& Define the shortcut \cs{np} for
+% \cs{numprint}.\\[\medskipamount]
+% debug& Produce debug information in the log file.
+% \end{longtable}
+% \endgroup
+%
+% \subsection{Commands}
+%
+% \begin{longtable}[l]{%
+% @{}>{\ttfamily \char`\\}p{0.3\linewidth}@{}p{0.7\linewidth}@{}}
+% npfourdigitsep& Switch on separating four-digit numbers.\\
+% npfourdigitnosep& Switch off separating four-digit
+% numbers.\\[\medskipamount]
+% npaddmissingzero& Switch on adding missings zeros before or after the
+% decimal sign.\\
+% npnoaddmissingzero& Switch off adding missings zeros before or after
+% the decimal sign.\\[\medskipamount]
+% npaddplus& Add a plus to a number without a sign.\\
+% npnoaddplus& Don't do that.\\[\medskipamount]
+% npaddplusexponent& Add a plus to the exponent when it has no sign.\\
+% npnoaddplusexponent& Don't do that.\\[\medskipamount]
+% np& Shortcut for \cs{numprint} (only available with package
+% option~\texttt{np}).\\
+% numprint& Typesets a number (the package's main
+% command).\\[\medskipamount]
+% npdecimalsign& Change the decimal sign.\\
+% npthousandsep& Change the thousand separator (before and after the
+% decimal sign).\\
+% npthousandspartsep& Change the thousand separator (only after the
+% decimal sign).\\
+% npproductsign& Change the product sign.\\
+% npunitseparator& Change the separator between a number and a
+% unit.\\
+% npdegreeseparator& Change the separator between a number and a
+% degree symbol.\\[\medskipamount]
+% nppercentseparator& Change the separator between a number and a
+% percent sign.\\[\medskipamount]
+% nprounddigits& Declare how many digits will be printed after the
+% decimal sign.\\
+% npnoround& Switch off rounding and print numbers as given.\\
+% nproundexpdigits& Declare how many digits will be printed after the
+% decimal sign in the exponent.\\
+% npnoroundexp& Switch off rounding for the
+% exponent.\\[\medskipamount]
+% nplpadding& Declare up to how many digits the number will be padded at
+% the lefthand side. \\
+% npnolpadding& Switch off padding. \\[\medskipamount]
+% npreplacenull& Replace the after-decimal-sign part by another text
+% if it is zero.\\
+% npprintnull& Print zeros after the decimal sign.\\[\medskipamount]
+% npdigits& Switch on aligned number printing with given digits before
+% and after the decimal sign.\\
+% npnodigits& Print numbers in a box that is as wide as needed by the
+% number.\\
+% npexponentdigits& Switch on aligned printing of the exponent.\\
+% npnoexponentdigits& Switch alignment off for the
+% exponent.\\[\medskipamount]
+% npaddtolanguage& Adds language definitions to the extras section
+% of a \texttt{babel} language.\\
+% npstyledefault& Defines the settings in standard format.\\
+% npstylegerman& Defines the German number format.\\
+% npstyleenglish& Defines the English number
+% format.\\[\medskipamount]
+% npmakebox& Command similar to \cs{makebox} but with text instead
+% of length in first optional argument.\\[\medskipamount]
+% npboldmath& Bold math version with digits with the same width as
+% normal digits.\\[\medskipamount]
+% npafternum& Puts text after the number in
+% tabulars.\\[\medskipamount]
+% npunit& Sets the unit in tabulars.\\[\medskipamount]
+% \end{longtable}
+%
+% \section{Known bugs}
+%
+% \begin{itemize}
+% \item When aligning the exponent for tabulars, the distance between
+% the ``10'' and the exponent is too small.
+% \end{itemize}
+%
+% \section{To do}
+%
+% \begin{itemize}
+% \item Add more languages to the automatic international support.
+% \item Add support for ``|<|'' in tabular definitions.
+% \item Avoid many of the temporary variables.
+% \item Add support for numbers in tabulars that are right aligned or
+% centered.
+% \end{itemize}
+%
+% \section{Acknowledgements}
+%
+% \begin{itemize}
+% \item
+% Tilman Finke, tfinke@it-and-law.de, had the idea of rounding
+% numbers.
+% \item
+% Stephan Helma, s.p.helma@gmx.net, has implemented padding
+% numbers on the left side.
+% This function has been slightly changed by me.
+% \item
+% Portuguese support by Vilar Camara Neto and Luis.
+% \end{itemize}
+%
+% \begin{thebibliography}{1}
+% \bibitem{carlisle1999a}
+% Carlisle, David: \emph{The \texttt{tabularx} package},
+% version~2.07, 1999.\newblock
+% \url{CTAN:macros/latex/contrib/tabularx/}.
+% \bibitem{carlisle2000a}
+% Carlisle, David: \emph{The \texttt{longtable} package},
+% version~4.10, 2000.\newblock
+% \url{CTAN:macros/latex/contrib/longtable/}.
+% \bibitem{guthoehrlein2000a}
+% Guth\"ohrlein, Eckhart: \emph{The \texttt{rccol} package},
+% version~1.1a, 2000.\newblock
+% \url{CTAN:macros/latex/contrib/rccol/}.
+% \end{thebibliography}
+%
+% \StopEventually{\PrintChanges \PrintIndex}
+%
+% \section{The implementation}
+% \iffalse
+%<*package>
+% \fi
+% Heading of the package:
+% \begin{macrocode}
+\NeedsTeXFormat{LaTeX2e}
+\ProvidesPackage{numprint}
+ [2005/07/11 v1.35 Print numbers (HH)]
+% \end{macrocode}
+%
+% \subsection{Load packages}
+%
+% \changes{1.33}{2004/11/19}{Avoid to use the \texttt{calc} package
+% since it causes problems with many other packages}%
+%
+% Load package array.sty for the new column types.
+% \begin{macrocode}
+\RequirePackage{array}
+% \end{macrocode}
+% \changes{1.10}{2003/10/12}{Avoid use of \texttt{substr} package}%
+%
+% \subsection{Package options and settings}
+%
+% Define a boolean if the first digit is separated in a four digit
+% number. Default is true for compatibility with older versions.
+% \begin{macrocode}
+\newif\ifnprt@numsepfour
+% \end{macrocode}
+% Show warnings or errors?
+% \begin{macrocode}
+\newif\ifnprt@errormessage
+% \end{macrocode}
+% Add missing zeros?
+% \begin{macrocode}
+\newif\ifnprt@addmissingzero
+% \end{macrocode}
+% Add missing plus signs?
+% \begin{macrocode}
+\newif\ifnprt@addplus@mantissa
+\newif\ifnprt@addplus@exponent
+% \end{macrocode}
+% Switch the style depending on the language automatically?
+% \begin{macrocode}
+\newif\ifnprt@autolanguage
+% \end{macrocode}
+% Old or new column types?
+% \begin{macrocode}
+\newif\ifnprt@newcolumntype
+% \end{macrocode}
+% Declare new math type?
+% \begin{macrocode}
+\newif\ifnprt@npbold
+% \end{macrocode}
+% \begin{macro}{\npfourdigitsep}
+% Switch separating of the fourth digit on.
+% \begin{macrocode}
+\newcommand*\npfourdigitsep{\nprt@numsepfourtrue}%
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\npfourdigitnosep}
+% Switch separating of the fourth digit off.
+% \begin{macrocode}
+\newcommand*\npfourdigitnosep{\nprt@numsepfourfalse}%
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\npaddmissingzero}
+% Add a missing zero before or after decimalsign.
+% \begin{macrocode}
+\newcommand*\npaddmissingzero{\nprt@addmissingzerotrue}%
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\npnoaddmissingzero}
+% Don't add a missing zero before or after decimalsign.
+% \begin{macrocode}
+\newcommand*\npnoaddmissingzero{\nprt@addmissingzerofalse}%
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\npaddplus}
+% Add a plus to the mantissa if no sign is given.
+% \begin{macrocode}
+\newcommand*\npaddplus{\nprt@addplus@mantissatrue}%
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\npnoaddplus}
+% Don't add a plus to the mantissa if no sign is given.
+% \begin{macrocode}
+\newcommand*\npnoaddplus{\nprt@addplus@mantissafalse}%
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\npaddplusexponent}
+% Add a plus to the exponent if no sign is given.
+% \begin{macrocode}
+\newcommand*\npaddplusexponent{\nprt@addplus@exponenttrue}%
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\npnoaddplusexponent}
+% Don't add a plus to the exponent if no sign is given.
+% \begin{macrocode}
+\newcommand*\npnoaddplusexponent{\nprt@addplus@exponentfalse}%
+% \end{macrocode}
+% \end{macro}
+% Declare options. \verb|nosepfour| switches seperating of the fourth
+% digit off, \verb|sepfour| switches it on. Default is on four
+% compatibility reasons with older versions.
+% \begin{macrocode}
+\DeclareOption{nosepfour}{\npfourdigitnosep}
+\DeclareOption{sepfour}{\npfourdigitsep}
+% \end{macrocode}
+% Add missing zeros after decimal sign?
+% \begin{macrocode}
+\DeclareOption{noaddmissingzero}{\npnoaddmissingzero}
+\DeclareOption{addmissingzero}{\npaddmissingzero}
+% \end{macrocode}
+% Add a plus sign to the mantissa if no sign is given?
+% \begin{macrocode}
+\DeclareOption{noaddplus}{\npnoaddplus}
+\DeclareOption{addplus}{\npaddplus}
+% \end{macrocode}
+% Add a plus sign to the exponent if no sign is given?
+% \begin{macrocode}
+\DeclareOption{noaddplusexponent}{\npnoaddplusexponent}
+\DeclareOption{addplusexponent}{\npaddplusexponent}
+% \end{macrocode}
+% Add missing zeros after decimal sign?
+% \begin{macrocode}
+\DeclareOption{noautolanguage}{\nprt@autolanguagefalse}
+\DeclareOption{autolanguage}{\nprt@autolanguagetrue}
+% \end{macrocode}
+% \begin{macro}{\np}
+% \changes{1.00}{2003/10/07}{Add shortcut for \cs{numprint}}%
+% Define a shortcut for the \cs{numprint} command?
+% \begin{macrocode}
+\DeclareOption{np}{\newcommand*\np{\numprint}}
+% \end{macrocode}
+% \end{macro}
+% Produce warnings or errors?
+% \begin{macrocode}
+\DeclareOption{oldcolumntypes}{\nprt@newcolumntypefalse}
+\DeclareOption{newcolumntypes}{\nprt@newcolumntypetrue}
+% \end{macrocode}
+% Declare new math type?
+% \begin{macrocode}
+\DeclareOption{boldmath}{\nprt@npboldtrue}
+% \end{macrocode}
+% Produce warnings or errors?
+% \begin{macrocode}
+\DeclareOption{warning}{\nprt@errormessagefalse}
+\DeclareOption{error}{\nprt@errormessagetrue}
+% \end{macrocode}
+% Generate some debug information to the log file?
+% \begin{macrocode}
+\newcommand*\nprt@debug[1]{}
+\DeclareOption{debug}{%
+ \renewcommand*\nprt@debug[1]{\PackageInfo{numprint}{#1}}%
+}
+% \end{macrocode}
+% Execute default options and the given options.
+% \begin{macrocode}
+\ExecuteOptions{sepfour,addmissingzero,error,noautolanguage,newcolumntypes}
+\ProcessOptions\relax
+% \end{macrocode}
+% Define commands to change the output of the \verb|\numprint|
+% command.
+%
+% \begin{macro}{\npdecimalsign}
+% Change the decimal sign. In English it is normally ``.'', in German
+% ``,''.
+% The additional pair of braces \verb|{}| prevents from inserting
+% additional space in math mode, e.g., $1,2$ versus $1{,}2$.
+% \begin{macrocode}
+\newcommand*\npdecimalsign[1]{\def\nprt@decimal{{#1}}}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\npthousandsep}
+% Change the thousand separator. In English it often is ``,'', in
+% German ``.'' or ``\,'' (\verb|\,|).
+% Here again the additional \verb|{}| is used as above.
+% This command changes both the sign before and after the decimal
+% sign.
+% If you want a different sign after the comma you have to call
+% \verb|\npthousandthpartsep| after \verb|\npthousandsep|.
+% \begin{macrocode}
+\newcommand*\npthousandsep[1]{\def\nprt@separator@before{{#1}}%
+ \def\nprt@separator@after{{#1}}}
+% \end{macrocode}
+% \end{macro}%
+% \begin{macro}{\npthousandthpartsep}
+% Change the thousand separator after the decismal sign.
+% \begin{macrocode}
+\newcommand*\npthousandthpartsep[1]{\def\nprt@separator@after{{#1}}}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\npproductsign}
+% Change the product sign that is printed in numbers with exponent
+% like $\numprint{123e4}$. Normally it is \verb|\cdot|. In American
+% texts sometimes \verb|\times|.
+% The two pairs of braces \verb|{}| ensure the correct spacing on the
+% left and right side of the product sign, e.g., 3$\cdot$4 versus
+% 3${}\cdot{}$4.
+% \begin{macrocode}
+\newcommand*\npproductsign[1]{\def\nprt@prod{\ensuremath{{}#1{}}}}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\npunitseparator}
+% Change the separator between number an unit.
+% Here again the additional \verb|{}| is used as above.
+% \begin{macrocode}
+\newcommand*\npunitseparator[1]{\def\nprt@unitsep{{#1}}}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\npdegreeseparator}
+% Change the separator between number an unit.
+% Here again the additional \verb|{}| is used as above.
+% \begin{macrocode}
+\newcommand*\npdegreeseparator[1]{\def\nprt@degreesep{{#1}}}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\nppercentseparator}
+% Change the separator between number an unit.
+% Here again the additional \verb|{}| is used as above.
+% \begin{macrocode}
+\newcommand*\nppercentseparator[1]{\def\nprt@percentsep{{#1}}}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\nprt@fillnull}
+% Defines command |#1| with a number of |#2| zeros filled.
+% This should reside in Sect.~\ref{sec:code:round} but is called
+% before.
+% \begin{macrocode}
+\def\nprt@fillnull#1#2{%
+ \@tempcnta=-1
+ \loop
+ \g@addto@macro{#1}{0}%
+ \advance\@tempcnta by 1
+ \ifnum\@tempcnta<#2
+ \repeat
+}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\nprounddigits}
+% Define a command that sets a count of digits after which the number
+% is rounded.
+% This command defines \cs{nprt@rounddigits} that stores the count and
+% \cs{nprt@roundnull} that contains of \cs{nprt@rounddigits} ``0''
+% digits.
+% \begin{macrocode}
+\newcommand\nprounddigits[1]{%
+ \def\nprt@rounddigits{#1}%
+ \def\nprt@roundnull{}%
+ \nprt@fillnull{\nprt@roundnull}{#1}%
+}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\npnoround}
+% A command to switch off rounding.
+% \begin{macrocode}
+\newcommand\npnoround{\nprounddigits{-1}}
+% \end{macrocode}
+% \end{macro}
+% Don't round by default.
+% \begin{macrocode}
+\npnoround
+% \end{macrocode}
+% \begin{macro}{\nproundexpdigits}
+% \begin{macro}{\npnoroundexp}
+% The same for exponents.
+% \begin{macrocode}
+\newcommand\nproundexpdigits[1]{%
+ \def\nprt@roundexpdigits{#1}%
+ \def\nprt@roundexpnull{}%
+ \nprt@fillnull{\nprt@roundexpnull}{#1}%
+ }
+\newcommand\npnoroundexp{\nproundexpdigits{-1}}
+\npnoroundexp
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+% \begin{macro}{\nplpadding}
+% This command sets the total counts of digits a number should contain.
+% The missing digits are filled with the character from the second
+% argument (which is 0 by default).
+% \begin{macrocode}
+\newcommand\nplpadding[2][0]{%
+ \def\nprt@lpaddigits{#2}%
+ \def\nprt@lpadchar{#1}%
+}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\npnolpadding}
+% The command to switch of padding.
+% \begin{macrocode}
+\newcommand*\npnolpadding{\nplpadding[\@empty]{-1}}
+% \end{macrocode}
+% \end{macro}
+% Don't pad by default.
+% \begin{macrocode}
+\npnolpadding
+% \end{macrocode}
+% \begin{macro}{\npreplacenull}
+% Optionally, one or more zeros after the decimal sign can be replaced
+% by other text, e.g., ``---'''.
+% \begin{macrocode}
+\newcommand*\npreplacenull[1]{\def\nprt@replacenull{#1}}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\npprintnull}
+% Switch off replacement, again.
+% \begin{macrocode}
+\newcommand*\npprintnull{\let\nprt@replacenull=\@empty}
+% \end{macrocode}
+% \end{macro}
+% Print the zero by default.
+% \begin{macrocode}
+\npprintnull
+% \end{macrocode}
+% \begin{macro}{\npunitcommand}
+% This command is used to typeset the unit.
+% \begin{macrocode}
+\newcommand*\npunitcommand[1]{\ensuremath{\mathrm{#1}}}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\npdigits}
+% With this command the user can switch to aligned printing.
+% The first parameter stands for the digits before the decimal sign
+% and the second for the digits after it.
+% \begin{macrocode}
+\newif\ifnprt@mantissa@fixeddigits
+\newcommand*\npdigits[2]{%
+ \edef\nprt@mantissa@fixeddigits@before{#1}%
+ \edef\nprt@mantissa@fixeddigits@after{#2}%
+ \nprt@mantissa@fixeddigitstrue
+}
+% \end{macrocode}
+% Initialize the numbers.
+% \begin{macrocode}
+\def\nprt@mantissa@fixeddigits@before{-1}%
+\def\nprt@mantissa@fixeddigits@after{-1}%
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\npnodigits}
+% Switch back to normal printing.
+% \begin{macrocode}
+\newcommand*\npnodigits{\nprt@mantissa@fixeddigitsfalse}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\npexponentdigits}
+% With this command the user can switch to aligned printing of the
+% exponent.
+% The parameter stands for the digits before the decimal sign.
+% \begin{macrocode}
+\newif\ifnprt@exponent@fixeddigits
+\newcommand*\npexponentdigits[2][0]{%
+ \edef\nprt@exponent@fixeddigits@before{#2}%
+ \edef\nprt@exponent@fixeddigits@after{#1}%
+ \nprt@exponent@fixeddigitstrue
+}
+% \end{macrocode}
+% Initialize the numbers.
+% \begin{macrocode}
+\def\nprt@exponent@fixeddigits@before{-1}%
+\def\nprt@exponent@fixeddigits@after{-1}%
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\npnoexponentdigits}
+% Switch back to normal printing.
+% \begin{macrocode}
+\newcommand*\npnoexponentdigits{\nprt@exponent@fixeddigitsfalse}
+% \end{macrocode}
+% \end{macro}
+%
+%
+% \subsection{Error and warning messages}
+%
+% Define a boolean which helps \cs{numprint} to detect errors.
+% \begin{macrocode}
+\newif\ifnprt@argumenterror
+% \end{macrocode}
+% \begin{macro}{\nprt@error}
+% Define \cs{nprt@error\marg{Message}\marg{Help text}} which prints
+% a warning resp.\ an error message, depending on the package options
+% |warning| and |error|.
+% \begin{macrocode}
+\newcommand\nprt@error[2]{%
+ \ifnprt@errormessage
+ \PackageError{numprint}{#1}{#2}%
+ \else
+ \PackageWarning{numprint}{#1}%
+ \fi
+% \end{macrocode}
+% The boolean is set to ``true''.
+% Then, \cs{numprint} knows that an error occured.
+% \begin{macrocode}
+ \nprt@argumenterrortrue
+}
+% \end{macrocode}
+% \end{macro}
+%
+%
+% \subsection{String parsing}
+%
+% \changes{1.10}{2003/10/12}{Avoid use of \texttt{substr} package}%
+% The \cs{IfCharInString} package does not work in the tabular
+% alignment context.
+% Thus, define an own command \cs{nprt@IfCharInString} that does the
+% same.
+% \begin{macro}{\nprt@charfound}
+% \begin{macrocode}
+\newif\ifnprt@charfound
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\nprt@IfCharInString}
+% ????
+% \begin{macrocode}
+\newcommand*\nprt@IfCharInString[2]{%
+ \nprt@charfoundfalse
+ \begingroup
+ \def\nprt@searchfor{#1}%
+ \edef\nprt@argtwo{#2}%
+ \expandafter\nprt@@IfCharInString\nprt@argtwo\@empty\@empty
+ \endgroup
+ \ifnprt@charfound
+ \expandafter\@firstoftwo
+ \else
+ \expandafter\@secondoftwo
+ \fi
+}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\nprt@@IfCharInString}
+% ????
+% \begin{macrocode}
+ \def\nprt@@IfCharInString#1#2\@empty{%
+ \def\nprt@argone{#1}%
+ \edef\nprt@argtwo{#2}%
+ \ifx\nprt@searchfor\nprt@argone
+ \global\nprt@charfoundtrue
+ \else
+ \ifx\nprt@argtwo\@empty
+ \else
+ \nprt@@IfCharInString#2\@empty
+ \fi
+ \fi
+ }
+% \end{macrocode}
+% \end{macro}
+%
+%
+% \subsection{Parsing of the \textmd{\cs{numprint}} argument}
+%
+% \begin{macro}{\nprt@plus@test}
+% \begin{macro}{\nprt@minus@test}
+% \begin{macro}{\nprt@plusminus@test}
+% Define the signs as commands. This is necessary to be able to
+% compare them with other characters.
+% \begin{macrocode}
+\newcommand*\nprt@plus@test{+}
+\newcommand*\nprt@minus@test{-}
+\newcommand*\nprt@plusminus@test{\pm}
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \begin{macro}{\nprt@numberlist}
+% \begin{macro}{\nprt@dotlist}
+% \begin{macro}{\nprt@epxlist}
+% \begin{macro}{\nprt@signlist}
+% Define lists of valid characters for different elements of numbers
+% for parsing the mandatory argument of the \cs{numprint} command.
+% It has nothing to do with the output.
+% \cs{nprt@numberlist} contains digits, \cs{nprt@dotlist} valid
+% decimal signs, \cs{nprt@explist} the characters that start the
+% exponent, and \cs{nprt@signlist} the valid signs, where
+% ``\texttt{+-}'' as alias for ``\cs{pm}'' does not have to be
+% specified seperately.
+% \begin{macrocode}
+\newcommand*\nprt@numberlist{0123456789}
+\newcommand*\nprt@dotlist{.,}
+\newcommand*\nprt@explist{eEdD}
+\newcommand*\nprt@signlist{+-\pm}
+\newcommand*\nprt@ignorelist{}
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% Counters for the number of digits before and after the decimal sign
+% of the mantissa.
+% \begin{macrocode}
+\newcounter{nprt@mantissa@digitsbefore}%
+\newcounter{nprt@mantissa@digitsafter}%
+% \end{macrocode}
+% Counters for the number of digits before and after the decimal sign
+% of the exponent.
+% \begin{macrocode}
+\newcounter{nprt@exponent@digitsbefore}%
+\newcounter{nprt@exponent@digitsafter}%
+% \end{macrocode}
+% Boolean to store if an exponent will be printed.
+% \begin{macrocode}
+\newif\ifnprt@expfound
+% \end{macrocode}
+% Boolean to store if mantissa resp.\ exponent contain a decimal
+% sign.
+% \begin{macrocode}
+\newif\ifnprt@mantissa@decimalfound
+\newif\ifnprt@exponent@decimalfound
+% \end{macrocode}
+% \begin{macro}{\nprt@testsign}
+% Define \cs{nprt@testsign\marg{Number type}\marg{Number}} which tests
+% wheather a sign is given and then starts \cs{nprt@testnumber} (the
+% call actually is done by \cs{nprt@@testsign}).
+% \begin{macrocode}
+\newcommand*\nprt@testsign[2]{%
+% \end{macrocode}
+% First, store the expanded arguments in macros.
+% \begin{macrocode}
+ \edef\nprt@commandname{#1}%
+ \edef\nprt@tmp{#2}%
+% \end{macrocode}
+% Call the working command \cs{nprt@@testsign}.
+% The large number of \cs{expandafter} calls is necessary to ensure
+% that the second to fourth argument are already expanded (thus, |#2|
+% and |#3| are single characters).
+% Append enough \cs{@empty} to ensure the argument-end marker is found
+% even for an empty number.
+% \begin{macrocode}
+ \expandafter\nprt@@testsign\expandafter{%
+ \expandafter\nprt@commandname\expandafter}%
+ \nprt@tmp\@empty\@empty\@empty\@empty
+}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\nprt@@testsign}
+% The first argument is the Number type (``mantissa'' or
+% ``exponent'').
+% Because it is longer than one character, it has to be enclosed in
+% braces when calling this function (see the previous code line).
+% The arguments |#2| to |#4| are the given number, where |#2| and |#3|
+% contain of the first resp.\ second character of the number, while
+% |#4| contains the rest.
+% \begin{macrocode}
+\def\nprt@@testsign#1#2#3#4\@empty{%
+% \end{macrocode}
+% Store the first argument to a macro.
+% \begin{macrocode}
+ \edef\nprt@commandname{#1}%
+% \end{macrocode}
+% Define the macros that store the digits before respectivly after the
+% decimal sign.
+% They are filled digit by digit and start empty.
+% \begin{macrocode}
+ \expandafter\xdef\csname nprt@#1@before\endcsname{\@empty}%
+ \expandafter\xdef\csname nprt@#1@after\endcsname{\@empty}%
+% \end{macrocode}
+% Yet, no digits are stored.
+% \begin{macrocode}
+ \setcounter{nprt@#1@digitsbefore}{0}%
+ \setcounter{nprt@#1@digitsafter}{0}%
+% \end{macrocode}
+% Test wheather the first character of the number, |#2|, contains a
+% sign symbol which is listed in \cs{nprt@signlist}.
+% \begin{macrocode}
+ \nprt@IfCharInString{#2}{\nprt@signlist}{%
+% \end{macrocode}
+% If yes, store that sign in the command
+% \cs{nprt@\meta{\#2}@sign}.
+% \begin{macrocode}
+ \expandafter\xdef\csname nprt@#1@sign\endcsname{#2}%
+% \end{macrocode}
+% If the sign is a ``+'' the second character of the number may be a
+% ``-'' to replace that combination by \cs{pm}.
+% Thus, do an extra handling of that case.
+% \begin{macrocode}
+ \expandafter\ifx\csname nprt@#1@sign\endcsname\nprt@plus@test
+ \def\nprt@tmp{#3}%
+ \ifx\nprt@tmp\nprt@minus@test
+% \end{macrocode}
+% The second character, |#3|, \emph{is} a ``-'', thus redefine
+% \cs{nprt@\meta{\#2}@sign} to \cs{pm}.
+% \begin{macrocode}
+ \expandafter\xdef\csname nprt@#1@sign\endcsname{+-}%
+% \end{macrocode}
+% The digits start at the third character of the number string which
+% is |#4|.
+% Start \cs{nprt@testnumber} to parse the digits of the number if a
+% number is given after the given sign ``+-''.
+% If not, empty \cs{nprt@\meta{\#1}} that \cs{numprint} can determine
+% that only a sign has been given.
+% \begin{macrocode}
+ \def\nprt@tmp{#4}%
+ \ifx\nprt@tmp\@empty
+ \expandafter\edef\csname nprt@#1\endcsname{\@empty}%
+ \else
+ \expandafter\nprt@testnumber\expandafter\nprt@commandname#4\@empty
+ \fi
+ \else
+% \end{macrocode}
+% If there is a single sign character ``+'', the digits start at |#3|.
+% Start \cs{nprt@testnumber} to parse the digits of the number if a
+% number is given after the given sign ``+''.
+% If not, empty \cs{nprt@\meta{\#1}} that \cs{numprint} can determine
+% that only a sign has been given.
+% \begin{macrocode}
+ \ifx#3\@empty
+ \expandafter\edef\csname nprt@#1\endcsname{\@empty}%
+ \else
+ \expandafter\nprt@testnumber\expandafter\nprt@commandname#3#4\@empty
+ \fi
+ \fi
+ \else
+% \end{macrocode}
+% If the sign is a ``\cs{pm}'' store ``\texttt{+-} as sign.
+% \begin{macrocode}
+ \expandafter\ifx\csname nprt@#1@sign\endcsname\nprt@plusminus@test
+ \expandafter\xdef\csname nprt@#1@sign\endcsname{+-}%
+ \fi
+% \end{macrocode}
+% If there is a single sign character other than ``+'', the digits
+% start at |#3|.
+% Start \cs{nprt@testnumber} to parse the digits of the number if a
+% number is given after the given sign.
+% If not, empty \cs{nprt@\meta{\#1}} that \cs{numprint} can determine
+% that only a sign has been given.
+% \begin{macrocode}
+ \ifx#3\@empty
+ \expandafter\edef\csname nprt@#1\endcsname{\@empty}%
+ \else
+ \expandafter\nprt@testnumber\expandafter\nprt@commandname#3#4\@empty
+ \fi
+ \fi
+ }{%
+% \end{macrocode}
+% If there is no sign, set \cs{nprt@\meta{\#2}@sign} empty.
+% \begin{macrocode}
+ \expandafter\xdef\csname nprt@#1@sign\endcsname{\@empty}%
+% \end{macrocode}
+% The digits start at |#2|.
+% Start \cs{nprt@testnumber} to parse the digits of the number.
+% \begin{macrocode}
+ \expandafter\nprt@testnumber\expandafter\nprt@commandname#2#3#4\@empty
+ }%
+}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\nprt@testnumber}
+% As with \cs{nprt@@testsign}, the first argument is the Number type,
+% while the second and third arguments contain the number.
+% |#2| contains the first character of the remaining number string,
+% |#3| the rest.
+% \begin{macrocode}
+\def\nprt@testnumber#1#2#3\@empty{%
+% \end{macrocode}
+% Store the arguments in macros.
+% \begin{macrocode}
+ \edef\nprt@commandname{#1}%
+ \edef\nprt@argthree{#3}%
+% \end{macrocode}
+% Test wheather the current character is a valid character for a real
+% number (say a digit or a decimal sign).
+% \begin{macrocode}
+ \nprt@IfCharInString{#2}{\nprt@numberlist\nprt@dotlist}{%
+% \end{macrocode}
+% If this is the case, continue testing.
+% If the current character is a decimal sign, set the boolean
+% \cs{ifnprt@\meta{Number type}@decimalfound} that a decimal
+% sign has been found.
+% If this has been done before, the number contains two decimal signs
+% which is not allowed, thus, generate an error message.
+% \begin{macrocode}
+ \nprt@IfCharInString{#2}{\nprt@dotlist}{%
+ \csname ifnprt@#1@decimalfound\endcsname
+ \nprt@error{More than one decimal sign used}{The mantissa
+ or the exponent may only contain a maximum of one decimal
+ sign (one of the list `\nprt@dotlist')}%
+ \else
+ \csname nprt@#1@decimalfoundtrue\endcsname
+ \fi
+ }{%
+% \end{macrocode}
+% If the current character is no decimal sign it has to be a digit.
+% If the decimal sign has been found before, this digit is in the real
+% part of the number.
+% Then, add it at the end of the after-decimal-sign part.
+% Also, increase the number of found digits.
+% \begin{macrocode}
+ \csname ifnprt@#1@decimalfound\endcsname
+ \expandafter\g@addto@macro\csname nprt@#1@after\endcsname{#2}%
+ \stepcounter{nprt@#1@digitsafter}%
+ \else
+% \end{macrocode}
+% If the decimal sign has not been found before, this digit is in the
+% integer part of the number.
+% Then, add it at the end of the before-decimal-sign part.
+% \begin{macrocode}
+ \expandafter\g@addto@macro\csname nprt@#1@before\endcsname{#2}%
+ \stepcounter{nprt@#1@digitsbefore}%
+ \fi
+ }%
+% \end{macrocode}
+% If the next character is not \cs{@empty} and thus, the end of the
+% number is not reached, start \cs{nprt@testnumber} resursively to
+% parse the next character.
+% \begin{macrocode}
+ \ifx\nprt@argthree\@empty
+ \else
+ \expandafter\nprt@testnumber\expandafter\nprt@commandname#3\@empty
+ \fi
+ }{%
+% \end{macrocode}
+% The current character is neither a digit nor a decimal sign.
+% Thus, it is a invalid character; produce an error message.
+% \begin{macrocode}
+ \nprt@error{Invalid number format. Printing the
+ argument\MessageBreak
+ verbatim}{Something is wrong in the format of the number}%
+ }%
+}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\nprt@testcharacter}
+% This macro parses the whole mandatory argument of \cs{numprint}.
+% This means it is tested on invalid characters and on a mantissa and
+% an exponent.
+% The first argument is the current character while |#2| is the rest
+% of the argument, not parsed yet.
+% \begin{macrocode}
+\def\nprt@testcharacter#1#2\@empty{%
+% \end{macrocode}
+% Store the second argument to a macro.
+% \begin{macrocode}
+ \edef\nprt@argtwo{#2}%
+% \end{macrocode}
+% Test wheather the current character is a valid one.
+% \begin{macrocode}
+ \nprt@IfCharInString{#1}{%
+ \nprt@numberlist\nprt@dotlist\nprt@explist\nprt@signlist\nprt@ignorelist}{%
+% \end{macrocode}
+% Yes, it is valid.
+%
+% Now, test wheather it is one of the ignored characters.
+% \begin{macrocode}
+ \nprt@IfCharInString{#1}{\nprt@ignorelist}{%
+ \nprt@debug{Character `\noexpand#1' ignored}%
+ }{%
+% \end{macrocode}
+% Yes, it is valid.
+%
+% Now, test wheather it is one of the characters that start the
+% exponent.
+% If yes, set \cs{ifnprt@expfound} to ``true''.
+% If in addition, this has been done before, you have used more than
+% one exponent starting character; produce an error message.
+% \begin{macrocode}
+ \nprt@IfCharInString{#1}{\nprt@explist}{%
+ \ifnprt@expfound
+ \nprt@error{Character for exponent (`\nprt@explist') used
+ more than once}{The argument of \string\numprint\space may
+ only contain one of following characters: `\nprt@explist'}%
+ \fi
+ \nprt@expfoundtrue
+ }{%
+% \end{macrocode}
+% If the current character is not an exponent-starting character it
+% is either a part of the mantissa or the exponent, depending on
+% wheather the exponent has been started before.
+% Add the current character to the corresponding command that stores
+% the mantissa resp.\ the exponent.
+% \begin{macrocode}
+ \ifnprt@expfound
+ \g@addto@macro\nprt@exponent{#1}%
+ \else
+ \g@addto@macro\nprt@mantissa{#1}%
+ \fi
+ }%
+ }%
+% \end{macrocode}
+% If we have not reached the end of the argument, call
+% \cs{nprt@testcharacter} recursively.
+% \begin{macrocode}
+ \ifx\nprt@argtwo\@empty
+ \else
+ \nprt@testcharacter#2\@empty\@empty\@empty
+ \fi
+ }{%
+% \end{macrocode}
+% If the character is not valid produce an error message.
+% \begin{macrocode}
+ \nprt@error{Invalid characters `#1' in mandatory argument
+ of\MessageBreak
+ \string\numprint. Allowed are\MessageBreak
+ `\nprt@numberlist\nprt@dotlist\nprt@explist\nprt@signlist\nprt@ignorelist'}{%
+ You may only use the specified characters in the argument.}%
+ }%
+}
+% \end{macrocode}
+% \end{macro}
+%
+%
+% \subsection{Table alignment}
+%
+% \subsubsection{Aligned numbers, also for ordinary text}
+%
+% Define some lengths that help to calculate the width of a number.
+% \begin{macrocode}
+\newlength{\nprt@digitwidth}%
+\newlength{\nprt@sepwidth}%
+\newlength{\nprt@decimalwidth}%
+\newlength{\nprt@blockwidth}%
+% \end{macrocode}
+% \begin{macro}{\nprt@calcblockwidth}
+% Define \cs{nprt@calcblockwidth\marg{Number
+% type}\marg{Position}\marg{Math mode}}, where
+% \meta{Number type} is either ``mantissa'' or ``exponent'',
+% \meta{Position} is the position relative to the decimal sign
+% (``before'' or ``after''), \meta{Math mode} is a math mode command
+% (\cs{displaystyle}, \cs{textstyle}, \cs{scriptstyle}, or
+% \cs{scriptscriptstyle}).
+%
+% This macro calculates the width of a block if aligned output is
+% requested.
+% The resulted width is stored in the length \cs{nprt@blockwidth}.
+% \begin{macrocode}
+\newcommand*\nprt@calcblockwidth[3]{%
+% \end{macrocode}
+% Store the arguments in macros.
+% \begin{macrocode}
+ \edef\nprt@argone{#1}%
+ \edef\nprt@argtwo{#2}%
+ \edef\nprt@argthree{#3}%
+% \end{macrocode}
+% Define a macro with the contents ``mantissa'' to be able to compare
+% it.
+% \begin{macrocode}
+ \edef\nprt@mantissaname{mantissa}%
+% \end{macrocode}
+% Define a macro with the contents ``after'' to be able to compare
+% it.
+% \begin{macrocode}
+ \edef\nprt@aftername{after}%
+% \end{macrocode}
+% If the width for the mantissa is to be calculated, enter this code
+% part.
+% \begin{macrocode}
+ \ifx\nprt@argone\nprt@mantissaname
+% \end{macrocode}
+% The width of the digits and separators changes between text and
+% math mode.
+% If math mode is active, proceed here.
+% \begin{macrocode}
+ \ifmmode
+% \end{macrocode}
+% Calculate the width of digits.
+% It is assumed that all digits have the same width as a zero.
+% First, execute parameter \verb|#3| to switch to the current math
+% style.
+% This is be done that way since it is not possible to export length
+% values from \cs{mathchoice}.
+% \begin{macrocode}
+ \settowidth{\nprt@digitwidth}{$#3%
+ 0$}%
+% \end{macrocode}
+% Calculate the width of the separators.
+% This may differ from before and after the decimal sign.
+% \begin{macrocode}
+ \settowidth{\nprt@sepwidth}{$#3%
+ \csname nprt@separator@#2\endcsname$}%
+% \end{macrocode}
+% Calculate the width of the decimal sign.
+% \begin{macrocode}
+ \settowidth{\nprt@decimalwidth}{$#3%
+ \nprt@decimal$}%
+ \else
+% \end{macrocode}
+% Do the same for text mode.
+% \begin{macrocode}
+ \settowidth{\nprt@digitwidth}{0}%
+ \settowidth{\nprt@sepwidth}{\csname nprt@separator@#2\endcsname}%
+ \settowidth{\nprt@decimalwidth}{\nprt@decimal}%
+ \fi
+% \end{macrocode}
+% The same for the exponent.
+% \begin{macrocode}
+ \else
+ \ifmmode
+ \settowidth{\nprt@digitwidth}{$#3%
+ {}^{0}$}%
+ \settowidth{\nprt@sepwidth}{$#3%
+ {}^{\csname nprt@separator@#2\endcsname}$}%
+ \settowidth{\nprt@decimalwidth}{$#3%
+ {}^{\nprt@decimal}$}%
+ \else
+ \settowidth{\nprt@digitwidth}{\textsuperscript{0}}%
+ \settowidth{\nprt@sepwidth}{%
+ \textsuperscript{\csname nprt@separator@#2\endcsname}}%
+ \settowidth{\nprt@decimalwidth}{\textsuperscript{\nprt@decimal}}%
+ \fi
+ \fi
+% \end{macrocode}
+% Output to the log file.
+% \begin{macrocode}
+ \nprt@debug{Widths for #1 #2 decimal sign
+ (\ifx\nprt@argthree\@empty text mode\else math mode #3\fi):\MessageBreak
+ digits \the\nprt@digitwidth,
+ separators \the\nprt@sepwidth,\MessageBreak
+ decimal sign \the\nprt@decimalwidth}%
+% \end{macrocode}
+% Produce a warning if the current number exceeds the reserved space.
+% Signs ($+-\pm$) are not taken into account.
+% \begin{macrocode}
+ \ifnum\csname nprt@#1@fixeddigits@#2\endcsname<%
+ \csname thenprt@#1@digits#2\endcsname
+ \PackageWarning{numprint}{#1 exceeds reserved space
+ #2\MessageBreak
+ decimal sign}%
+ \fi
+% \end{macrocode}
+% \changes{1.34}{2004/12/13}{Fix a bug invoked in version~1.33. Found
+% by Stefan Salewski}%
+% Calculate the width of the given number of digits without
+% separators.
+% \begin{macrocode}
+ \setlength{\nprt@blockwidth}{%
+ \csname nprt@#1@fixeddigits@#2\endcsname\nprt@digitwidth}%
+% \end{macrocode}
+% Calculate how many separators are put into the number.
+% \begin{macrocode}
+ \setcounter{nprt@blockcnt}{\csname nprt@#1@fixeddigits@#2\endcsname}%
+ \addtocounter{nprt@blockcnt}{-1}%
+ \divide\c@nprt@blockcnt 3%
+% \end{macrocode}
+% If four-digit length numbers are not separated, delete the number of
+% separators again.
+% \begin{macrocode}
+ \ifnprt@numsepfour
+ \else
+ \ifnum\csname nprt@#1@fixeddigits@before\endcsname<5
+ \ifnum\csname nprt@#1@fixeddigits@after\endcsname<5
+ \setcounter{nprt@blockcnt}{0}%
+ \fi
+ \fi
+ \fi
+% \end{macrocode}
+% Add the width of the separators to the width.
+% \begin{macrocode}
+ \addtolength{\nprt@blockwidth}{\thenprt@blockcnt\nprt@sepwidth}%
+% \end{macrocode}
+% Add the width of the decimal sign to the width if it is after the
+% decimal sign and there shall be digits after the decimal sign.
+% \begin{macrocode}
+ \ifx\nprt@argtwo\nprt@aftername
+ \expandafter\ifnum\csname nprt@#1@fixeddigits@after\endcsname>0
+ \addtolength{\nprt@blockwidth}{\the\nprt@decimalwidth}%
+ \fi
+ \fi
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\npunit}
+% The \cs{npunit} command takes as argument a unit that is printed in
+% every cell of a table when using the (new) |n| or |N| column types.
+% \begin{macrocode}
+\newcommand*\npunit[1]{\def\nprt@unit{#1}}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\npnounit}
+% Initialize \cs{nprt@unit}.
+% \begin{macrocode}
+\edef\nprt@unit{\@empty}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\npafternum}
+% The \cs{npunit} command takes as argument some text that is printed
+% after the number in every cell of a table when using the (new) |n|
+% or |N| column types.
+% \begin{macrocode}
+\newcommand*\npafternum[1]{\def\nprt@afternum{#1}}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\nprt@afternum}
+% Initialize \cs{nprt@afternum}.
+% \begin{macrocode}
+\edef\nprt@afternum{\@empty}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\npmakebox}
+% \changes{1.10}{2003/10/12}{Declare \cs{npmakebox} command}%
+% The \cs{npmakebox} is similar to the \cs{makebox} command but it
+% takes a text as first optional argument instead of a length.
+% The width of the box is calculated by the width of this text.
+% \begin{macrocode}
+\DeclareRobustCommand*\npmakebox{%
+ \@ifnextchar[% ]
+ {\nprt@makebox}{\makebox}%
+}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\nprt@makebox}
+% The internal part of the \cs{npmakebox} command.
+% \begin{macrocode}
+\newcommand*\nprt@makebox{}
+\def\nprt@makebox[#1]{%
+ \settowidth\@tempdima{#1}%
+ \makebox[\@tempdima]%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \changes{1.10}{2003/10/12}{Define math version \texttt{npbold}}%
+% Declare a bold math alphabet |npbold| that aligns with normal
+% digits.
+% \begin{macrocode}
+\ifnprt@npbold
+ \DeclareMathVersion{npbold}
+ \SetSymbolFont{operators}{npbold}{OT1}{cmr} {b}{n}
+ \SetSymbolFont{letters} {npbold}{OML}{cmm} {b}{it}
+ \SetSymbolFont{symbols} {npbold}{OMS}{cmsy}{b}{n}
+ \SetMathAlphabet\mathsf{npbold}{OT1}{cmss}{b}{n}
+ \SetMathAlphabet\mathit{npbold}{OT1}{cmr}{b}{it}
+% \end{macrocode}
+% \begin{macro}{\npboldmath}
+% Switch to that bold math alphabet.
+% \begin{macrocode}
+ \def\npboldmath{\@nomath\npboldmath
+ \mathversion{npbold}}
+\fi
+% \end{macrocode}
+% \end{macro}
+%
+%
+% \subsubsection{Auxilliary routines for the new column types}
+%
+% This code has been developed starting from the \texttt{rccol}
+% package by Eckhart Guth\"ohrlein~\cite{guthoehrlein2000a}.
+% Some small bugs of that package have been corrected here, too.
+%
+% \begin{macro}{\nprt@digittoks}
+% Token list that will contain all characters of a tabular cell that
+% are allowed for \cs{numprint}.
+% \begin{macrocode}
+\newtoks\nprt@digittoks
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\nprt@pretoks}
+% Token list with all tokens before the number itself.
+% \begin{macrocode}
+\newtoks\nprt@pretoks
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\nprt@posttoks}
+% Token list with all tokens after the number itself.
+% \begin{macrocode}
+\newtoks\nprt@posttoks
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\ifnprt@numfound}
+% Has the number already been found in the parsing of the tabular
+% cell?
+% \begin{macrocode}
+\newif\ifnprt@numfound
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\nprt@begin}
+% This macro is executed at the begin of each tabular cell.
+% \begin{macrocode}
+\def\nprt@begin{%
+% \end{macrocode}
+% Initialize the tokens and macros.
+% \begin{macrocode}
+ \nprt@digittoks={}%
+ \nprt@pretoks={}%
+ \nprt@posttoks={}%
+ \edef\nprt@unit{\@empty}%
+ \edef\nprt@afternum{\@empty}%
+ \nprt@numfoundfalse
+% \end{macrocode}
+% Set the allowed characters.
+% This macro is made empty when the number itself is read-in totally.
+% \begin{macrocode}
+ \edef\nprt@allowedchars{\nprt@numberlist\nprt@dotlist\nprt@explist
+ \nprt@signlist\nprt@ignorelist}%
+% \end{macrocode}
+% Start to parse the tabular cell.
+% \begin{macrocode}
+ \nprt@getnexttok
+}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\nprt@saveothertok}
+% Adds the current token to the list of tokens before or after the
+% number.
+% \begin{macrocode}
+\def\nprt@saveothertok#1{%
+ \ifnprt@numfound
+% \end{macrocode}
+% If the number has already been found it is ended now.
+% This is marked by clearing the list of allowed characters.
+% \begin{macrocode}
+ \def\nprt@allowedchars{}%
+ \nprt@posttoks=\expandafter{\the\nprt@posttoks#1}%
+ \else
+ \nprt@pretoks=\expandafter{\the\nprt@pretoks#1}%
+ \fi
+}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\nprt@getnexttok}
+% \changes{1.31}{2004/08/18}{Bugfix: The numprint column types did not
+% like empty cells in the last column of a tabular}%
+% Parse the tabular cell.
+% The argument is the next token of the tabular cell.
+% Inside this command, the end of the tabular cell is detected by
+% different possibilities to end a cell.
+% \begin{macrocode}
+\def\nprt@getnexttok#1{%
+% \end{macrocode}
+% If the current token is \cs{tabularnewline} or |\\|
+% (which is the same) the tabular cell is finished.
+% \begin{macrocode}
+ \ifx\tabularnewline#1%
+% \end{macrocode}
+% Redefine the \cs{nprt@next} command that is called at the end of
+% this command to execute the found \cs{tabularnewline} command.
+% \begin{macrocode}
+ \let\nprt@next\tabularnewline
+ \else
+% \end{macrocode}
+% If this tabular cell is not in the last column and a |&| is found,
+% the \cs{nprt@end} command is found that is inserted into this cell
+% using the |<| specifier by the columnn types.
+% \begin{macrocode}
+ \ifx\end#1%
+% \end{macrocode}
+% Redefine \cs{nprt@next} to execute \cs{nprt@end} at the end of this
+% command.
+% \begin{macrocode}
+ \let\nprt@next\end
+ \else
+% \end{macrocode}
+% If this is the last cell of the tabular, the \cs{end} part of
+% \cs{end\{tabular\}} or \cs{end\{tabular*\}} is found.
+% \begin{macrocode}
+ \ifx\nprt@end#1%
+% \end{macrocode}
+% Test wheather it is the normal or the star version of the
+% environment.
+% Is this really necessary?
+% \begin{macrocode}
+ \let\nprt@next\nprt@end
+ \else
+% \end{macrocode}
+% If this is the last cell of the tabular and the tabular has been
+% called using \cs{tabular} \ldots\ \cs{endtabular} instead of using
+% the environment call, \cs{endtabular} is found.
+% \begin{macrocode}
+ \ifx\endtabular#1%
+ \let\nprt@next\endtabular
+ \else
+% \end{macrocode}
+% For |tabularx|, a test on \cs{csname} has to be added.
+% \begin{macrocode}
+ \ifx\csname#1%
+ \let\nprt@next\csname
+ \else
+% \end{macrocode}
+% If the last cell of a line is empty, \cs{relax} will be found.
+% \begin{macrocode}
+ \ifx\relax#1%
+ \let\nprt@next\relax
+ \else
+% \end{macrocode}
+% If no command is found that ends the tabular cell, we are not yet at
+% the end of the cell.
+% Redefine \cs{nprt@next} to start this command recursively for
+% parsing the next token.
+% \begin{macrocode}
+ \let\nprt@next\nprt@getnexttok
+% \end{macrocode}
+% Test if this token is one of the allowed characters of a number.
+% \begin{macrocode}
+ \nprt@IfCharInString{#1}{\nprt@allowedchars}{%
+% \end{macrocode}
+% If yes, append this character to the token list of the number and
+% set the flag that the number has been found.
+% \begin{macrocode}
+ \nprt@numfoundtrue
+ \nprt@digittoks=\expandafter{\the\nprt@digittoks#1}%
+ }{%
+% \end{macrocode}
+% If it is no character of a number, store it for the tokens before or
+% after the number.
+% \begin{macrocode}
+ \nprt@saveothertok{#1}%
+ }%
+ \fi % \relax
+ \fi % \csname
+ \fi % \endtabular
+ \fi % \nprt@end
+ \fi % \end
+ \fi % \tabularnewline
+% \end{macrocode}
+% Call the previously saved command (recursion or end of the tabular
+% cell).
+% \begin{macrocode}
+ \nprt@next
+}
+% \end{macrocode}
+% Boolean to decide if math mode is active outside the tabular cell.
+% This is true for the |array| environment.
+% \begin{macrocode}
+\newif\ifnprt@mathtabular
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\nprt@end}
+% This macro is called at the end of each tabular cell.
+% The arguments are used as follows: \meta{digits before},
+% \meta{digits after} the decimal sign for the mantissa;
+% \meta{digits before}, \meta{digits after} the decimal sign for the
+% exponent; commands inserted \meta{before} and \meta{after} the
+% \cs{numprint} command.
+% The arguments five and six are empty for printing the number in text
+% mode and contain ``|$|'' both for printing the number in math mode.
+% \begin{macrocode}
+\def\nprt@end#1#2#3#4#5#6{%
+% \end{macrocode}
+% First, print the tokens before the number.
+% \begin{macrocode}
+ \the\nprt@pretoks
+% \end{macrocode}
+% Print the number in a group in order to save the tokens before and
+% after the number to be influenced by its settings.
+% \begin{macrocode}
+ \begingroup
+% \end{macrocode}
+% Set the digits for the alignment of the mantissa.
+% \begin{macrocode}
+% \npnodigits
+ \npdigits{#1}{#2}%
+% \end{macrocode}
+% Set the digits for the alignment of the exponent if given.
+% If no number of digits is given, they are set negativ.
+% \begin{macrocode}
+ \npnoexponentdigits
+ \ifnum#3<0
+ \nprt@debug{no exponent alignment in tabular}%
+ \else
+ \ifnum#4<0
+ \nprt@debug{exponent alignment in tabular with #3 digits}%
+ \npexponentdigits{#3}%
+ \else
+ \nprt@debug{exponent alignment in tabular with #3.#4 digits}%
+ \npexponentdigits[#4]{#3}%
+ \fi
+ \fi
+% \end{macrocode}
+% Omit the section that prints the number if no number has been
+% given.
+% \begin{macrocode}
+ \ifnprt@numfound
+% \end{macrocode}
+% Print the pre-command if defined.
+% Since the pre-command is fixed to nothing or ``|$|'' to switch to
+% math mode, this is only done if the math mode is not active,
+% before.
+% Set the boolean \cs{ifnprt@mathtabular} according to the previous
+% status in order to close the math mode if necessary.
+% \begin{macrocode}
+ \ifmmode
+ \nprt@mathtabulartrue
+ \else
+ \nprt@mathtabularfalse
+ #5%
+ \fi
+% \end{macrocode}
+% Print the number, with unit if one has been given.
+% \begin{macrocode}
+ \ifx\nprt@unit\@empty
+ \numprint{\the\nprt@digittoks}%
+ \else
+ \numprint[\nprt@unit]{\the\nprt@digittoks}%
+ \fi
+% \end{macrocode}
+% Switch off math mode if it has not been active before.
+% \begin{macrocode}
+ \ifnprt@mathtabular
+ \else
+ #6%
+ \fi
+% \end{macrocode}
+% Print a message to the log file if no number has been specified.
+% \begin{macrocode}
+ \else
+ \PackageInfo{numprint}{No number in tabular cell}%
+ \fi
+% \end{macrocode}
+% Do the rest outside the group in order to prevent the post-texts
+% from being formatted as the number.
+% \begin{macrocode}
+ \endgroup
+% \end{macrocode}
+% Print the tokens after the number.
+% \begin{macrocode}
+ \the\nprt@posttoks
+% \end{macrocode}
+% Print the contents defined with \cs{npafternum}.
+% \begin{macrocode}
+ \ifx\nprt@afternum\@empty
+ \else
+ \nprt@afternum
+ \fi
+}
+% \end{macrocode}
+% \end{macro}
+%
+%
+% \subsubsection{New column types}
+% \changes{1.10}{2003/10/12}{New tabular alignment mechanism}%
+%
+% Define the new column types.
+% \begin{macrocode}
+\ifnprt@newcolumntype
+% \end{macrocode}
+%
+% Declare a new column type |N| which prints a number in text mode and
+% does not need to repeat \cs{numprint} in each tabular cell.
+% This is declared empty because all executing macros are redefined
+% anyway.
+% \begin{macrocode}
+ \newcolumntype{N}{}
+% \end{macrocode}
+% \begin{macro}{\NC@rewrite@N}
+% Redefine this command to parse the declaration of the |N| column
+% type to look for an optional argument.
+% If none is given, set both optional arguments to ``|-1|''.
+% \begin{macrocode}
+ \def\NC@rewrite@N{%
+ \nprt@digittoks{}%
+ \nprt@pretoks{}%
+% \end{macrocode}
+% If no optional argument is given, set both optional arguments to
+% ``|-1|''.
+% \begin{macrocode}
+ \@ifnextchar[{% ]
+ \nprt@rewrite@{}{}%
+ }{%
+ \nprt@rewrite@@{}{}{-1}[-1]%
+ }%
+ }
+% \end{macrocode}
+% \end{macro}
+% Declare a new column type |n| which prints a number and does not
+% need to repeat \cs{numprint} in each tabular cell.
+% This is declared empty because all executing macros are redefined
+% anyway.
+% \begin{macrocode}
+ \newcolumntype{n}{}
+% \end{macrocode}
+% \begin{macro}{\NC@rewrite@n}
+% Same as \cs{NC@rewrite@N}, but give ``|$|'' twice for math mode.
+% \begin{macrocode}
+ \def\NC@rewrite@n{%
+ \nprt@digittoks{}%
+ \nprt@pretoks{}%
+ \@ifnextchar[{% ]
+ \nprt@rewrite@{$}{$}%
+ }{%
+ \nprt@rewrite@@{$}{$}{-1}[-1]%
+ }%
+ }
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\nprt@rewrite@}
+% Look for the second optional argument.
+% \begin{macrocode}
+ \def\nprt@rewrite@#1#2[#3]{%
+ \@ifnextchar[{%]
+ \nprt@rewrite@@{#1}{#2}{#3}%
+ }{%
+ \nprt@rewrite@@{#1}{#2}{#3}[-1]%
+ }%
+ }
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\nprt@rewrite@@}
+% The arguments are used as follows:
+% commands inserted \meta{before} and \meta{after} the
+% \cs{numprint} command; \meta{digits before}, \meta{digits after} the
+% decimal sign for the mantissa; \meta{digits before}, \meta{digits
+% after} the decimal sign for the exponent.
+% \begin{macrocode}
+ \def\nprt@rewrite@@#1#2#3[#4]#5#6{%
+% \end{macrocode}
+% Add the definition for the current column to the already made column
+% definitions that are stored in \cs{@temptokena}.
+% Before the column itself, the starting command for the parsing,
+% \cs{nprt@begin}, is inserted.
+% At the end of the column, start the final work, command
+% \cs{nprt@end}.
+% These commands shall not be expanded, yet.
+% \begin{macrocode}
+ \edef\nprt@rewrite@scratch{\the\@temptokena
+ >{\noexpand\nprt@begin\noexpand\ignorespaces}l%
+ <{\noexpand\nprt@end{#5}{#6}{#3}{#4}{#1}{#2}}%
+ }%
+% \end{macrocode}
+% Set \cs{@temptokena} to the preceding and the current column
+% definition.
+% This is implicitely used by the |array| package.
+% \begin{macrocode}
+ \@temptokena\expandafter{\nprt@rewrite@scratch}%
+% \end{macrocode}
+% Parse for next column in the definition.
+% \begin{macrocode}
+ \NC@find
+ }
+% \end{macrocode}
+% \end{macro}
+%
+%
+% \subsubsection{Old column types for compatibility}
+%
+% Define the old column types.
+% \begin{macrocode}
+\else
+% \end{macrocode}
+% The column type \verb|n| aligns the base number but not the exponent.
+% \begin{macrocode}
+ \newcolumntype{n}[2]{>{\npdigits{#1}{#2}$}l<{$}}
+% \end{macrocode}
+% The column type \verb|N| aligns the base number as well as the exponent.
+% \begin{macrocode}
+ \newcolumntype{N}[3]{%
+ >{\npdigits{#1}{#2}\npexponentdigits{#3}$}l<{$}}
+% \end{macrocode}
+% End of column type section.
+% \begin{macrocode}
+\fi
+% \end{macrocode}
+%
+%
+% \subsection{Round numbers}%
+% \label{sec:code:round}%
+%
+% Stores if the currenct digit has to be rounded up.
+% \begin{macrocode}
+\newif\ifnprt@roundup
+% \end{macrocode}
+% Declare the counter used inside \cs{nprt@round@after} and
+% \cs{nprt@round@before}.
+% \begin{macrocode}
+\newcount\nprt@thisdigit
+% \end{macrocode}
+% \begin{macro}{\nprt@round@after}
+% Does the rounding of the number after the decimal sign.
+% The first argument contains the current digit, the second the rest
+% of the number.
+%
+% This routine is a little bit complicated.
+% It is called recursively.
+% In the forward rund, it just counts the number of digits, it has
+% parsed already.
+% In the backward rund the rounding is done.
+% \begin{macrocode}
+\def\nprt@round@after#1#2\@empty{%
+% \end{macrocode}
+% Store the arguments in macros.
+% \begin{macrocode}
+ \edef\nprt@argone{#1}%
+ \edef\nprt@argtwo{#2}%
+% \end{macrocode}
+% Count the parsed digits.
+% \begin{macrocode}
+ \advance \nprt@curpos by 1
+% \end{macrocode}
+% If the end of the number is reached an internal error has been
+% occured since enough zeros are appended to the number before.
+% \begin{macrocode}
+ \ifx\nprt@argone\@empty
+ \nprt@error{Rounding: End of number has been reached}{This may
+ not happen}%
+ \else
+% \end{macrocode}
+% If the current digit is one behind the last digit to be printed it
+% decides if the last printed digit is rounded or not.
+% This decision is stored in \cs{ifnprt@roundup}.
+% If this position is reached, stop the recursion.
+% \begin{macrocode}
+ \ifnum\nprt@curpos>\nprt@rndpos
+ \ifnum\nprt@argone>4
+ \nprt@rounduptrue
+ \fi
+ \else
+% \end{macrocode}
+% The position has not been reached, yet.
+% Thus, call this routine recursively.
+% \begin{macrocode}
+ \expandafter\nprt@round@after#2\@empty\@empty
+% \end{macrocode}
+% The following lines are executed in the backward run when rounding.
+%
+% Store the current digit in a number in order to be able to calculate
+% with it.
+% \begin{macrocode}
+ \nprt@thisdigit=#1
+% \end{macrocode}
+% If this number is to be rounded up do it by advancing it by one.
+% \begin{macrocode}
+ \ifnprt@roundup
+ \advance \nprt@thisdigit by 1
+% \end{macrocode}
+% Reset \cs{ifnprt@roundup} since the preceeding digit is not to be
+% rounded, normally.
+% \begin{macrocode}
+ \nprt@roundupfalse
+% \end{macrocode}
+% If the digit has been rounded from 9 to 10, it has to be a ``0'' and
+% the preceeding digit has to be rounded up.
+% \begin{macrocode}
+ \ifnum\nprt@thisdigit=10
+ \nprt@thisdigit=0
+ \nprt@rounduptrue
+ \fi
+ \fi
+% \end{macrocode}
+% Store the modificated current digit to the new number by putting it
+% into \cs{nprt@newnum} before all digits that have been stored
+% before.
+% \begin{macrocode}
+ \expandafter\xdef\expandafter\nprt@newnum{%
+ \the\nprt@thisdigit\nprt@newnum}%
+ \fi
+ \fi
+}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\nprt@round@before}
+% Does the rounding of the number after the decimal sign.
+% The first argument contains the current digit, the second the rest
+% of the number.
+% This routine works as \cs{nprt@round@after} but stops at its end in
+% contrast to a given number.
+% \begin{macrocode}
+\def\nprt@round@before#1#2\@empty{%
+% \end{macrocode}
+% Store the arguments.
+% \begin{macrocode}
+ \edef\nprt@argone{#1}%
+ \edef\nprt@argtwo{#2}%
+% \end{macrocode}
+% Do the recursion until the end of the number.
+% This routine does not have to decide wheather the number has to be
+% rounded since it knows that by \cs{ifnprt@roundup}, set by
+% \cs{nprt@round@after}.
+% \begin{macrocode}
+ \ifx\nprt@argtwo\@empty
+ \else
+ \expandafter\nprt@round@before#2\@empty
+ \fi
+% \end{macrocode}
+% Store the current digit into a counter and use zero if the number
+% before the decimal sign is empty.
+% \begin{macrocode}
+ \ifx\nprt@argone\@empty
+ \nprt@thisdigit=0
+ \else
+ \nprt@thisdigit=#1
+ \fi
+% \end{macrocode}
+% Add one to the number if it has to be rounded.
+% \begin{macrocode}
+ \ifnprt@roundup
+ \advance \nprt@thisdigit by 1
+% \end{macrocode}
+% Reset the rounding of the next number.
+% \begin{macrocode}
+ \nprt@roundupfalse
+% \end{macrocode}
+% If rounded from 9 to 10, set this digit to ``0'' and give the
+% information to the next digit.
+% \begin{macrocode}
+ \ifnum\nprt@thisdigit=10
+ \nprt@thisdigit=0
+ \nprt@rounduptrue
+ \fi
+ \fi
+% \end{macrocode}
+% If the number is empty, the new number has to be added and the
+% counter adjusted.
+% \begin{macrocode}
+ \ifx\nprt@argone\@empty
+ \xdef\nprt@newnum{\the\nprt@thisdigit}%
+ \stepcounter{nprt@\nprt@numname @digitsbefore}%
+ \else
+% \end{macrocode}
+% Insert the current digit before the already stored digits in
+% \cs{nprt@newnum}.
+% \begin{macrocode}
+ \expandafter\xdef\expandafter\nprt@newnum{%
+ \the\nprt@thisdigit\nprt@newnum}%
+ \fi
+}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\nprt@round}
+% Round a number.
+% The first argument is the Number type (``mantissa'' resp.\
+% ``exponent''), the second is the number of digits to be printed
+% after the decimal sign.
+% \begin{macrocode}
+\newcommand*\nprt@round[2]{%
+ \begingroup
+% \end{macrocode}
+% Store the Number type for use in \cs{nprt@round@before} and
+% \cs{nprt@round@after}.
+% \begin{macrocode}
+ \edef\nprt@numname{#1}%
+% \end{macrocode}
+% If the number of printed digits after the decimal sign is negative,
+% no rounding will be performed.
+% \begin{macrocode}
+ \ifnum#2<0
+ \else
+% \end{macrocode}
+% Print a debug message.
+% \begin{macrocode}
+ \nprt@debug{\string\nprt@round: Round after #2 digits for #1}%
+% \end{macrocode}
+% Set the number of digits after the decimal sign to the given value
+% since this number of digits will be printed later.
+% \begin{macrocode}
+ \setcounter{nprt@#1@digitsafter}{#2}%
+% \end{macrocode}
+% Append enough zeros to the after-decimal-sign part in order to have
+% enough digits that \cs{nprt@round@after} will not reach the end of
+% the number.
+% \begin{macrocode}
+ \expandafter\g@addto@macro\csname nprt@#1@after\endcsname{%
+ \nprt@roundnull}%
+% \end{macrocode}
+% Two new counters for the round position and the current postion in
+% \cs{nprt@round@after}.
+% \begin{macrocode}
+ \newcount\nprt@curpos
+ \newcount\nprt@rndpos
+% \end{macrocode}
+% Set the number of digits after the decimal sign.
+% \begin{macrocode}
+ \nprt@rndpos=#2
+% \end{macrocode}
+% Default not to round.
+% \begin{macrocode}
+ \nprt@roundupfalse
+% \end{macrocode}
+% Define the ``working'' number for the subroutines.
+% \begin{macrocode}
+ \edef\nprt@tmpnum{\csname nprt@#1@after\endcsname}%
+% \end{macrocode}
+% The new number starts empty and will be filled by
+% \cs{nprt@round@after}.
+% \begin{macrocode}
+ \edef\nprt@newnum{}%
+% \end{macrocode}
+% Do the rounding after the decimal sign.
+% \begin{macrocode}
+ \expandafter\nprt@round@after\nprt@tmpnum\@empty\@empty
+% \end{macrocode}
+% Copy the new number after the decimal sign to the ``official''
+% command storing it.
+% \begin{macrocode}
+ \expandafter\xdef\csname nprt@#1@after\endcsname{\nprt@newnum}%
+% \end{macrocode}
+% If the integer part has to be modificated, too, do it.
+% \begin{macrocode}
+ \ifnprt@roundup
+% \end{macrocode}
+% Copy the number to the working number.
+% \begin{macrocode}
+ \edef\nprt@tmpnum{\csname nprt@#1@before\endcsname}%
+% \end{macrocode}
+% Clear the new number.
+% \begin{macrocode}
+ \edef\nprt@newnum{}%
+% \end{macrocode}
+% Do the rounding before the decimal sign.
+% \begin{macrocode}
+ \expandafter\nprt@round@before\nprt@tmpnum\@empty\@empty
+% \end{macrocode}
+% If the first digit has been rounded up from 9 a new digit ``1'' has
+% to be inserted before the number.
+% \begin{macrocode}
+ \ifnprt@roundup
+ \expandafter\xdef\expandafter\nprt@newnum{1\nprt@newnum}%
+ \stepcounter{nprt@#1@digitsbefore}%
+ \fi
+% \end{macrocode}
+% Copy the new number before the decimal sign to the ``official''
+% command storing it.
+% \begin{macrocode}
+ \expandafter\xdef\csname nprt@#1@before\endcsname{\nprt@newnum}%
+ \fi
+ \fi
+ \endgroup
+% \end{macrocode}
+% Set the boolean for a found decimal sign according to the number of
+% printed decimals.
+% \begin{macrocode}
+ \ifnum#2<0
+ \else
+% \end{macrocode}
+% If rounded to no digits after the decimal sign, switch off printing
+% of it.
+% \begin{macrocode}
+ \ifnum#2=0
+ \csname nprt@#1@decimalfoundfalse\endcsname
+ \else
+% \end{macrocode}
+% If one or more digits are printed, a decimal sign has to be printed.
+% \begin{macrocode}
+ \csname nprt@#1@decimalfoundtrue\endcsname
+ \fi
+ \fi
+}%
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\nprt@lpad}
+% Pad a number with a character on the left side.
+% The first argument contains the number, the second is the desired length
+% and the third the padding character.
+% \begin{macrocode}
+\newcommand*\nprt@lpad[3]{%
+% \end{macrocode}
+% If the count of digits is negative, no padding will be performed.
+% \begin{macrocode}
+ \ifnum#2<0
+ \else
+% \end{macrocode}
+% Print a debug message.
+% \begin{macrocode}
+ \nprt@debug{\string\nprt@lpad: Padding #1 with #3 to a length of #2}%
+% \end{macrocode}
+% If the number has less than the desired length, add the padding character
+% to the left and call this function recursively.
+% \begin{macrocode}
+ \ifnum\csname thenprt@#1@digitsbefore\endcsname<#2
+ \expandafter\xdef\csname nprt@#1@before\endcsname{%
+ #3\csname nprt@#1@before\endcsname}%
+ \stepcounter{nprt@#1@digitsbefore}%
+ \nprt@lpad{#1}{#2}{#3}%
+ \fi
+ \fi
+}%
+% \end{macrocode}
+% \end{macro}
+%
+%
+% \subsection{Print the numbers}
+%
+% \begin{macro}{\nprt@sign@+}
+% \begin{macro}{\nprt@sign@-}
+% \begin{macro}{\nprt@sign@+-}
+% Define commands for printing the signs in math mode. This ensures
+% that the printed signs really are signs and not hyphens. Compare
+% ``-'' to ``\ensuremath{-}''.
+% \begin{macrocode}
+\expandafter\newcommand\csname nprt@sign@+\endcsname{\ensuremath{+}}
+\expandafter\newcommand\csname nprt@sign@-\endcsname{\ensuremath{-}}
+\expandafter\newcommand\csname nprt@sign@+-\endcsname{\ensuremath{\pm}}
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \begin{macro}{\nprt@printsign}
+% Print a sign.
+% The first argument contains the number type (``mantissa'' or
+% ``exponent'').
+% The second argument contains the sign as in source code.
+% \begin{macrocode}
+\newcommand*\nprt@printsign[2]{%
+% \end{macrocode}
+% Write sign to log file.
+% \begin{macrocode}
+ \nprt@debug{\string\nprt@printsign: `#2'}%
+% \end{macrocode}
+% Set command in a group to prevent the defined macros from being
+% global.
+% \begin{macrocode}
+ \edef\nprt@marg{#2}%
+% \end{macrocode}
+% If a plus is to be added do it if no sign given.
+% \begin{macrocode}
+ \csname ifnprt@addplus@#1\endcsname
+ \ifx\nprt@marg\@empty
+ \edef\nprt@marg{+}%
+ \fi
+ \fi
+% \end{macrocode}
+% Do nothing if still no sign given.
+% \begin{macrocode}
+ \ifx\nprt@marg\@empty
+ \else
+% \end{macrocode}
+% If a macro \cs{nprt@sign@\meta{sign}} is defined for the given sign,
+% e.g., \cs{nprt@sign@+}, print it; if not, print the sign itself.
+% \changes{1.22}{2004/08/08}{Print sign in a group to avoid additional space
+% for an operator (for nbaseprt)}%
+% \begin{macrocode}
+ \@ifundefined{nprt@sign@\nprt@marg}{%
+ \PackageWarning{numprint}{%
+ Unknown sign `\nprt@marg'. Print as typed in}%
+ \nprt@marg
+ }{%
+ {\csname nprt@sign@\nprt@marg\endcsname}%
+ }%
+ \fi
+}
+% \end{macrocode}
+% \end{macro}
+% Internal counters for printing.
+% \begin{macrocode}
+\newcounter{nprt@digitsfirstblock}
+\newcounter{nprt@blockcnt}
+% \end{macrocode}
+% Internal boolean.
+% \begin{macrocode}
+\newif\ifnprt@shortnumber
+% \end{macrocode}
+% \begin{macro}{\nprt@printbefore}
+% Print the number before the decimal sign.
+% The argument is the Number type (``mantissa'' or ``exponent'').
+% When this macro is called, everything is parsed already.
+% Thus, it is known wheather a decimal sign has been found, which and
+% how many digits are before resp.\ after the decimal sign etc.
+% \begin{macrocode}
+\newcommand*\nprt@printbefore[1]{%
+% \end{macrocode}
+% If missing zeros shall be added and there is no digit before the
+% decimal sign store that ``0'' into the corresponding command and
+% store in the counter that the number of digits before the decimal
+% sign is one, know.
+% \begin{macrocode}
+ \ifnprt@addmissingzero
+ \ifnum\csname thenprt@#1@digitsbefore\endcsname=0
+ \expandafter\edef\csname nprt@#1@before\endcsname{0}%
+ \stepcounter{nprt@#1@digitsbefore}%
+ \fi
+ \fi
+% \end{macrocode}
+% I'm not sure why I have added the group here.
+% But it works and I won't change it, therefore.
+% \begin{macrocode}
+ \begingroup
+% \end{macrocode}
+% Store the number to be printed in \cs{nprt@numbertoprint} in order
+% to have simpler calls in this routine than using \cs{csname}\ldots
+% \begin{macrocode}
+ \edef\nprt@numbertoprint{\csname nprt@#1@before\endcsname}%
+% \end{macrocode}
+% If four-digit numbers are not to be separated and both, the integer
+% and the real parts, are shorter than 5 digits, set the boolean
+% \cs{ifnprt@shortnumber} to ``true'' that the number is printed
+% without separators, later.
+% \begin{macrocode}
+ \ifnprt@numsepfour
+ \else
+ \ifnum\csname thenprt@#1@digitsbefore\endcsname<5
+ \ifnum\csname thenprt@#1@digitsafter\endcsname<5
+ \nprt@shortnumbertrue
+ \fi
+ \fi
+ \fi
+% \end{macrocode}
+% If the number is short according to the preceeding code, just print
+% that number by calling \cs{nprt@numbertoprint}.
+% \begin{macrocode}
+ \ifnprt@shortnumber
+ \nprt@numbertoprint
+ \else
+% \end{macrocode}
+% If the number will get separators, calculate how many separators
+% will be inserted.
+% \begin{macrocode}
+ % ganze Bloecke
+ \setcounter{nprt@blockcnt}{%
+ \csname thenprt@#1@digitsbefore\endcsname}%
+ \addtocounter{nprt@blockcnt}{-1}%
+ \divide\c@nprt@blockcnt 3%
+% \end{macrocode}
+% Then, calculate how many digits are in the first block (one, two, or
+% three).
+% Use \cs{c@nprt@cntprint} as temporary variable.
+% \begin{macrocode}
+ \setcounter{nprt@digitsfirstblock}{%
+ \csname thenprt@#1@digitsbefore\endcsname}%
+ \setcounter{nprt@cntprint}{\thenprt@blockcnt}%
+ \multiply \c@nprt@cntprint 3%
+ \addtocounter{nprt@digitsfirstblock}{-\thenprt@cntprint}%
+% \end{macrocode}
+% Depending on that number, call \cs{nprt@printone},
+% \cs{nprt@printtwo}, resp.\ \cs{nprt@printthree} which do what you
+% may expect with that names.
+% \begin{macrocode}
+ \ifnum\thenprt@digitsfirstblock=1
+ \expandafter\nprt@printone\nprt@numbertoprint\@empty
+ \else
+ \ifnum\thenprt@digitsfirstblock=2
+ \expandafter\nprt@printtwo\nprt@numbertoprint\@empty
+ \else
+ \ifnum\thenprt@digitsfirstblock=3
+ \expandafter\nprt@printthree\nprt@numbertoprint\@empty
+ \else
+ \ifnum\thenprt@digitsfirstblock=0
+ \else
+ \PackageError{numprint}{internal error}{}%
+ \fi
+ \fi
+ \fi
+ \fi
+ \fi
+ \endgroup
+}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\nprt@printthree}
+% Print three digits.
+% If the command has not reached the end of the string, print a
+% separator \cs{nprt@separator@before} and call this routine
+% recursively.
+% \begin{macrocode}
+\def\nprt@printthree#1#2#3#4\@empty{%
+ #1#2#3%
+ \def\nprt@tmp{#4}%
+ \ifx\nprt@tmp\empty
+ \else
+ \nprt@separator@before%
+ \nprt@printthree#4\@empty\@empty\@empty
+ \fi
+}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\nprt@printtwo}
+% The same but start with two instead of three digits.
+% \begin{macrocode}
+\def\nprt@printtwo#1#2#3\@empty{%
+ #1#2%
+ \def\nprt@tmp{#3}%
+ \ifx\nprt@tmp\empty
+ \else
+ \nprt@separator@before%
+ \nprt@printthree#3\@empty\@empty\@empty
+ \fi
+}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\nprt@printone}
+% The same but start with one instead of three digits.
+% \begin{macrocode}
+\def\nprt@printone#1#2\@empty{%
+ #1%
+ \def\nprt@tmp{#2}%
+ \ifx\nprt@tmp\empty
+ \else
+ \nprt@separator@before%
+ \nprt@printthree#2\@empty\@empty\@empty
+ \fi
+}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\nprt@printafter}
+% Print the number after the decimal sign.
+% The argument is the Number type (``mantissa'' or ``exponent'').
+% This macro works similarly as \cs{nprt@printbefore}.
+% \begin{macrocode}
+\newcommand*\nprt@printafter[1]{%
+% \end{macrocode}
+% If a missing zero shall be added do it if no digits are given after
+% the decimal sign if a decimal sign has been given.
+% If no decimal sign has been given, the number is pure integer and
+% does not get a real part.
+% \begin{macrocode}
+ \csname ifnprt@#1@decimalfound\endcsname
+ \ifnprt@addmissingzero
+ \ifnum\csname thenprt@#1@digitsafter\endcsname=0
+ \expandafter\edef\csname nprt@#1@after\endcsname{0}%
+ \stepcounter{nprt@#1@digitsafter}%
+ \fi
+ \fi
+% \end{macrocode}
+% If a after-decimal zero will be replaced by another command but the
+% real part is empty, put a ``0'' after the comma (same as
+% ``addmissingzero'', but here it is just a hack in order to enable
+% the replacement command to take effect later).
+% \begin{macrocode}
+ \ifx\nprt@replacenull\@empty
+ \else
+ \ifnum\csname thenprt@#1@digitsafter\endcsname=0
+ \expandafter\edef\csname nprt@#1@after\endcsname{0}%
+ \stepcounter{nprt@#1@digitsafter}%
+ \fi
+ \fi
+ \fi
+% \end{macrocode}
+% Store the number in \cs{nprt@numbertoprint} and continue only if it
+% is not empty.
+% \begin{macrocode}
+ \begingroup
+ \edef\nprt@numbertoprint{\csname nprt@#1@after\endcsname}%
+ \ifx\nprt@numbertoprint\@empty
+ \else
+% \end{macrocode}
+% Find out wheather separators have to be inserted.
+% \begin{macrocode}
+ \ifnprt@numsepfour
+ \else
+ \ifnum\csname thenprt@#1@digitsbefore\endcsname<5
+ \ifnum\csname thenprt@#1@digitsafter\endcsname<5
+ \nprt@shortnumbertrue
+ \fi
+ \fi
+ \fi
+% \end{macrocode}
+% If a zero has to be replaced by a replacement text, and if the after
+% comma part has the numerical value ``0'' (= it contains of zeros
+% only), do the replacement.
+% \begin{macrocode}
+ \ifx\nprt@replacenull\@empty
+ \else
+ \ifnum\nprt@numbertoprint=0
+ \nprt@shortnumbertrue
+ \edef\nprt@numbertoprint{\nprt@replacenull}%
+ \fi
+ \fi
+% \end{macrocode}
+% If the number is short (without separators) just print it.
+% \begin{macrocode}
+ \ifnprt@shortnumber
+ \nprt@numbertoprint
+ \else
+% \end{macrocode}
+% Print the number with separators.
+% The choice between different block sizes does not have to be done
+% because the after-decimal-sign part starts with three-digit block
+% from the left end.
+% \begin{macrocode}
+ \expandafter\nprt@printthree@after%
+ \nprt@numbertoprint\@empty\@empty\@empty
+ \fi
+ \fi
+ \endgroup
+}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\nprt@printthree@after}
+% The same as \cs{nprt@printthree} but with another separator.
+% \begin{macrocode}
+\def\nprt@printthree@after#1#2#3#4\@empty{%
+ #1#2#3%
+ \def\nprt@tmp{#4}%
+ \ifx\nprt@tmp\empty
+ \else
+ \nprt@separator@after
+ \nprt@printthree@after#4\@empty\@empty\@empty
+ \fi
+}
+% \end{macrocode}
+% \end{macro}
+%
+%
+% \subsection{The main command}%
+% \label{sec:code:main}%
+%
+% \begin{macro}{\numprint}
+% The main macro of the package.
+% The mandatory argument takes a number and prints it as described
+% above.
+% The optional argument may contain a unit which then is printed,
+% too.
+% \begin{macrocode}
+\DeclareRobustCommand*\numprint[2][\@empty]{%
+% \end{macrocode}
+% Switch off the error flag.
+% This should not be necessary but is done for stability reasons.
+% \begin{macrocode}
+ \nprt@argumenterrorfalse
+% \end{macrocode}
+% Clear the mantissa and the exponent.
+% \begin{macrocode}
+ \xdef\nprt@exponent{\@empty}%
+ \xdef\nprt@mantissa{\@empty}%
+% \end{macrocode}
+% Do everything inside a group to avoid defining too many temporary
+% macros that are not deleted after the macro.
+% \begin{macrocode}
+ \begingroup
+% \end{macrocode}
+% Store the mandatory argument into a macro.
+% Redefine \cs{,} and |~| to do nothing as to ignore them.
+% Because the argument is expanded this does not work with the ignore
+% list for characters.
+% This again has to be done inside a group to preserve the two macros
+% for later usage.
+% \begin{macrocode}
+ \begingroup
+ \def\,{}%
+ \catcode`\~=\active % tilde is active
+ \def~{}%
+ \xdef\nprt@marg{#2}%
+ \endgroup
+% \end{macrocode}
+% Don't expand the unit because that may cause trouble.
+% \begin{macrocode}
+ \def\nprt@oarg{#1}%
+% \end{macrocode}
+% Declare some commands to detect empty arguments.
+% \begin{macrocode}
+ \def\nprt@@empty{\@empty}%
+ \def\nprt@nix{}%
+ \def\nprt@nixleer{ }%
+% \end{macrocode}
+% Some debug information.
+% \begin{macrocode}
+ \ifx\nprt@oarg\nprt@@empty
+ \nprt@debug{\string\numprint{\protect#2}}%
+ \else
+ \nprt@debug{\string\numprint[\protect#1]{\protect#2}}%
+ \fi
+% \end{macrocode}
+% Test for an empty mandatory argument.
+% \begin{macrocode}
+ \ifx\nprt@marg\nprt@nix
+ \nprt@error{empty argument}{You have to specify a number in
+ the argument of \string\numprint}%
+ \fi
+ \ifx\nprt@marg\nprt@nixleer
+ \nprt@error{empty argument}{You have to specify a number in
+ the argument of \string\numprint}%
+ \fi
+% \end{macrocode}
+% Test wheather only valid characters have been used and devide the
+% argument in the mantissa and the exponent.
+% \begin{macrocode}
+ \expandafter\nprt@testcharacter\nprt@marg\@empty\@empty
+% \end{macrocode}
+% If there are invalid characters in the argument, just print the
+% argument without formatting it.
+% Redefine \cs{pm} to avoid an additional error in text mode.
+% \begin{macrocode}
+ \ifnprt@argumenterror
+ \begingroup\def\pm{+-}#2\endgroup
+ \else
+% \end{macrocode}
+% If everything is okay, proceed with parsing.
+%
+% \changes{1.31}{2004/08/18}{Bugfix: \cs{numprint\{e123\}} reprinted the
+% last used sign}%
+% If the mantissa is empty don't work on it but reset the sign of the
+% mantissa to avoid to reprint the old sign when using
+% \cs{numprint\{e123\}}.
+% If it is not empty, parse it for a sign and a number.
+% \begin{macrocode}
+ \ifx\nprt@mantissa\@empty
+ \def\nprt@mantissa@sign{\@empty}%
+ \else
+ \nprt@testsign{mantissa}{\nprt@mantissa}%
+ \fi
+% \end{macrocode}
+% If the mantissa contains only a sign, \cs{nprt@mantissa} is set to
+% \cs{@empty} and thus empty even if it wasn't 4 lines above.
+% If the mantissa only contains of a sign and an exponent is given,
+% everything is fine.
+% If no exponent is given, the input format is invalid.
+% \begin{macrocode}
+ \ifx\nprt@mantissa\@empty
+ \ifx\nprt@exponent\@empty
+ \nprt@error{Invalid number format. Printing the
+ argument\MessageBreak
+ verbatim}{Something is wrong in the format of the number}%
+ \else
+ \nprt@printsign{mantissa}{\nprt@mantissa@sign}%
+ \fi
+ \else
+% \end{macrocode}
+% Round the mantissa if necessary.
+% \begin{macrocode}
+ \nprt@round{mantissa}{\nprt@rounddigits}%
+% \end{macrocode}
+% Pad the mantissa if necessary.
+% \begin{macrocode}
+ \nprt@lpad{mantissa}{\nprt@lpaddigits}{\nprt@lpadchar}%
+ \fi
+% \end{macrocode}
+% If an exponent has been found, parse this like the mantissa.
+% \begin{macrocode}
+ \ifnprt@expfound
+% \end{macrocode}
+% Test wheather an exponent character was given but no exponent.
+% \begin{macrocode}
+ \ifx\nprt@exponent\@empty
+ \nprt@error{Empty exponent}{If you specify an exponent
+ using one of the characters `\nprt@explist' you
+ have\MessageBreak
+ to give an exponent, too.}%
+ \else
+ \nprt@testsign{exponent}{\nprt@exponent}%
+ \nprt@round{exponent}{\nprt@roundexpdigits}%
+ \fi
+ \fi
+% \end{macrocode}
+% If either the mantissa or the exponent produces an error, just print
+% the argument as is.
+% Redefine \cs{pm} to avoid an additional error in text mode.
+% \begin{macrocode}
+ \ifnprt@argumenterror
+ \begingroup\def\pm{+-}#2\endgroup
+ \else
+% \end{macrocode}
+% Print the mantissa if present.
+% \begin{macrocode}
+ \ifx\nprt@mantissa\@empty
+ \else
+% \end{macrocode}
+% Print the part before the decimal sign.
+%
+% If the number shall be printed in a box (table alignment) some
+% special things have to be done.
+% \begin{macrocode}
+ \ifnprt@mantissa@fixeddigits
+ \ifmmode
+% \end{macrocode}
+% In math mode, it must be decided which math style is active because
+% the width of the box depends on that.
+% The \cs{mathchoice} command does the formatting for all styles and
+% typesets the active one then.
+% \begin{macrocode}
+ \mathchoice{%
+% \end{macrocode}
+% Calculate the width of the block for the \cs{displaystyle}.
+% \begin{macrocode}
+ \nprt@calcblockwidth{mantissa}{before}{\displaystyle}%
+% \end{macrocode}
+% Generate a box with the calculated width and the corresponding math
+% style.
+% \begin{macrocode}
+ \makebox[\the\nprt@blockwidth][r]{$\displaystyle
+% \end{macrocode}
+% Print the sign if present.
+% \begin{macrocode}
+ \nprt@printsign{mantissa}{\nprt@mantissa@sign}%
+% \end{macrocode}
+% Print the integer part into the box.
+% \begin{macrocode}
+ \nprt@printbefore{mantissa}$}%
+ }{%
+% \end{macrocode}
+% Do the same for \cs{textstyle}.
+% \begin{macrocode}
+ \nprt@calcblockwidth{mantissa}{before}{\textstyle}%
+ \makebox[\the\nprt@blockwidth][r]{$\textstyle
+ \nprt@printsign{mantissa}{\nprt@mantissa@sign}%
+ \nprt@printbefore{mantissa}$}%
+ }{%
+% \end{macrocode}
+% Do the same for \cs{scriptstyle}.
+% \begin{macrocode}
+ \nprt@calcblockwidth{mantissa}{before}{\scriptstyle}%
+ \makebox[\the\nprt@blockwidth][r]{$\scriptstyle
+ \nprt@printsign{mantissa}{\nprt@mantissa@sign}%
+ \nprt@printbefore{mantissa}$}%
+ }{%
+% \end{macrocode}
+% Do the same for \cs{scriptscriptstyle}.
+% \begin{macrocode}
+ \nprt@calcblockwidth{mantissa}{before}{\scriptscriptstyle}%
+ \makebox[\the\nprt@blockwidth][r]{$\scriptscriptstyle
+ \nprt@printsign{mantissa}{\nprt@mantissa@sign}%
+ \nprt@printbefore{mantissa}$}%
+ }%
+ \else
+% \end{macrocode}
+% If the number is printed in text mode, the size is preserved inside
+% the box.
+% Thus, no hack as for math mode is necessary.
+% \begin{macrocode}
+ \nprt@calcblockwidth{mantissa}{before}{\@empty}%
+ \makebox[\the\nprt@blockwidth][r]{%
+ \nprt@printsign{mantissa}{\nprt@mantissa@sign}%
+ \nprt@printbefore{mantissa}%
+ }%
+ \fi
+ \else
+% \end{macrocode}
+% If the number is printed without fixed width, just print it.
+% \begin{macrocode}
+ \nprt@printsign{mantissa}{\nprt@mantissa@sign}%
+ \nprt@printbefore{mantissa}%
+ \fi
+% \end{macrocode}
+% Print the after-decimal-sign digits.
+% This works exactly as the integer part.
+% \begin{macrocode}
+ \ifnprt@mantissa@fixeddigits
+ \ifmmode
+ \mathchoice{%
+ \nprt@calcblockwidth{mantissa}{after}{\displaystyle}%
+ \makebox[\the\nprt@blockwidth][l]{$\displaystyle
+ \ifnprt@mantissa@decimalfound
+ \nprt@decimal
+ \fi
+ \nprt@printafter{mantissa}$}%
+ }{%
+ \nprt@calcblockwidth{mantissa}{after}{\textstyle}%
+ \makebox[\the\nprt@blockwidth][l]{$\textstyle
+ \ifnprt@mantissa@decimalfound
+ \nprt@decimal
+ \fi
+ \nprt@printafter{mantissa}$}%
+ }{%
+ \nprt@calcblockwidth{mantissa}{after}{\scriptstyle}%
+ \makebox[\the\nprt@blockwidth][l]{$\scriptstyle
+ \ifnprt@mantissa@decimalfound
+ \nprt@decimal
+ \fi
+ \nprt@printafter{mantissa}$}%
+ }{%
+ \nprt@calcblockwidth{mantissa}{after}{\scriptscriptstyle}%
+ \makebox[\the\nprt@blockwidth][l]{$\scriptscriptstyle
+ \ifnprt@mantissa@decimalfound
+ \nprt@decimal
+ \fi
+ \nprt@printafter{mantissa}$}%
+ }%
+ \else
+ \nprt@calcblockwidth{mantissa}{after}{\@empty}%
+ \makebox[\the\nprt@blockwidth][l]{%
+ \ifnprt@mantissa@decimalfound
+ \nprt@decimal
+ \fi
+ \nprt@printafter{mantissa}%
+ }%
+ \fi
+ \else
+ \ifnprt@mantissa@decimalfound
+ \nprt@decimal
+ \fi
+ \nprt@printafter{mantissa}%
+ \fi
+ \fi
+% \end{macrocode}
+% If an exponent is defined it has to be printed later.
+% Therefore, define the command \cs{nprt@printexp} that just prints
+% its argument.
+% \begin{macrocode}
+ \ifnprt@expfound
+ \def\nprt@printexp##1{##1}%
+% \end{macrocode}
+% If a sign but no number has been given for the exponent
+% \cs{nprt@exponent} is empty but \cs{ifnprt@expfound} true.
+% Test for this case here.
+% \begin{macrocode}
+ \ifx\nprt@exponent\@empty
+ \nprt@error{Invalid number format in
+ exponent. Printing\MessageBreak
+ garbage}{Something is wrong in the format of the exponent}%
+ \fi
+ \else
+% \end{macrocode}
+% If there is no exponent but digits reserved for it, define the
+% \cs{nprt@printexp} so that is just needs that space but does not
+% print anything.
+% \begin{macrocode}
+ \ifnprt@exponent@fixeddigits
+ \def\nprt@printexp##1{\hphantom{##1}}%
+ \else
+% \end{macrocode}
+% If there is no exponent and no reserved digits, don't print the
+% exponent.
+% \begin{macrocode}
+ \def\nprt@printexp##1{}%
+ \fi
+ \fi
+% \end{macrocode}
+% If\label{page:code:color} negative numbers are printed in red (as
+% shown in section~\ref{sec:negative-red}), a positive mantissa with a
+% negative exponent would normally lead to a black mantissa with a
+% red exponent.
+% To avoid that the \cs{color} command is redefined to do nothing
+% here.
+% Do it in a group to restrain this to the exponent itself.
+% \changes{1.22}{2004/08/08}{Restrain empty \cs{color} command to
+% exponent}%
+% \begin{macrocode}
+ \begingroup
+ \def\color##1{}%
+% \end{macrocode}
+% Call the command that either print the exponent, reserves space as
+% it were printed or does nothing.
+% \begin{macrocode}
+ \nprt@printexp{%
+% \end{macrocode}
+% If not mantissa is specified, print the short version, e.g.,
+% $10^{123}$ and thus leave out the product sign.
+% \begin{macrocode}
+ \ifx\nprt@mantissa\@empty
+ \else
+% \end{macrocode}
+% Print out the product sign, if there is a mantissa.
+% \begin{macrocode}
+ \nprt@prod
+ \fi
+% \end{macrocode}
+% Print ``10'' and the exponent.
+% This is different between text and math mode.
+% \begin{macrocode}
+ \ifmmode 10^\else 10\expandafter\textsuperscript\fi{%
+% \end{macrocode}
+% Print the number before the decimal sign.
+% As the mantissa.
+% \begin{macrocode}
+ \ifnprt@exponent@fixeddigits
+ \ifmmode
+ \mathchoice{%
+ \nprt@calcblockwidth{exponent}{before}{\displaystyle}%
+ \makebox[\the\nprt@blockwidth][r]{$\displaystyle
+ \nprt@printsign{exponent}{\nprt@exponent@sign}%
+ \nprt@printbefore{exponent}$}%
+ }{%
+ \nprt@calcblockwidth{exponent}{before}{\textstyle}%
+ \makebox[\the\nprt@blockwidth][r]{$\textstyle
+ \nprt@printsign{exponent}{\nprt@exponent@sign}%
+ \nprt@printbefore{exponent}$}%
+ }{%
+ \nprt@calcblockwidth{exponent}{before}{\scriptstyle}%
+ \makebox[\the\nprt@blockwidth][r]{$\scriptstyle
+ \nprt@printsign{exponent}{\nprt@exponent@sign}%
+ \nprt@printbefore{exponent}$}%
+ }{%
+ \nprt@calcblockwidth{exponent}{before}{\scriptscriptstyle}%
+ \makebox[\the\nprt@blockwidth][r]{$\scriptscriptstyle
+ \nprt@printsign{exponent}{\nprt@exponent@sign}%
+ \nprt@printbefore{exponent}$}%
+ }%
+ \else
+ \nprt@calcblockwidth{exponent}{before}{\@empty}%
+ \makebox[\the\nprt@blockwidth][r]{%
+ \nprt@printsign{exponent}{\nprt@exponent@sign}%
+ \nprt@printbefore{exponent}%
+ }%
+ \fi
+ \else
+ \nprt@printsign{exponent}{\nprt@exponent@sign}%
+ \nprt@printbefore{exponent}%
+ \fi
+% \end{macrocode}
+% Produce a warning since this is uncommon in exponents.
+% \begin{macrocode}
+ \ifnprt@exponent@decimalfound
+ \PackageWarning{numprint}{Non-integer exponent}%
+ \fi
+% \end{macrocode}
+% Print the part after the decimal sign.
+% \begin{macrocode}
+ \ifnprt@exponent@fixeddigits
+ \ifmmode
+ \mathchoice{%
+ \nprt@calcblockwidth{exponent}{after}{\displaystyle}%
+ \makebox[\the\nprt@blockwidth][l]{$\displaystyle
+ \ifnprt@exponent@decimalfound
+ \nprt@decimal
+ \fi
+ \nprt@printafter{exponent}$}%
+ }{%
+ \nprt@calcblockwidth{exponent}{after}{\textstyle}%
+ \makebox[\the\nprt@blockwidth][l]{$\textstyle
+ \ifnprt@exponent@decimalfound
+ \nprt@decimal
+ \fi
+ \nprt@printafter{exponent}$}%
+ }{%
+ \nprt@calcblockwidth{exponent}{after}{\scriptstyle}%
+ \makebox[\the\nprt@blockwidth][l]{$\scriptstyle
+ \ifnprt@exponent@decimalfound
+ \nprt@decimal
+ \fi
+ \nprt@printafter{exponent}$}%
+ }{%
+ \nprt@calcblockwidth{exponent}{after}{\scriptscriptstyle}%
+ \makebox[\the\nprt@blockwidth][l]{$\scriptscriptstyle
+ \ifnprt@exponent@decimalfound
+ \nprt@decimal
+ \fi
+ \nprt@printafter{exponent}$}%
+ }%
+ \else
+ \nprt@calcblockwidth{exponent}{after}{\@empty}%
+ \makebox[\the\nprt@blockwidth][l]{%
+ \ifnprt@exponent@decimalfound
+ \nprt@decimal
+ \fi
+ \nprt@printafter{exponent}%
+ }%
+ \fi
+ \else
+ \ifnprt@exponent@decimalfound
+ \nprt@decimal
+ \fi
+ \nprt@printafter{exponent}%
+ \fi
+ }% 10^
+ }% \nprt@printexp
+ \endgroup
+ \fi
+ \fi
+% \end{macrocode}
+% If the unit is not empty, print it, too.
+% \begin{macrocode}
+ \ifx\nprt@oarg\nprt@@empty
+ \else
+% \end{macrocode}
+% All units expect the degree symbol are separated from the number.
+% Detect wheather the degree symbol is used.
+%
+% \changes{1.22}{2004/08/08}{Produce a warning rather than an error
+% when using \cs{textdegree} as unit}%
+% The \cs{textdegree} command is not useable in math mode.
+% Redeclare it to generate a warning and to use \cs{tcdegree}
+% instead.
+% \begin{macrocode}
+ \def\textdegree{%
+ \PackageWarning{numprint}{The unit is typeset in mathmode. Use
+ \string\tcdegree\space of\MessageBreak
+ the mathcomp package or \string\degree\space of the
+ gensymb\MessageBreak
+ package}%
+% \end{macrocode}
+% Call \cs{tcdegree} via \cs{csname} in order to avoid a second error
+% message if \cs{tcdegree} is not present (because of not loading
+% |mathcomp.sty|.
+% \begin{macrocode}
+ \csname tcdegree\endcsname
+ }%
+% \end{macrocode}
+% \changes{1.22}{2004/08/08}{Enable to use \cs{textcelsius},
+% \cs{textohm}, \cs{textmu}, and \cs{textperthousand} in the unit}%
+% \changes{1.32}{2004/09/13}{Produce an error rather than a warning
+% when using \texttt{textcomp} symbols in the unit if
+% \texttt{mathcomp} or \texttt{gensymb} is not loaded}%
+% Handle \cs{textcelsius}, \cs{textohm}, \cs{textmu}, and
+% \cs{textperthousand} in the same way as \cs{textdegree}.
+% \begin{macrocode}
+ \def\nprt@PackageError##1##2{\PackageWarning{numprint}{##1}}%
+ \def\textcelsius{%
+ \begingroup
+ \@ifundefined{tccelsius}{\@ifundefined{celsius}{%
+ \def\nprt@PackageError####1####2{%
+ \PackageError{numprint}{####1}{####2}}%
+ }{\celsius}}{\tccelsius}%
+ \nprt@PackageError{The unit is typeset in
+ mathmode. Use \string\tccelsius\space of\MessageBreak
+ the mathcomp package or \string\celsius\space of the
+ gensymb\MessageBreak
+ package}{If you load the mathcomp package
+ \string\textcelsius\space is substituted by
+ \string\tccelsius. If you load the gensymb package
+ \string\textcelsius\space is substituted by \string\celsius.}%
+ \endgroup
+ }%
+ \def\textohm{%
+ \begingroup
+ \@ifundefined{tcohm}{\@ifundefined{ohm}{%
+ \def\nprt@PackageError####1####2{%
+ \PackageError{numprint}{####1}{####2}}%
+ }{\ohm}}{\tcohm}%
+ \nprt@PackageError{The unit is typeset in
+ mathmode. Use \string\tcohm\space of\MessageBreak
+ the mathcomp package or \string\ohm\space of the
+ gensymb\MessageBreak
+ package}{If you load the mathcomp package
+ \string\textohm\space is substituted by
+ \string\tcohm. If you load the gensymb package
+ \string\textohm\space is substituted by \string\ohm.}%
+ \endgroup
+ }%
+ \def\textmu{%
+ \begingroup
+ \@ifundefined{tcmu}{%
+ \def\nprt@PackageError####1####2{%
+ \PackageError{numprint}{####1}{####2}}%
+ }{\tcmu}%
+ \nprt@PackageError{The unit is typeset in
+ mathmode. Use \string\tcmu\space of\MessageBreak
+ the mathcomp package}{If you load the mathcomp package
+ \string\textmu\space is substituted by \string\tcmu.}%
+ \endgroup
+ }%
+ \def\textperthousand{%
+ \begingroup
+ \@ifundefined{tcperthousand}{\@ifundefined{perthousand}{%
+ \def\nprt@PackageError####1####2{%
+ \PackageError{numprint}{####1}{####2}}%
+ }{\perthousand}}{\tcperthousand}%
+ \nprt@PackageError{The unit is typeset in
+ mathmode. Use \string\tcperthousand\MessageBreak
+ of the mathcomp package or \string\perthousand\space of
+ the\MessageBreak
+ gensymb package}{If you load the mathcomp package
+ \string\textperthousand\space is substituted by
+ \string\tcperthousand. If you load the gensymb package
+ \string\textperthousand\space is substituted by
+ \string\perthousand.}%
+ \endgroup
+ }%
+% \end{macrocode}
+% If the unit is \cs{tcdegree} from the \texttt{mathcomp} package, the
+% unit is a degree sign.
+% Then print the separator \cs{nprt@degreesep} instead of
+% \cs{nprt@unitsep}.
+% \begin{macrocode}
+ \def\nprt@tmpunit{\tcdegree}%
+ \ifx\nprt@oarg\nprt@tmpunit
+ \ensuremath{\nprt@degreesep}%
+ \else
+% \end{macrocode}
+% If the unit is \cs{degree} from the \texttt{gensymb} package, the
+% unit is a degree sign.
+% Then print the separator \cs{nprt@degreesep} instead of
+% \cs{nprt@unitsep}.
+% \begin{macrocode}
+ \def\nprt@tmpunit{\degree}%
+ \ifx\nprt@oarg\nprt@tmpunit
+ \ensuremath{\nprt@degreesep}%
+ \else
+% \end{macrocode}
+% If the unit is \cs{textdegree} from the \texttt{textcomp} package, the
+% unit is a degree sign.
+% Then print the separator \cs{nprt@degreesep} instead of
+% \cs{nprt@unitsep}.
+% \begin{macrocode}
+ \def\nprt@tmpunit{\textdegree}%
+ \ifx\nprt@oarg\nprt@tmpunit
+ \ensuremath{\nprt@degreesep}%
+ \else
+% \end{macrocode}
+% If the unit is \cs{\%}, the unit is a percent sign.
+% Then print the separator \cs{nprt@percentsep} instead of
+% \cs{nprt@unitsep}.
+% \begin{macrocode}
+ \def\nprt@tmpunit{\%}%
+ \ifx\nprt@oarg\nprt@tmpunit
+ \ensuremath{\nprt@percentsep}%
+ \else
+% \end{macrocode}
+% Else, print \cs{nprt@unitsep}.
+% \begin{macrocode}
+ \ensuremath{\nprt@unitsep}%
+ \fi
+ \fi
+ \fi
+ \fi
+% \end{macrocode}
+% Finally, print the unit.
+% \begin{macrocode}
+ \npunitcommand{\nprt@oarg}%
+ \fi
+ \endgroup
+}
+% \end{macrocode}
+% \end{macro}
+%
+%
+% \subsection{Print lengths and counters}%
+% \label{sec:code:lenprint}%
+%
+% \begin{macro}{\cntprint}
+% The macro for printing counters.
+% The mandatory argument takes a \LaTeX\ counter.
+% The optional argument may contain a unit which is printed, too.
+% \begin{macrocode}
+\newcounter{nprt@cntprint}
+\DeclareRobustCommand*\cntprint[2][\@empty]{%
+ \@ifundefined{c@#2}{\@nocounterr{#2}}{%
+ \numprint[#1]{\arabic{#2}}%
+ }%
+}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\lenprint}
+% The macro for printing lengths.
+% The mandatory argument takes a \TeX\ dimension or a counter.
+% The optional argument may contain a unit that is used to convert the
+% unit from |pt| to the given value and which then is printed, too.
+% \begin{macrocode}
+\DeclareRobustCommand*\lenprint[2][\@empty]{%
+% \end{macrocode}
+% Do everything in a group to avoid macros to resist outside.
+% \begin{macrocode}
+ \begingroup
+% \end{macrocode}
+% Save the optional argument in \cs{nprt@oarg} and expand it.
+% \begin{macrocode}
+ \edef\nprt@oarg{#1}%
+% \end{macrocode}
+% If no optional argument has been given, change it to |pt|.
+% This cannot be done as default argument in the
+% \cs{DeclareRobustCommand*} definition since printing of counters
+% does not have |pt| as default.
+% \begin{macrocode}
+ \edef\nprt@tmp{\@empty}%
+ \ifx\nprt@oarg\nprt@tmp
+ \def\nprt@oarg{pt}%
+ \fi
+% \end{macrocode}
+% If the chosen unit is not defined produce an error message and fall
+% back to |pt|.
+% \begin{macrocode}
+ \@ifundefined{nprt@factor@\nprt@oarg}{%
+ \PackageError{numprint}{Invalid unit `#1'}{%
+ The requested unit is not defined using \string\npdefunit.^^J%
+ Using `pt' instead.}%
+ \def\nprt@oarg{pt}%
+ }{}%
+% \end{macrocode}
+% For later printing, a length is used that is fixed to |pt| as
+% length.
+% If another unit has been chosen a fake length has to be calculated
+% that is as many |pt| long as the original length is in the given
+% unit.
+% Thus, multiply the mandatory argument by the specific factor for the
+% given unit.
+% \begin{macrocode}
+ \setlength{\@tempdima}{#2}%
+ \setlength{\@tempdima}{\csname nprt@factor@\nprt@oarg\endcsname\@tempdima}%
+% \end{macrocode}
+% If the unit name for the given unit is not defined but the factor
+% is an internal error has occured.
+% Produce an error message.
+% \begin{macrocode}
+ \@ifundefined{nprt@unit@\nprt@oarg}{%
+ \PackageError{numprint}{Unknown unit name `\nprt@oarg'}{%
+ Send a bug report to harald.harders@tu-bs.de with a short
+ example showing this bug.}%
+ }{%
+% \end{macrocode}
+% Store the unit name in \cs{nprt@oarg}.
+% \begin{macrocode}
+ \edef\nprt@oarg{\csname nprt@unit@\nprt@oarg\endcsname}%
+ }%
+% \end{macrocode}
+% Finally, call \cs{numprint}.
+% The two \cs{expandafter} are necessary since \cs{numprint} also uses
+% \cs{nprt@oarg} and produces an infinite loop otherwise.
+% \begin{macrocode}
+ \expandafter\numprint\expandafter[\nprt@oarg]{\strip@pt\@tempdima}%
+ \endgroup
+}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\npdefunit}
+% Define a new unit for usage with \cs{lenprint}.
+% First argument: name in the sourcecode.
+% Second argument: printed unit.
+% Third argument: factor from |pt| to the new unit or |*| to preserve
+% old factor.
+% \begin{macrocode}
+\newcommand*\npdefunit[3]{%
+% \end{macrocode}
+% If the third argument is not |*| define the factor for this unit in
+% \cs{nprt@factor@\meta{\#1}}.
+% \begin{macrocode}
+ \if#3*
+ \else
+ \expandafter\def\csname nprt@factor@#1\endcsname{#3}%
+ \fi
+% \end{macrocode}
+% Define the unit name for this unit in \cs{nprt@unit@\meta{\#1}}.
+% \begin{macrocode}
+ \expandafter\def\csname nprt@unit@#1\endcsname{#2}%
+}
+% \end{macrocode}
+% \end{macro}
+% Declare the standard units.
+% \cs{!} is used to delete the unit separator again.
+% This is a hack and does not work in all cases correctly.
+% \begin{macrocode}
+\npdefunit{pt}{pt}{1.00000000000}
+\npdefunit{bp}{bp}{0.99626400996}
+\npdefunit{in}{in}{0.01383700013}
+\npdefunit{ft}{ft}{0.00115308334}
+\npdefunit{mm}{mm}{0.35145980351}
+\npdefunit{cm}{cm}{0.03514598035}
+\npdefunit{m}{m}{0.0003514598035}
+\npdefunit{km}{km}{0.0000003514598035}
+% \end{macrocode}
+%
+%
+% \subsection{Internationalization}
+%
+% \begin{macro}{\nprt@ifundefined}
+% The normal \cs{@ifundefined} command defines the tested macro as
+% side effect.
+% This command is better.
+% Sometimes it will hopefully be unnecessary and supported by the
+% standard (with a different name, of course).
+% \begin{macrocode}
+\newcommand*\nprt@ifundefined[1]{%
+ \begingroup\expandafter\expandafter\expandafter\endgroup
+ \expandafter\ifx\csname #1\endcsname\relax
+ \expandafter\@firstoftwo
+ \else
+ \expandafter\@secondoftwo
+ \fi
+}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\nprt@addto}
+% Adds the code of the second argument to the macro defined in the
+% first argument.
+% This argument has to be specified without the preceeding backslash.
+% The code is added only if the command is defined, already.
+% \begin{macrocode}
+\newcommand\nprt@addto[2]{%
+ \expandafter\nprt@ifundefined{#1}{}{%
+ \expandafter\addto\expandafter{\csname #1\endcsname}{#2}%
+ }%
+}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\npaddtolanguage}
+% Define \cs{npaddtolanguage\marg{Language}\marg{Language
+% definitions}}.
+% Adds the \meta{Language definitions} specified in argument two to
+% the \meta{Language} of argument one.
+% The language definitions have to be provided in a command with the
+% name \cs{npstyle}\meta{Language definitions}.
+% The switching-on command is added to \cs{extras\meta{Language}}
+% while the switching-off command \cs{npstyledefault} is added to
+% \cs{noextras\meta{Language}}.
+%
+% For example, \cs{npaddtolanguage\{UKenglish\}\{english\}} adds the
+% command \cs{npstyleenglish} to \cs{extrasUKenglish} and
+% \cs{npstyledefault} to \cs{noextrasUKenglish}.
+%
+% The \cs{npstyle\meta{Language definitions}} commands are described
+% below.
+% \begin{macrocode}
+\newcommand\npaddtolanguage[2]{%
+ \nprt@addto{extras#1}{\csname npstyle#2\endcsname}%
+ \nprt@addto{noextras#1}{\npstyledefault}%
+}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\npstyledefault}
+% Set the default values for the separators.
+% They are set to the German language because of compatibility with
+% older versions.
+% \begin{macrocode}
+\newcommand*\npstyledefault{%
+ \npthousandsep{\,}%
+ \npdecimalsign{,}%
+ \npproductsign{\cdot}%
+ \npunitseparator{\,}%
+ \npdegreeseparator{}%
+ \nppercentseparator{\nprt@unitsep}%
+}
+% \end{macrocode}
+% \end{macro}
+% Set the default settings (that are actually the same as German).
+% \begin{macrocode}
+ \npstyledefault
+% \end{macrocode}
+% \begin{macro}{\npstylegerman}
+% Sets the parameters to German habit.
+% \begin{macrocode}
+\newcommand*\npstylegerman{%
+ \npthousandsep{\,}%
+ \npdecimalsign{,}%
+ \npproductsign{\cdot}%
+ \npunitseparator{\,}%
+ \npdegreeseparator{}%
+ \nppercentseparator{\nprt@unitsep}%
+}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\npstyleenglish}
+% Sets the parameters to English habit.
+% \begin{macrocode}
+\newcommand*\npstyleenglish{%
+ \npthousandsep{,}%
+ \npdecimalsign{.}%
+ \npproductsign{\times}%
+ \npunitseparator{\,}%
+ \npdegreeseparator{}%
+ \nppercentseparator{\nprt@unitsep}%
+}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\npstyleportuguese}
+% Sets the parameters to German habit.
+% \begin{macrocode}
+\newcommand*\npstyleportuguese{%
+ \npthousandsep{\,}%
+ \npdecimalsign{,}%
+ \npproductsign{\cdot}%
+ \npunitseparator{\,}%
+ \npdegreeseparator{}%
+ \nppercentseparator{\nprt@unitsep}%
+}
+% \end{macrocode}
+% \end{macro}
+% Do the following actions at \cs{begin\{document\}} to ensure that it
+% is done after loading \texttt{babel.sty} if it is loaded at all.
+% \begin{macrocode}
+\AtBeginDocument{%
+% \end{macrocode}
+% By default, automatic language support is switched off for
+% compatiblity reasons.
+% Proceed only if it is switched on.
+% \begin{macrocode}
+ \ifnprt@autolanguage
+% \end{macrocode}
+% Automatic language support only works with babel.
+% \begin{macrocode}
+ \@ifpackageloaded{babel}{%
+% \end{macrocode}
+% Adds the language settings to the known languages if they are
+% provided by babel.
+% The current version knows all German, English, and Portuguese
+% dialects.
+% \begin{macrocode}
+ \npaddtolanguage{UKenglish}{english}%
+ \npaddtolanguage{USenglish}{english}%
+ \npaddtolanguage{american}{english}%
+ \npaddtolanguage{austrian}{german}%
+ \npaddtolanguage{british}{english}%
+ \npaddtolanguage{canadian}{english}%
+ \npaddtolanguage{english}{english}%
+ \npaddtolanguage{german}{german}%
+ \npaddtolanguage{naustrian}{german}%
+ \npaddtolanguage{ngerman}{german}%
+ \npaddtolanguage{brazil}{portuguese}
+ \npaddtolanguage{brazilian}{portuguese}
+ \npaddtolanguage{portuges}{portuguese}
+ \npaddtolanguage{portuguese}{portuguese}
+% \end{macrocode}
+% Set the active language again to activate the extras section.
+% \begin{macrocode}
+ \expandafter\selectlanguage\expandafter{\languagename}%
+ }{%
+% \end{macrocode}
+% If |babel| is not loaded but automatic language support is
+% activated, switch to English as default:
+% \begin{macrocode}
+ \npstyleenglish
+ }%
+ \fi
+}
+% \end{macrocode}
+% Load configuration file if present.
+% \begin{macrocode}
+\InputIfFileExists{numprint.cfg}{%
+ \message{Configuration file `numprint.cfg' loaded.}%
+}{%
+ \message{No configuration file `numprint.cfg' found.}%
+}
+% \end{macrocode}
+% \begin{macro}{\nprt@renameerror}
+% A command for producing an error message for redefined macros.
+% \begin{macrocode}
+\newcommand*\nprt@renameerror[1]{%
+ \expandafter\def\csname #1\endcsname{%
+ \PackageError{numprint}{This command has been renamed
+ to\MessageBreak
+ \string\np #1}{In order to avoid problems with other
+ packages and for consistency, this\MessageBreak
+ command has been renamed in this version.}%
+ }%
+}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\fourdigitsep}
+% \changes{1.00}{2003/10/07}{Renamed to \cs{npfourdigitsep}}%
+% \begin{macro}{\fourdigitnosep}
+% \changes{1.00}{2003/10/07}{Renamed to \cs{npfourdigitnosep}}%
+% \begin{macro}{\addmissingzero}
+% \changes{1.00}{2003/10/07}{Renamed to \cs{npaddmissingzero}}%
+% \begin{macro}{\noaddmissingzero}
+% \changes{1.00}{2003/10/07}{Renamed to \cs{npnoaddmissingzero}}%
+% \begin{macro}{\digits}
+% \changes{1.00}{2003/10/07}{Renamed to \cs{npdigits}}%
+% \begin{macro}{\nodigits}
+% \changes{1.00}{2003/10/07}{Renamed to \cs{npnodigits}}%
+% \begin{macro}{\exponentdigits}
+% \changes{1.00}{2003/10/07}{Renamed to \cs{npexponentdigits}}%
+% \begin{macro}{\noexponentdigits}
+% \changes{1.00}{2003/10/07}{Renamed to \cs{npnoexponentdigits}}%
+% Define replacements for the old commands that produce error
+% messages.
+% \begin{macrocode}
+\nprt@renameerror{fourdigitsep}
+\nprt@renameerror{fourdigitnosep}
+\nprt@renameerror{addmissingzero}
+\nprt@renameerror{noaddmissingzero}
+\nprt@renameerror{digits}
+\nprt@renameerror{nodigits}
+\nprt@renameerror{exponentdigits}
+\nprt@renameerror{noexponentdigits}
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+%
+% \iffalse
+%</package>
+% \fi
+% \Finale
+
diff --git a/Master/texmf-dist/source/latex/numprint/numprint.ins b/Master/texmf-dist/source/latex/numprint/numprint.ins
new file mode 100644
index 00000000000..01b79050be3
--- /dev/null
+++ b/Master/texmf-dist/source/latex/numprint/numprint.ins
@@ -0,0 +1,28 @@
+\input docstrip.tex
+\preamble
+
+ numprint package
+
+ Copyright 2000--2005 Harald Harders
+
+ This program can be redistributed and/or modified under the terms
+ of the LaTeX Project Public License Distributed from CTAN
+ archives in directory macros/latex/base/lppl.txt; either
+ version 1 of the License, or any later version.
+
+ h.harders@tu-bs.de
+
+\endpreamble
+
+\askforoverwritefalse
+
+% Files
+%%%%%%%%%%%%%%%%%%%%%%
+\generate{%
+ \file{numprint.sty}{\from{numprint.dtx}{package}}%
+ \file{numprint032.sty}{\from{numprint032.dtx}{package}}%
+ \file{nbaseprt.sty}{\from{nbaseprt.dtx}{package}}%
+}%
+
+\Msg{* Ready}
+\endbatchfile
diff --git a/Master/texmf-dist/source/latex/numprint/numprint032.dtx b/Master/texmf-dist/source/latex/numprint/numprint032.dtx
new file mode 100644
index 00000000000..7458c7f7f06
--- /dev/null
+++ b/Master/texmf-dist/source/latex/numprint/numprint032.dtx
@@ -0,0 +1,1532 @@
+% \iffalse meta comment
+% File: numprint.dtx Copyright (C) 2000--2004 Harald Harders
+% \fi
+%
+% \iffalse
+%
+%<*package>
+\def\packagename{numprint}
+\def\nprtfileversion{0.32}
+\def\nprtfiledate{2003/09/18}
+\def\nprtdocdate{2003/09/18}
+%</package>
+%<*driver>
+\documentclass{ltxdoc}
+\IfFileExists{numprint.sty}{\usepackage{numprint}
+ \let\numprintSTYfound\active}{\GenericWarning{numprint.dtx}{Package
+ file numprint.sty not found (Documentation will be messed up!^^J^^A
+ Generate numprint.sty by (La)TeXing numprint.ins, process
+ numprint.dtx again)^^J}\stop}
+\usepackage{longtable}
+\title{The \texttt{numprint} package\thanks{This file has version
+ \nprtfileversion\ last revised \nprtfiledate, documentation dated
+ \nprtdocdate.}}
+\author{Harald Harders\\\texttt{h.harders@tu-bs.de}}
+\date{File Date \nprtfiledate, Printed \today}
+\npdecimalsign{.}%
+\newlength{\tempdima}%
+\makeatletter
+\renewenvironment{table}[1][]{%
+ \@float{table}[#1]%
+ \centering%
+ \setlength{\tempdima}{\abovecaptionskip}%
+ \setlength{\abovecaptionskip}{\belowcaptionskip}%
+ \setlength{\belowcaptionskip}{\tempdima}%
+ }{%
+\end@float
+}
+\makeatother
+\EnableCrossrefs
+\CodelineIndex
+\DoNotIndex{\def,\edef,\let,\newcommand,\newenvironment,\newcounter}
+\DoNotIndex{\setcounter,\space,\if,\else,\fi,\empty,\@empty,\ifx,\fi}
+\DoNotIndex{\ifnum,\fi,\expandafter}
+\CodelineNumbered
+\RecordChanges
+%\CheckSum{1016}
+\begin{document}
+ \DocInput{numprint.dtx}
+\end{document}
+%</driver>
+% \fi
+%
+% \changes{0.01}{2000/08/30}{Changed to dtx format}
+% \changes{0.08}{2001/01/08}{Preceed ``np'' to some commands due to
+% incompatibility with babel french}
+%
+% \maketitle
+% \begin{abstract}
+% \noindent This package prints numbers with a separator every three
+% digits and it convert numbers given as |12345.6e789| to
+% $12\,345{,}6\cdot 10^{789}$.
+% The decimal sign, the thousand separator, as well as the product
+% sign can be changed by the user, e.g. to reach
+% $12{,}345.6\times 10^{789}$.
+% If an optional argument is given it is printed upright as unit.
+% \changes{0.21}{2003/02/25}{Abstract changed}
+% \end{abstract}
+%
+% \tableofcontents
+%
+% \section*{Copyright}
+% Copyright 2000--2004 Harald Harders.
+%
+% This program can be redistributed and/or modified under the terms
+% of the LaTeX Project Public License Distributed from CTAN
+% archives in directory macros/latex/base/lppl.txt; either
+% version 1 of the License, or any later version.
+%
+% \section{The user interface}
+%
+% To use this package place
+% \begin{verbatim}
+%\usepackage{numprint}
+% \end{verbatim}
+% in the preamble of your document. No options are necessary.
+%
+% \subsection{Print numbers in text and math mode}
+%
+% \DescribeMacro{\numprint}%
+% The package provides the command \verb|\numprint[#1]{#2}| that prints
+% the number given in the required argument. The number is printed in the
+% active mode (math or text) so that an eventual chosen difference
+% between mathematical and text numbers stays visible (e.g. by using
+% the eco-package.
+%
+% Numbers may contain of these characters:
+% ``|+-\pm0123456789.,eE|''. Either a ``,'' or a ''.'' can be used as
+% decimal sign. No thousand separators are allowed in the
+% argument. ``E'' or ``e'' is converted to $\cdot 10^{x}$.
+% |\pm| produces a $\pm$.
+% \changes{0.20}{2003/02/24}{Added support for $\pm$ sign}%
+% From version 0.30 on, \cs{numprint} is stricter with the argument.
+% It tests wheather the argument contains of supported characters
+% only.
+%
+% For example typing
+% \begin{verbatim}
+%\numprint{-123456}; \numprint[N/mm^2]{-123456}; \numprint{3,1415927e-3.1}
+% \end{verbatim}
+% leads to ``\numprint{-123456}; \numprint[N/mm^2]{-123456};
+% \numprint{3,1415927e-3.1}''. Notice
+% that ``.'' and ``,'' can be mixed within one number.
+%
+% If no number is given before the exponential character ``e''
+% resp. ``E'' a pure exponential format is generated.
+% For example typing
+% \begin{verbatim}
+%\numprint{e4.3242}
+% \end{verbatim}
+% leads to ``\numprint{e4.3242}''.
+% \changes{0.04}{2001/03/06}{Added support for pure $10^x$ format}%
+%
+% \changes{0.02}{2000/08/30}{Added optional argument for units}%
+% If the optional argument is given it is printed as a unit in math
+% mode with an upright font (\verb|\mathrm|). The space between the
+% number and the unit is \verb|\,| by default. It can be changed using
+% the command |\npunitseparator|.
+%
+% \DescribeMacro{\npthousandsep}%
+% \DescribeMacro{\npthousandthpartsep}%
+% \DescribeMacro{\npdecimalsign}%
+% \DescribeMacro{\npproductsign}%
+% By using the three commands \verb|\npthousandsep{#1}|,
+% \verb|\npdecimalsign{#1}|, and
+% \verb|\npproductsign{#1}|\footnote{These command did not have the
+% ``np'' in older versions. This had to be changed in order to avoid
+% an incompatibiliby with the french language of babel.} several
+% separators can be changed. E.g.
+% \begin{verbatim}
+%\npdecimalsign{\ensuremath{\cdot}}\npthousandsep{,}\npproductsign{\times}%
+%\numprint{-123456}; \numprint{3,1415927e-3.1}
+% \end{verbatim}
+% leads to ``{\npdecimalsign{\ensuremath{\cdot}}%
+% \npthousandsep{,}\npproductsign{\times}%
+% \numprint{-123456}; \numprint{3,1415927e-3.1}}''.
+%
+% \DescribeMacro{\global}%
+% These commands change the behaviour of the \verb|\numprint| command
+% only locally (inside the current group). By preceding \verb|\global|
+% the change can be made global inside a group. For example:
+% \begin{verbatim}
+%Local:
+%\numprint{123e4},
+%{\npproductsign{\times}\numprint{123e4}},
+%\numprint{123e4}.
+%Global:
+%\numprint{123e4},
+%{\global\npproductsign{\times}\numprint{123e4}},
+%\numprint{123e4}
+% \end{verbatim}
+% leads to the following:
+%
+% \noindent Local:
+% \numprint{123e4},
+% {\npproductsign{\times}\numprint{123e4}},
+% \numprint{123e4}.
+% Global:
+% \numprint{123e4},
+% {\global\npproductsign{\times}\numprint{123e4}},
+% \numprint{123e4}
+% \npproductsign{\cdot}
+%
+% The current version has the following defaults:
+% \begin{verbatim}
+%\npthousandsep{\,}
+%\npthousandthpartsep{\,}
+%\npdecimalsign{,}
+%\npproductsign{{}\cdot{}}
+%\npunitseparator{\,}
+% \end{verbatim}
+% These will surely change in a new version when I add automatic
+% international support. Then the defaults will by language dependent.
+%
+% \changes{0.31}{2003/09/16}{Describe automatic language-dependent
+% switch of decimal sign}%
+% If you are using the |babel| package you may reach an automatic
+% change of the parameters by using the \cs{addto} command of |babel|,
+% e.g.:
+% \begin{verbatim}
+%\addto\extrasenglish{%
+% \npthousandsep{,}%
+% \npthousandthpartsep{,}%
+% \npdecimalsign{.}%
+% \npproductsign{{}\times{}}%
+%}
+%\addto\extrasngerman{%
+% \npthousandsep{\,}%
+% \npthousandthpartsep{\,}%
+% \npdecimalsign{,}%
+% \npproductsign{{}\cdot{}}%
+%}
+% \end{verbatim}
+%
+% \subsection{Change the behaviour}
+% \subsubsection{Eliminate separators for four-digit numbers}
+%
+% \DescribeMacro{\fourdigitsep}%
+% \DescribeMacro{\fourdigitnosep}%
+% \changes{0.06}{2002/09/18}{Add description for not separating four
+% digit numbers}%
+% Some people want numbers with four digits not to be devided by a
+% thousand separator.
+% This can be achieved using the command |\fourdigitnosep|.
+% You can switch back to separating with |\fourdigitsep|.
+% An example:
+% \begin{verbatim}
+%\fourdigitnosep$\numprint{1234.1234}$, $\numprint{12345.12345}$ --
+%\fourdigitsep$\numprint{1234.1234}$, $\numprint{12345.12345}$
+% \end{verbatim}
+% Leads to
+% ``\fourdigitnosep$\numprint{1234.1234}$, $\numprint{12345.12345}$ --
+% \fourdigitsep$\numprint{1234.1234}$, $\numprint{12345.12345}$''.
+% Default values can be set by the package options |sepfour| and
+% |nosepfour|.
+%
+% If a number has four digits before the decimal sign, but more than
+% four digits after it, or vice versa, the fourth digit is seperated
+% \emph{before and after} the digital sign for consistency.
+% An example:
+% \begin{verbatim}
+%\fourdigitnosep$\numprint{1234.1234}$, $\numprint{1234.12345}$,
+%$\numprint{12345.1234}$
+% \end{verbatim}
+% Leads to
+% ``\fourdigitnosep$\numprint{1234.1234}$, $\numprint{1234.12345}$,
+% $\numprint{12345.1234}$''.
+%
+% \subsubsection{Add missing zeros before or after decimal sign}
+%
+% \DescribeMacro{\addmissingzero}%
+% \DescribeMacro{\noaddmissingzero}%
+% \changes{0.06}{2002/09/18}{Add handling for missing numbers before
+% and after decimalsign}%
+% Sometimes people let out a leading zero or a zero after the
+% decimalsign, e.g. |123.| or |.123|.
+% Numprint can add the left out zero, when |\addmissingzero| is
+% used. This behaviour can be switched of with |\noaddmissingzero|.
+% Corresponding package options are |addmissingzero| and
+% |noaddmissinzero|. Default is |addmissingzero|.
+%
+%
+% \subsubsection[Rounding numbers]{Rounding numbers\footnote{This was
+% an idea of Tilman Finke, tfinke@it-and-law.de}}%
+% \changes{0.30}{2003/05/19}{Add rounding of numbers}%
+%
+% \DescribeMacro{\nprounddigits}%
+% \DescribeMacro{\nproundexpdigits}%
+% \DescribeMacro{\npnoround}%
+% \DescribeMacro{\npnoroundexp}%
+% By default, as many digits are printed after the decimal sign, as
+% the \cs{numprint} command gets as argument.
+% This behaviour can be changed to print a given number of digits
+% where the number is rounded resp.\ filled with zeros.
+%
+% This can be switched of using the
+% \cs{nprounddigits\{\meta{\normalfont digits}\}} command for ordinary
+% numbers and the \cs{nproundexpdigits\{\meta{\normalfont digits}\}}
+% command for exponents.
+% Rounding is switched off with \cs{npnoround} resp.\
+% \cs{npnoroundexp}.
+% For example,
+% \begin{verbatim}
+%\nprounddigits{2}$\numprint{1.123}$, $\numprint{1.149}$,
+%$\numprint{1}$, $\numprint{9.999}$ $\numprint{-9.999}$ --
+%\npnoround$\numprint{1.123}$, $\numprint{1.149}$,
+%$\numprint{1}$, $\numprint{9.999}$ $\numprint{-9.999}$
+% \end{verbatim}
+% leads to
+% ``\nprounddigits{2}$\numprint{1.123}$, $\numprint{1.149}$,
+% $\numprint{1}$, $\numprint{9.999}$ $\numprint{-9.999}$ --
+% \npnoround$\numprint{1.123}$, $\numprint{1.149}$,
+% $\numprint{1}$, $\numprint{9.999}$ $\numprint{-9.999}$''
+%
+% \DescribeMacro{\npreplacenull}%
+% \DescribeMacro{\npprintnull}%
+% For amounts of money, sometimes a zero after the decimal sign is
+% replaced by different signs, as for example ``---''.
+% If rounding is switched on, this can be done by calling
+% \cs{npreplacenull\{\meta{\normalfont replacement}\}}, e.g.
+% \begin{verbatim}
+%\npreplacenull{\mbox{---}}
+% \end{verbatim}
+% Here, \cs{mbox} guarantees that ``---'' is printed in text mode.
+% It can be switched off using \cs{npprintnull}.
+%
+%
+% \subsection{Print aligned numbers in tabulars}%
+% \changes{0.05}{2001/03/12}{Added basic support for aligned tabular
+% entries}%
+%
+% The aim of this function is to combine the functionality of the
+% \verb|dcolumn| package with this one. This has not been achieved by
+% this version. But a first step is done.
+%
+% \DescribeMacro{columntype n}
+% \DescribeMacro{columntype N}
+% This package defines two new column types \verb|n| and \verb|N|. The
+% first one alignes the base number to the decimal sign, the second
+% additionaly alignes the exponent.
+% Use these commands like follows:
+% \begin{verbatim}
+%\begin{tabular}{|n{5}{3}|N{5}{3}{3}|}
+% \hline
+% \numprint{123.45e12.12}& \numprint{123.45e12.12}\\
+% \numprint{12345.678e123.123}& \numprint{12345.678e123.123}\\
+% \hline
+%\end{tabular}
+% \end{verbatim}
+% This leads to\par
+% \begin{tabular}{|n{5}{3}|N{5}{3}{3}|}
+% \hline
+% \numprint{123.45e12.12}& \numprint{123.45e12.12}\\
+% \numprint{12345.678e123.123}& \numprint{12345.678e123.123}\\
+% \hline
+% \end{tabular}
+%
+% The first option defines the number of digits before the decimal
+% sign, the second the number after.
+% In case of the type \verb|N| the third option defines the number of
+% digits before the decimal sign in the exponent.
+% Unfortunately the number of digits can not be calculated
+% automatically.
+% Notice that the command \verb|\numprint| has to be written again in
+% each tabular entry. This will hopefully be changed in a future version.
+%
+% \section{To Do}
+%
+% \begin{itemize}
+% \item Add automatic international support using babel, german, or ngerman:
+%
+% German: \npdecimalsign{,}\npthousandsep{\,}\npproductsign{\cdot}%
+% \numprint{3,1415927e-3.1}
+%
+% American: \npdecimalsign{.}\npthousandsep{,}\npproductsign{\times}%
+% \numprint{3,1415927e-3.1}
+% \item Combine the packages dcolumn and numprint.
+% \item Fix spacing in aligned exponents (spacing is too large).
+% \end{itemize}
+%
+% \StopEventually{\PrintChanges \PrintIndex}
+%
+%
+% \section{The implementation}
+% \iffalse
+%<*package>
+% \fi
+% Heading of the package:
+% \begin{macrocode}
+\NeedsTeXFormat{LaTeX2e}
+\ProvidesPackage{numprint032}[\nprtfiledate\space v\nprtfileversion\space
+ Print numbers]
+\message{Package `numprint032', Version \nprtfileversion\space of \nprtfiledate.}
+\message{Compatiblity version of numprint for versions prior 1.00}
+% \end{macrocode}
+% \changes{0.05}{2001/03/12}{Added basic support for aligned tabular entries}%
+% Load package calc.sty for calculating widths of boxes.
+% \begin{macrocode}
+\RequirePackage{calc}
+% \end{macrocode}
+% Load package array.sty for the new column types.
+% \begin{macrocode}
+\RequirePackage{array}
+% \end{macrocode}
+% Define a boolean if the first digit is separated in a four digit
+% number. Default is true for compatibility with older versions.
+% \begin{macrocode}
+\newif\if@numsepfour
+% \end{macrocode}
+% Define a command which helds the zero to be added if necessary.
+% \begin{macrocode}
+\newcommand\@addmissingzero{}
+% \end{macrocode}
+% \begin{macro}{\fourdigitsep}
+% Switch separating of the fourth digit on.
+% \begin{macrocode}
+\newcommand*{\fourdigitsep}{\@numsepfourtrue}%
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\fourdigitnosep}
+% Switch separating of the fourth digit off.
+% \begin{macrocode}
+\newcommand*{\fourdigitnosep}{\@numsepfourfalse}%
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\addmissingzero}
+% \changes{0.06}{2002/09/18}{Add handling for missing numbers before
+% and after decimalsign}%
+% Add a missing zero before or after decimalsign.
+% \begin{macrocode}
+\newcommand*{\addmissingzero}{\def\@addmissingzero{0}}%
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\noaddmissingzero}
+% Don't add a missing zero before or after decimalsign.
+% \begin{macrocode}
+\newcommand*{\noaddmissingzero}{\def\@addmissingzero{}}%
+% \end{macrocode}
+% \end{macro}
+% Declare options. \verb|nosepfour| switches seperating of the fourth
+% digit off, \verb|sepfour| switches it on. Default is on four
+% compatibility reasons with older versions.
+% \begin{macrocode}
+\DeclareOption{nosepfour}{\fourdigitnosep}
+\DeclareOption{sepfour}{\fourdigitsep}
+\DeclareOption{noaddmissingzero}{\noaddmissingzero}
+\DeclareOption{addmissingzero}{\addmissingzero}
+\ExecuteOptions{sepfour,addmissingzero}
+\ProcessOptions\relax
+% \end{macrocode}
+% Define commands to change the output of the \verb|\numprint|
+% command.
+%
+% \begin{macro}{\npdecimalsign}
+% Change the decimal sign. In English it is normally ``.'', in German
+% ``,''.
+% The additional pair of braces \verb|{}| prevents from inserting
+% additional space in math mode, e.g. $1,2$ versus $1{,}2$.
+% \begin{macrocode}
+\newcommand{\npdecimalsign}[1]{\def\nprt@decimal{{#1}}}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\npthousandsep}
+% Change the thousand separator. In English it often is ``,'', in
+% German ``.'' or ``\,'' (\verb|\,|).
+% Here again the additional \verb|{}| is used as above.
+% This command changes both the sign before and after the comma. If
+% you want a different sign after the comma you have to call
+% \verb|\npthousandthpartsep| after \verb|\npthousandsep|.
+% \begin{macrocode}
+\newcommand{\npthousandsep}[1]{\def\nprt@thousand{{#1}}%
+ \def\nprt@thousandthpart{{#1}}}
+% \end{macrocode}
+% \end{macro}%
+% \begin{macro}{\npthousandthpartsep}
+% \begin{macrocode}
+\newcommand{\npthousandthpartsep}[1]{\def\nprt@thousandthpart{{#1}}}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\npproductsign}
+% Change the product sign that is printed in numbers with exponent
+% like $\numprint{123e4}$. Normally it is \verb|\cdot|. In American
+% texts sometimes \verb|\times|.
+% The two pairs of braces \verb|{}| ensure the correct spacing on the
+% left and right side of the product sign, e.g. 3$\cdot$4 versus
+% 3${}\cdot{}$4.
+% \begin{macrocode}
+\newcommand{\npproductsign}[1]{\def\nprt@prod{\ensuremath{{}#1{}}}}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\npunitseparator}
+% Change the separator between number an unit.
+% Here again the additional \verb|{}| is used as above.
+% \changes{0.03}{2001/02/10}{Fixed bug with units}%
+% \begin{macrocode}
+\newcommand{\npunitseparator}[1]{\def\nprt@unitsep{{#1}}}
+% \end{macrocode}
+% \end{macro}
+% Set the default values for the separators. They will surely change
+% in a new version with automatic international support. At the moment
+% the defaults match the German language.
+% \begin{macrocode}
+\npthousandsep{\,}%
+\npthousandthpartsep{\,}%
+\npdecimalsign{,}%
+\npproductsign{{}\cdot{}}%
+\npunitseparator{\,}%
+% \end{macrocode}
+% \changes{0.30}{2003/05/19}{Add rounding of numbers}%
+% \begin{macro}{\@fillnull}
+% Defines command |#1| with a number of |#2| zeros filled.
+% \begin{macrocode}
+\def\@fillnull#1#2{%
+ \@tempcnta=0
+ \loop
+ \g@addto@macro{#1}{0}%
+ \advance\@tempcnta by 1
+ \ifnum\@tempcnta<#2
+ \repeat
+}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\nprounddigits}
+% Define a command that sets a count of digits after which the number
+% is rounded.
+% This command defines \cs{nprt@rounddigits} that stores the count and
+% \cs{nprt@roundnull} that contains of \cs{nprt@rounddigits} ``0''
+% digits.
+% \begin{macrocode}
+\newcommand\nprounddigits[1]{%
+ \def\nprt@rounddigits{#1}%
+ \def\nprt@roundnull{}%
+ \@fillnull{\nprt@roundnull}{#1}%
+}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\npnoround}
+% A command to switch off rounding.
+% \begin{macrocode}
+\newcommand\npnoround{\nprounddigits{-1}}
+% \end{macrocode}
+% \end{macro}
+% Don't round by default.
+% \begin{macrocode}
+\npnoround
+% \end{macrocode}
+% \begin{macro}{\nproundexpdigits}
+% \begin{macro}{\npnoroundexp}
+% The same for exponents.
+% \begin{macrocode}
+\newcommand\nproundexpdigits[1]{%
+ \def\nprt@roundexpdigits{#1}%
+ \def\nprt@roundexpnull{}%
+ \@fillnull{\nprt@roundexpnull}{#1}%
+ }
+\newcommand\npnoroundexp{\nproundexpdigits{-1}}
+\npnoroundexp
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+% \changes{0.30}{2003/05/19}{Optionally replace zero after decimal sign}%
+% \begin{macro}{\npreplacenull}
+% Optionally, one or more zeros after the decimal sign can be replaced
+% by other text, e.g.\ ``---'''.
+% \begin{macrocode}
+\newcommand\npreplacenull[1]{\def\nprt@replacenull{#1}}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\npprintnull}
+% Switch off replacement, again.
+% \begin{macrocode}
+\newcommand\npprintnull{\let\nprt@replacenull=\@empty}
+% \end{macrocode}
+% \end{macro}
+% Print the zero by default.
+% \begin{macrocode}
+\npprintnull
+% \end{macrocode}
+% Define the signs as commands. This is necessary to be able to
+% compare them with other characters.
+% \changes{0.20}{2003/02/24}{Added support for $\pm$ sign}%
+% \begin{macrocode}
+\def\nprt@plus@test{+}
+\def\nprt@minus@test{-}
+\def\nprt@plusminus@test{\pm}
+% \end{macrocode}
+% Define commands for printing the signs in math mode. This ensures
+% that the printed signs really are signs and not hyphens. Compare
+% ``-'' to ``\ensuremath{-}''.
+% \changes{0.20}{2003/02/24}{Added support for $\pm$ sign}%
+% \begin{macrocode}
+\def\nprt@plus{\ensuremath{+}}
+\def\nprt@minus{\ensuremath{-}}
+\def\nprt@plusminus{\ensuremath{\pm}}
+% \end{macrocode}
+% \begin{macro}{\nprt@printdigit}
+% Print a digit. If this digit is a sign (\verb|+| or \verb|-|) it is
+% printed in math mode, else it is printed in the active mode.
+% \begin{macrocode}
+\def\nprt@printdigit#1{%
+ \def\nprt@tmp{#1}%
+ \ifx\nprt@tmp\nprt@plus@test
+ \nprt@plus
+ \else
+ \ifx\nprt@tmp\nprt@minus@test
+ \nprt@minus
+ \else
+ \ifx\nprt@tmp\nprt@plusminus@test
+ \nprt@plusminus
+ \else
+ #1%
+ \fi
+ \fi
+ \fi
+}
+% \end{macrocode}
+% \end{macro}
+% \changes{0.05}{2001/03/12}{Added basic support for aligned tabular entries}%
+% Define some booleans.
+% \verb|\ifnprt@block| decides whether the number is centered to the
+% decimal sign.
+% \verb|\ifnprt@blockexp| does the same for the exponent.
+% \verb|\ifnprt@exponent| is true when printing the exponent and false
+% otherwise.
+% \verb|\ifnprt@inmath| is set to true when using the command in math
+% mode.
+% \begin{macrocode}
+\newif\ifnprt@block
+\newif\ifnprt@blockexp
+\newif\ifnprt@exponent
+\newif\ifnprt@inmath
+% \end{macrocode}
+% \begin{macro}{\digits}
+% \changes{0.05}{2001/03/12}{Added basic support for aligned tabular entries}%
+% With this command the user can switch to aligned printing.
+% The first parameter stands for the digits before the decimal sign
+% and the second for the digits after it.
+% \begin{macrocode}
+\newcommand{\digits}[2]{%
+ \xdef\nprt@blockbefore{#1}%
+ \xdef\nprt@blockafter{#2}%
+ \nprt@blocktrue}%
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\nodigits}
+% Switch back to normal printing.
+% \begin{macrocode}
+\newcommand{\nodigits}{\nprt@blockfalse}%
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\exponentdigits}
+% With this command the user can switch to aligned printing of the
+% exponent.
+% The parameter stands for the digits before the decimal sign.
+% \begin{macrocode}
+\newcommand{\exponentdigits}[1]{%
+ \xdef\nprt@blockexpbefore{#1}%
+ \nprt@blockexptrue}%
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\noexponentdigits}
+% Switch back to normal printing.
+% \begin{macrocode}
+\newcommand{\noexponentdigits}{\nprt@blockexpfalse}%
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\nprt@three}
+% Print up to three digits and call this command again recursively if there
+% are more digits to print.
+%
+% The command must be called in a different way than normal \LaTeX\
+% commands. Braces must not be used but at the end of the command
+% list \verb|\@empty| has to appear in the source code. The command
+% gets four arguments where the first three are single digits and the
+% fourth contains the rest of the text preceding the \verb|\@empty|.
+% \begin{macrocode}
+\def\nprt@three#1#2#3#4\@empty{%
+% \end{macrocode}
+% Print the three digits.
+% \begin{macrocode}
+ \nprt@printdigit#1%
+ \nprt@printdigit#2%
+ \nprt@printdigit#3%
+% \end{macrocode}
+% Define a temporary variable containing the rest string for testing
+% if there is a rest at all.
+% \begin{macrocode}
+ \def\nprt@tmp{#4}%
+ \ifx\nprt@tmp\empty
+ \else
+% \end{macrocode}
+% If there is a rest string insert the thousand separator \dots
+% \begin{macrocode}
+ \nprt@thousand%
+% \end{macrocode}
+% \dots\ and call this command recursively.
+% Append enough \verb|\@empty| statements to ensure that the command
+% gets four arguments.
+% \begin{macrocode}
+ \nprt@three#4\@empty\@empty\@empty
+ \fi
+}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\nprt@threeafter}
+% Print up to three digits and call this command again recursively if there
+% are more digits to print. For use after the decimal sign.
+% \begin{macrocode}
+\def\nprt@threeafter#1#2#3#4\@empty{%
+% \end{macrocode}
+% Print the three digits.
+% \begin{macrocode}
+ \nprt@printdigit#1%
+ \nprt@printdigit#2%
+ \nprt@printdigit#3%
+% \end{macrocode}
+% Define a temporary variable containing the rest string for testing
+% if there is a rest at all.
+% \begin{macrocode}
+ \def\nprt@tmp{#4}%
+ \ifx\nprt@tmp\empty
+ \else
+% \end{macrocode}
+% If there is a rest string insert the thousand separator \dots
+% \begin{macrocode}
+ \nprt@thousandthpart%
+% \end{macrocode}
+% \dots\ and call this command recursively.
+% Append enough \verb|\@empty| statements to ensure that the command
+% gets four arguments.
+% \begin{macrocode}
+ \nprt@threeafter#4\@empty\@empty\@empty
+ \fi
+}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\nprt@two}
+% Print two digits and call \verb|\nprt@three| if there
+% are more digits to print. This command is maximally used once at the
+% beginning of the number when it contains 2, 5, 8, 11, \dots\ digits
+% before the decimal sign. For a description have a look at
+% \verb|\nprt@three|.
+% \begin{macrocode}
+\def\nprt@two#1#2#3\@empty{%
+ \nprt@printdigit#1%
+ \nprt@printdigit#2%
+ \def\nprt@tmp{#3}%
+ \ifx\nprt@tmp\empty
+ \else
+ \nprt@thousand\nprt@three#3\@empty\@empty\@empty
+ \fi
+}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\nprt@one}
+% Print one digit and call \verb|\nprt@three| if there
+% are more digits to print. This command is maximally used once at the
+% beginning of the number when it contains 1, 4, 7, 10, \dots\ digits
+% before the decimal sign. For a description watch \verb|\nprt@three|.
+% \begin{macrocode}
+\def\nprt@one#1#2\@empty{%
+ \nprt@printdigit#1%
+ \def\nprt@tmp{#2}%
+ \ifx\nprt@tmp\empty
+ \else
+% \end{macrocode}
+% Test if the first character was a sign. The thousand separator may
+% only be printed if the first character is no sign.
+% \changes{0.20}{2003/02/24}{Added support for $\pm$ sign}%
+% \begin{macrocode}
+ \def\nprt@tmp{#1}%
+ \ifx\nprt@tmp\nprt@plus@test
+ \else
+ \ifx\nprt@tmp\nprt@minus@test
+ \else
+ \ifx\nprt@tmp\nprt@plusminus@test
+ \else
+ \nprt@thousand
+ \fi
+ \fi
+ \fi
+ \nprt@three#2\@empty\@empty\@empty
+ \fi
+}
+% \end{macrocode}
+% \end{macro}
+% Define routines to test if a character is included in a string. If
+% yes the command \verb|\nprt@tmp| returns a nonempty string. If the
+% string does not contain the character \verb|\nprt@tmp| returns
+% nothing. To achieve this functionality the commands have to be
+% called in a special way. For example to test for a comma in a command
+% \verb|\str| you have to write
+% \verb|\nprt@commatest\str,\@empty|. So you always have to
+% append the character you are searching for (e.g. \verb|,|) and
+% \verb|\@empty| to your search string.
+% \begin{macrocode}
+\def\nprt@exptest#1e#2\@empty{\gdef\nprt@tmp{#2}}
+\def\nprt@Exptest#1E#2\@empty{\gdef\nprt@tmp{#2}}
+\def\nprt@commatest#1,#2\@empty{\gdef\nprt@tmp{#2}}
+\def\nprt@dottest#1.#2\@empty{\gdef\nprt@tmp{#2}}
+% \end{macrocode}
+% \begin{macro}{\nprt@exp}
+% Print number in the exponential format with an argument containing a
+% small ``e''. Call: \verb|\nprt@exp| number\verb|\@empty|,
+% e.g. \verb|\nprt@exp 123.2e4,3\@empty|. Both numbers containing a comma or
+% a dot work.
+% \begin{macrocode}
+\def\nprt@exp#1e#2\@empty{\expnumprint{#1}{#2}}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\nprt@Exp}
+% Print number in the exponential format with an argument containing a
+% capital ``E''. Call: \verb|\nprt@Exp| number\verb|\@empty|,
+% e.g. \verb|\nprt@Exp 123.2E4,3\@empty|. Both numbers containing a comma or
+% a dot work.
+% \begin{macrocode}
+\def\nprt@Exp#1E#2\@empty{\expnumprint{#1}{#2}}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\nprt@comma}
+% \changes{0.06}{2002/09/18}{Add handling for missing numbers before
+% and after decimalsign}%
+% Print a number without exponential part containing a comma. Call:
+% \verb|\nprt@comma| number\verb|\@empty|, e.g.
+% \verb|\nprt@comma 123,2\@empty|.
+% \begin{macrocode}
+\def\nprt@comma#1,#2\@empty{%
+ \nprt@dotcomma{#1}{#2}}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\nprt@dot}
+% \changes{0.06}{2002/09/18}{Add handling for missing numbers before
+% and after decimalsign}%
+% Print a number without exponential part containing a comma. Call:
+% \verb|\nprt@dot| number\verb|\@empty|, e.g.
+% \verb|\nprt@dot 123.2\@empty|.
+% \begin{macrocode}
+\def\nprt@dot#1.#2\@empty{%
+ \nprt@dotcomma{#1}{#2}}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\nprt@dotcomma}
+% \changes{0.06}{2002/09/18}{Add handling for missing numbers before
+% and after decimalsign}%
+% \changes{0.30}{2003/05/19}{Add support for rounding}%
+% Print a number without exponential part containing a dot or a comma. Call:
+% \verb|\nprt@dotcomma{before}{after}|, e.g.\
+% \verb|\nprt@dot{123}{2}|.
+% \begin{macrocode}
+\def\nprt@dotcomma#1#2{%
+ \begingroup
+% \end{macrocode}
+% If \cs{nprt@dotcomma} is called for printing an exponent, copy the
+% routines for exponents to the ordinary ones. This has to be done
+% between \cs{begingroup} and \cs{endgroup} to preserve the normal
+% settings.
+% \begin{macrocode}
+ \ifnprt@exponent
+ \edef\nprt@rounddigits{\nprt@roundexpdigits}%
+ \edef\nprt@roundnull{\nprt@roundexpnull}%
+ \fi
+ \ifnum\nprt@rounddigits<0
+% \end{macrocode}
+% If no rounding is done, just use the given arguments for printing.
+% \begin{macrocode}
+ \def\nprt@charsbeforecomma{#1}%
+ \def\nprt@charsaftercomma{#2}%
+ \else
+% \end{macrocode}
+% If rounding, do it.
+% First, provide empty strings for the parts before and after the
+% digit sign.
+% \begin{macrocode}
+ \def\nprt@charsbeforecomma{}%
+ \def\nprt@charsaftercomma{}%
+% \end{macrocode}
+% Append enough zeros after the decimal sign that all digits are
+% surely printed.
+% \begin{macrocode}
+ \edef\zwei{#2\nprt@roundnull}%
+% \end{macrocode}
+% Call the command \cs{nprt@roundaftercomma} that does the rounding
+% for the part after the decimal sign.
+% \begin{macrocode}
+ \expandafter\nprt@roundaftercomma\zwei\empty
+% \end{macrocode}
+% If the first digit after the comma is rounded from 9 to 0, rounding
+% has to be continued before the decimal sign by calling
+% \cs{nprt@roundbeforecomma}.
+% \begin{macrocode}
+ \if@@roundup
+ \nprt@roundbeforecomma#1\empty
+% \end{macrocode}
+% If the first digit has to be rounded from 9 to 0, a 1 has to be
+% inserted before the number.
+% \begin{macrocode}
+ \if@@roundup
+ \expandafter\xdef\expandafter\nprt@charsbeforecomma{%
+ 1\nprt@charsbeforecomma}%
+ \fi
+ \else
+ \def\nprt@charsbeforecomma{#1}%
+ \fi
+ \fi
+% \end{macrocode}
+% Count the digits after the comma.
+% \begin{macrocode}
+ \nprt@@hassignfalse
+ \expandafter\nprt@count\nprt@charsaftercomma\@empty\@empty\@empty
+% \end{macrocode}
+% Copy the result which is stored in |nprt@digitsbeforedecimal| to
+% |nprt@digitsafterdecimal|.
+% \begin{macrocode}
+ \setcounter{nprt@digitsafterdecimal}{\thenprt@digitsbeforedecimal}%
+% \end{macrocode}
+% Count the digits before the comma.
+% \begin{macrocode}
+ \expandafter\nprt@hassign\nprt@charsbeforecomma\@empty\@empty
+ \expandafter\nprt@count\nprt@charsbeforecomma\@empty\@empty\@empty
+% \end{macrocode}
+% Typeset the digits before the comma.
+% \begin{macrocode}
+ \ifnum\the\c@nprt@digitsbeforedecimal=0
+ \@addmissingzero
+ \else
+ \expandafter\beforecomma\nprt@charsbeforecomma\@empty\@empty
+ \fi
+% \end{macrocode}
+% Typeset the part after the decimal sign, if necessary.
+% \begin{macrocode}
+ \ifnum\nprt@rounddigits=0
+ \else
+% \end{macrocode}
+% Typeset the decimal sign.
+% \begin{macrocode}
+ \nprt@decimal
+% \end{macrocode}
+% Typeset the digits after the comma.
+% \begin{macrocode}
+ \ifnum\the\c@nprt@digitsafterdecimal>0
+ \aftercomma{\nprt@charsaftercomma}%
+ \else
+ \ifx\nprt@replacenull\@empty
+ \@addmissingzero
+ \else
+ \nprt@replacenull
+ \fi
+ \fi
+ \fi
+ \endgroup
+}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\expnumprint}
+% Print number in the exponential format. This function is called by
+% \verb|\nprt@exp| and \verb|\nprt@Exp|. It just calls
+% \verb|\numprint| for the number itself, prints $\cdot 10$, and
+% calls \verb|\numprint| for the exponent. It is distinguished between
+% text and math mode to ensure the usage of the right fonts.
+% \changes{0.04}{2001/03/06}{Added support for pure $10^x$ format}%
+% \begin{macrocode}
+\newcommand{\expnumprint}[2]{%
+ \def\nprt@tmp{#1}%
+ \ifx\nprt@tmp\@empty
+ \nprt@exponenttrue
+ \ifmmode
+ 10^{\numprint{#2}}%
+ \else
+ 10\textsuperscript{\numprint{#2}}%
+ \fi
+ \else
+ \ifmmode
+ \numprint{#1}%
+ \nprt@exponenttrue
+ \nprt@prod 10^{\numprint{#2}}%
+ \else
+ \numprint{#1}%
+ \nprt@exponenttrue
+ \nprt@prod 10\textsuperscript{\numprint{#2}}%
+ \fi
+ \fi
+ \nprt@exponentfalse
+}
+% \end{macrocode}
+% \end{macro}
+% Define a macro that includes |\@empty|. This seems to be necesarry since
+% the optional argument of |\numprint| is not expanded before printing it.
+% \changes{0.22}{2003/02/27}{Bugfix with invalid spacing after the number}%
+% \begin{macrocode}
+\def\nprt@empty{\@empty}%
+% \end{macrocode}
+% \begin{macro}{\numprint}
+% This is the main command of this package. It gets a number in the
+% argument and prints it.
+% \begin{macrocode}
+\DeclareRobustCommand*\numprint[2][\@empty]{%
+% \end{macrocode}
+% \changes{0.32}{2003/09/28}{Reset the number of digits before and
+% after the decimal sign (Bugfix for nosepfour)}%
+% Reset the number of digits before and after the decimal sign.
+% Without doing it, \texttt{nosepfour} is broken by one number with
+% more than 4 digits.
+% \begin{macrocode}
+ \setcounter{nprt@digitsafterdecimal}{0}%
+ \setcounter{nprt@digitsbeforedecimal}{0}%
+% \end{macrocode}
+% \changes{0.31}{2003/09/16}{Expand the mandatory argument of the
+% \cs{numprint} command before parsing it}%
+% Expand argument first.
+% \begin{macrocode}
+ \edef\nprt@marg{#2}%
+% \end{macrocode}
+% Call \verb|\nprt@Exptest| to test the argument for an ``E''.
+% \begin{macrocode}
+ \expandafter\nprt@Exptest\nprt@marg E\@empty
+% \end{macrocode}
+% If the argument contains no ``E'' proceed here.
+% \begin{macrocode}
+ \ifx\nprt@tmp\empty
+% \end{macrocode}
+% Call \verb|\nprt@exptest| to test the argument for an ``e''.
+% \begin{macrocode}
+ \expandafter\nprt@exptest\nprt@marg e\@empty
+% \end{macrocode}
+% If the argument contains no ``e'' the argument contains a simple
+% number. Then proceed here.
+% \begin{macrocode}
+ \ifx\nprt@tmp\empty
+% \end{macrocode}
+% Call \verb|\nprt@commatest| to test the argument for a ``,''.
+% \begin{macrocode}
+ \expandafter\nprt@commatest\nprt@marg,\@empty
+% \end{macrocode}
+% If the argument contains no ``,'' proceed here.
+% \begin{macrocode}
+ \ifx\nprt@tmp\empty
+% \end{macrocode}
+% Call \verb|\nprt@commatest| to test the argument for a ``.''.
+% \begin{macrocode}
+ \expandafter\nprt@dottest\nprt@marg.\@empty
+% \end{macrocode}
+% If the argument contains no ``.'' the number has no decimal
+% places. Then proceed here.
+% \begin{macrocode}
+ \ifx\nprt@tmp\empty
+% \end{macrocode}
+% Count the digits of the integer number.
+% \begin{macrocode}
+ \expandafter\nprt@hassign\nprt@marg\@empty
+ \expandafter\nprt@count\nprt@marg\@empty\@empty\@empty
+% \end{macrocode}
+% Print the number.
+% \begin{macrocode}
+ \begingroup
+% \end{macrocode}
+% If \cs{nprt@dotcomma} is called for printing an exponent, copy the
+% routines for exponents to the ordinary ones. This has to be done
+% between \cs{begingroup} and \cs{endgroup} to preserve the normal
+% settings.
+% \begin{macrocode}
+ \ifnprt@exponent
+ \def\nprt@rounddigits{\nprt@roundexpdigits}%
+ \def\nprt@roundnull{\nprt@roundexpnull}%
+ \fi
+% \end{macrocode}
+% If rounding is switched on with at least on digit, the part
+% after the decimal sign has to be printed.
+% Set the number of digits, then.
+% \begin{macrocode}
+ \ifnum\nprt@rounddigits>0
+ \setcounter{nprt@digitsafterdecimal}{\nprt@rounddigits}%
+ \fi
+% \end{macrocode}
+% Print the integer part.
+% \begin{macrocode}
+ \expandafter\beforecomma\nprt@marg\@empty\@empty
+% \end{macrocode}
+% Print the part after the decimal sign.
+% \begin{macrocode}
+ \ifnum\nprt@rounddigits>0
+ \nprt@decimal
+ \aftercomma{\nprt@roundnull}%
+ \fi
+ \endgroup
+% \end{macrocode}
+% If the argument contains a ``.'' proceed here.
+% Call \verb|\nprt@dot| to print the whole number.
+% \begin{macrocode}
+ \else
+ \expandafter\nprt@dot\nprt@marg\@empty
+ \fi
+% \end{macrocode}
+% If the argument contains a ``,'' proceed here.
+% Call \verb|\nprt@comma| to print the whole number.
+% \begin{macrocode}
+ \else
+ \expandafter\nprt@comma\nprt@marg\@empty
+ \fi
+% \end{macrocode}
+% If the argument contains a ``e'' proceed here.
+% Call \verb|\nprt@exp| to print the whole number.
+% \begin{macrocode}
+ \else
+ \expandafter\nprt@exp\nprt@marg\@empty
+ \fi
+% \end{macrocode}
+% If the argument contains a ``E'' proceed here.
+% Call \verb|\nprt@Exp| to print the whole number.
+% \begin{macrocode}
+ \else
+ \expandafter\nprt@Exp\nprt@marg\@empty
+ \fi
+% \end{macrocode}
+% \changes{0.02}{2000/08/30}{Added optional argument for units}%
+% \changes{0.03}{2001/02/10}{Fixed bug with units}%
+% \changes{0.20}{2003/02/24}{Fixed bug which made units fragile}%
+% \changes{0.22}{2003/02/27}{Bugfix with invalid spacing after the number}%
+% Handle optional argument and print the unit only when specified.
+% \begin{macrocode}
+ \def\nprt@unit{#1}%
+ \ifx\nprt@unit\nprt@empty
+ \else
+ \ensuremath{\nprt@unitsep\mathrm{\nprt@unit}}%
+ \fi
+}
+% \end{macrocode}
+% \end{macro}
+% \changes{0.05}{2001/03/12}{Added basic support for aligned tabular entries}%
+% Counters for counting digits: \verb|nprt@countblocks| counts number
+% of blocks before the decimal sign. \verb|nprt@digitsfirstblock|
+% counts the digits in the first block (0 to 2).
+% \verb|nprt@digitsbeforedecimal| counts the total number of
+% digits before the decimal sign.
+% \begin{macrocode}
+\newcounter{nprt@countblocksbefore}%
+\newcounter{nprt@digitsfirstblock}%
+\newcounter{nprt@digitsafterdecimal}%
+\newcounter{nprt@digitsbeforedecimal}%
+% \end{macrocode}
+% \begin{macro}{nprt@hassign}
+% Tests weather the first character of a string is not a digit.
+% \begin{macrocode}
+\newif\ifnprt@@hassign
+\def\nprt@hassign#1#2\@empty{%
+ \ifnum-9>-1#1
+ \nprt@@hassignfalse
+ \else
+ \nprt@@hassigntrue
+ \fi
+}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\nprt@count}
+% Count the number of digits of the argument. This is done recursively
+% by taking one character of the string and counting the runs of this
+% command. Every three digits the counter is resetted to zero because
+% only the modulus (Rest??) of the number of digits devided by 3 is
+% important.
+%
+% If the optional parameter contains anything other than
+% \verb|\@empty| the number of digits after the comma is counted.
+% \begin{macrocode}
+\def\nprt@count#1#2\@empty{%
+ \setcounter{nprt@digitsbeforedecimal}{0}%
+ \edef\nprt@arg{#1}%
+% \end{macrocode}
+% Handle an empty argument.
+% \begin{macrocode}
+ \ifx\nprt@arg\@empty
+ \else
+% \end{macrocode}
+% Count the digits.
+% \begin{macrocode}
+ \ifnprt@@hassign
+ \nprt@@count#2\@empty\@empty
+ \else
+ \nprt@@count#1#2\@empty\@empty
+ \fi
+ \fi
+% \end{macrocode}
+% \begin{macrocode}
+ \setcounter{nprt@countblocksbefore}{\arabic{nprt@digitsbeforedecimal}/3}%
+ \setcounter{nprt@digitsfirstblock}{%
+ \arabic{nprt@digitsbeforedecimal}-3*\arabic{nprt@countblocksbefore}}%
+}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\nprt@@count}
+% \changes{0.32}{2003/09/28}{Only one error message per \cs{numprint}}%
+% Do the counting itself.
+% \begin{macrocode}
+\def\nprt@@count#1#2\@empty{%
+ \ifnum-9>-1#1
+ \addtocounter{nprt@digitsbeforedecimal}{1}%
+ \def\nprt@tmp{#2}%
+ \ifx\nprt@tmp\empty
+ \else
+ \nprt@@count#2\@empty\@empty
+ \fi
+ \else
+ \PackageError{numprint}{Incorrect number format in
+ \string\numprint}{%
+ The main argument of the \string\numprint\space command may only
+ be started\MessageBreak
+ with \string"+\string", \string"-\string", or
+ \string"\string\pm\string" and then contain of\MessageBreak
+ digits \string"0\string" to \string"9\string",
+ \string",\string", \string".\string", \string"e\string", and
+ \string"E\string".}%
+% \setcounter{nprt@digitsbeforedecimal}{-1}%
+ \fi
+% \end{macrocode}
+% Count number of characters
+% \begin{macrocode}
+}
+% \end{macrocode}
+% \end{macro}
+% Print the digits before the decimal sign. Depending on the number of
+% digits either \verb|\nprt@one|, \verb|\nprt@two|, or
+% \verb|\nprt@three| is called.
+% \begin{macrocode}
+\newlength{\nprt@digitwidth}%
+\newlength{\nprt@sepwidth}%
+\newcounter{nprt@digitcount}%
+\newcounter{nprt@sepcount}%
+\newlength{\nprt@blockwidth}%
+% \end{macrocode}
+% \begin{macro}{beforecomma}
+% Prints the number before the decimal sign.
+% \begin{macrocode}
+\def\beforecomma#1#2\@empty{%
+% \end{macrocode}
+% \changes{0.05}{2001/03/12}{Added basic support for aligned tabular entries}%
+% If the number should be printed aligned generate a block with the
+% correct size.
+% \begin{macrocode}
+ \ifnprt@block
+ \ifnprt@exponent
+ \else
+ \settowidth{\nprt@digitwidth}{1}%
+ \settowidth{\nprt@sepwidth}{\nprt@thousand}%
+ \setcounter{nprt@digitcount}{\nprt@blockbefore}%
+ \setcounter{nprt@sepcount}{(\nprt@blockbefore-1)/3}%
+ \setlength{\nprt@blockwidth}{%
+ \arabic{nprt@digitcount}\nprt@digitwidth+%
+ \arabic{nprt@sepcount}\nprt@sepwidth}%
+% \end{macrocode}
+% If block length is four digits and fourth digit is not to be
+% separated adjust new width.
+% \begin{macrocode}
+ \if@numsepfour
+ \else
+ \ifnum\nprt@blockbefore=4
+ \ifnum\nprt@blockafter<5
+ \setlength{\nprt@blockwidth}{4\nprt@digitwidth}%
+ \fi
+ \fi
+ \fi
+% \end{macrocode}
+% If math mode switch to math mode again after invoking box.
+% \begin{macrocode}
+ \ifmmode\nprt@inmathtrue\fi
+ \makebox[\nprt@blockwidth][r]{%
+ \ifnprt@inmath$\fi %$ (only for syntax highlighing in emacs)
+ \fi
+ \fi
+ \ifnprt@blockexp
+ \ifnprt@exponent
+ \settowidth{\nprt@digitwidth}{1}%
+ \settowidth{\nprt@sepwidth}{\nprt@thousand}%
+ \setcounter{nprt@digitcount}{\nprt@blockexpbefore}%
+ \setcounter{nprt@sepcount}{(\nprt@blockexpbefore-1)/3}%
+ \setlength{\nprt@blockwidth}{%
+ \arabic{nprt@digitcount}\nprt@digitwidth+%
+ \arabic{nprt@sepcount}\nprt@sepwidth}%
+% \end{macrocode}
+% If block length is four digits and fourth digit is not to be
+% separated adjust new width.
+% \begin{macrocode}
+ \if@numsepfour
+ \else
+ \ifnum\nprt@blockexpbefore=4
+ \setlength{\nprt@blockwidth}{4\nprt@digitwidth}%
+ \fi
+ \fi
+ \ifmmode\nprt@inmathtrue\fi
+ \makebox[\nprt@blockwidth][r]{%
+% \end{macrocode}
+% asdf
+% To do: correct font size (normalstyle, scriptstyle, scriptscriptstyle)
+% \begin{macrocode}
+ \ifnprt@inmath$\scriptstyle\fi %$ (only for syntax highlighing in emacs)
+ \fi
+ \fi
+% \end{macrocode}
+% \changes{0.31}{2003/09/16}{Bug Fix: With four-digit numbers, print
+% everything instead of first digit only}%
+% Print the number itself.
+% \begin{macrocode}
+ \ifnprt@@hassign
+ \nprt@printdigit{#1}%
+ \edef\nprt@tmp{#2}%
+ \else
+ \edef\nprt@tmp{#1#2}%
+ \fi
+ \ifnum\thenprt@digitsfirstblock=1
+ \ifnum\thenprt@digitsbeforedecimal=4
+ \if@numsepfour
+ \expandafter\nprt@one\nprt@tmp\@empty\@empty\@empty
+ \else
+ \ifnum\thenprt@digitsafterdecimal<5
+ \nprt@tmp\ignorespaces
+ \else
+ \expandafter\nprt@one\nprt@tmp\@empty\@empty\@empty
+ \fi
+ \fi
+ \else
+ \expandafter\nprt@one\nprt@tmp\@empty\@empty\@empty
+ \fi
+ \fi
+ \ifnum\thenprt@digitsfirstblock=2
+ \expandafter\nprt@two\nprt@tmp\@empty\@empty\@empty
+ \fi
+ \ifnum\thenprt@digitsfirstblock=0
+ \expandafter\nprt@three\nprt@tmp\@empty\@empty\@empty\@empty
+ \fi
+% \end{macrocode}
+% \changes{0.05}{2001/03/12}{Added basic support for aligned tabular entries}%
+% Close the block if necessary.
+% \begin{macrocode}
+ \ifnprt@blockexp
+ \ifnprt@exponent
+ \ifnprt@inmath$\fi %$ (only for syntax highlighing in emacs)
+ }%
+ \fi
+ \fi
+ \ifnprt@block
+ \ifnprt@exponent
+ \else
+ \ifnprt@inmath$\fi %$ (only for syntax highlighing in emacs)
+ }%
+ \fi
+ \fi
+}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{aftercomma}
+% Print the digits after the decimal sign.
+% \begin{macrocode}
+\newcommand{\aftercomma}[1]{%
+% \end{macrocode}
+% Count number of digits.
+% \begin{macrocode}
+% \expandafter\nprt@count\expandafter{#1}%
+% \end{macrocode}
+% \changes{0.05}{2001/03/12}{Added basic support for aligned tabular entries}%
+% If the number should be printed aligned generate a block with the
+% correct size.
+% \begin{macrocode}
+ \ifnprt@block
+ \ifnprt@exponent
+ \else
+ \settowidth{\nprt@digitwidth}{1}%
+ \settowidth{\nprt@sepwidth}{\nprt@thousand}%
+ \setcounter{nprt@digitcount}{\nprt@blockafter}%
+ \setcounter{nprt@sepcount}{(\nprt@blockafter-1)/3}%
+ \setlength{\nprt@blockwidth}{%
+ \arabic{nprt@digitcount}\nprt@digitwidth+%
+ \arabic{nprt@sepcount}\nprt@sepwidth}%
+% \end{macrocode}
+% If block length is four digits and fourth digit is not to be
+% separated adjust new width.
+% \begin{macrocode}
+ \if@numsepfour
+ \else
+ \ifnum\nprt@blockafter=4
+ \ifnum\nprt@blockbefore<5
+ \setlength{\nprt@blockwidth}{4\nprt@digitwidth}%
+ \fi
+ \fi
+ \fi
+ \ifmmode\nprt@inmathtrue\fi
+ \makebox[\nprt@blockwidth][l]{%
+ \ifnprt@inmath$\fi %$ (only for syntax highlighing in emacs)
+ \fi
+ \fi
+% \end{macrocode}
+% If a zero after the decimal sign is replaced, don't test on 4 digits
+% after comma.
+% Therefor, set |nprt@digitsafterdecimalsign| to zero.
+% \begin{macrocode}
+ \ifx\nprt@replacenull\@empty
+ \else
+ \ifnum#1=0
+ \setcounter{nprt@digitsafterdecimal}{0}%
+ \fi
+ \fi
+% \end{macrocode}
+% Print the number itself.
+% \begin{macrocode}
+ \ifnum\thenprt@digitsafterdecimal=4
+ \if@numsepfour
+ \expandafter\nprt@threeafter#1\@empty\@empty\@empty
+ \else
+ \ifnum\thenprt@digitsbeforedecimal<5
+ #1\ignorespaces
+ \else
+ \expandafter\nprt@threeafter#1\@empty\@empty\@empty
+ \fi
+ \fi
+ \else
+% \end{macrocode}
+% Replace the zero after the comma by \cs{nprt@replacenull} if this is
+% wanted.
+% Otherwise, print the digits.
+% \begin{macrocode}
+ \ifx\nprt@replacenull\@empty
+ \expandafter\nprt@threeafter#1\@empty\@empty\@empty
+ \else
+ \ifnum#1=0
+ \nprt@replacenull
+ \else
+ \expandafter\nprt@threeafter#1\@empty\@empty\@empty
+ \fi
+ \fi
+ \fi
+% \end{macrocode}
+% \changes{0.05}{2001/03/12}{Added basic support for aligned tabular entries}%
+% Close the block if necessary.
+% \begin{macrocode}
+ \ifnprt@block
+ \ifnprt@exponent
+ \else
+ \ifnprt@inmath$\fi %$ (only for syntax highlighing in emacs)
+ }%
+ \fi
+ \fi
+}
+% \end{macrocode}
+% \end{macro}
+% New counter which shows the digit position for finding the digit
+% where to round.
+% \begin{macrocode}
+\newcounter{nprt@position}
+% \end{macrocode}
+% Boolean that shows if a 9 has been rounded to 0.
+% \begin{macrocode}
+\newif\if@@roundup
+% \end{macrocode}
+% Current digit to be able to add 1 to it.
+% \begin{macrocode}
+\newcounter{nprt@thisdigit}
+% \end{macrocode}
+% \begin{macro}{\nprt@roundaftercomma}
+% Command that rounds at the argument |#1#2| at the digit
+% \cs{nprt@rounddigits}.
+% This routine calls itself recursively.
+% \begin{macrocode}
+\def\nprt@roundaftercomma#1#2\empty{%
+ \addtocounter{nprt@position}{1}%
+ \edef\zwei{#2}%
+ \ifx\zwei\empty
+ \else
+ \expandafter\ifnum\thenprt@position<\nprt@rounddigits
+ \nprt@roundaftercomma#2\empty
+ \else
+ \nprt@roundup#2\empty
+ \fi
+ \fi
+ \setcounter{nprt@thisdigit}{#1}%
+ \if@@roundup
+ \addtocounter{nprt@thisdigit}{1}%
+ \ifnum\thenprt@thisdigit>9
+ \@@rounduptrue
+ \setcounter{nprt@thisdigit}{0}%
+ \else
+ \@@roundupfalse
+ \fi
+ \fi
+ \expandafter\xdef\expandafter\nprt@charsaftercomma{%
+ \thenprt@thisdigit\nprt@charsaftercomma}%
+ \addtocounter{nprt@position}{-1}%
+}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\nprt@roundup}
+% \begin{macrocode}
+\def\nprt@roundup#1#2\empty{%
+ \ifnum#1>4
+ \@@rounduptrue
+ \else
+ \@@roundupfalse
+ \fi
+}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\nprt@roundbeforecomma}
+% \begin{macrocode}
+\def\nprt@roundbeforecomma#1#2\empty{%
+ \edef\zwei{#2}%
+ \ifx\zwei\empty
+ \else
+ \nprt@roundbeforecomma#2\empty
+ \fi
+ \edef\eins{#1}%
+% \ifx\eins\nprt@minus@test
+% \expandafter\xdef\expandafter\nprt@charsbeforecomma{%
+% #1\nprt@charsbeforecomma}%
+% \else
+% \setcounter{nprt@thisdigit}{#1}%
+% \if@@roundup
+% \addtocounter{nprt@thisdigit}{1}%
+% \ifnum\thenprt@thisdigit>9
+% \@@rounduptrue
+% \setcounter{nprt@thisdigit}{0}%
+% \else
+% \@@roundupfalse
+% \fi
+% \fi
+ \ifnum-9>-1#1
+ \setcounter{nprt@thisdigit}{#1}%
+ \if@@roundup
+ \addtocounter{nprt@thisdigit}{1}%
+ \ifnum\thenprt@thisdigit>9
+ \@@rounduptrue
+ \setcounter{nprt@thisdigit}{0}%
+ \else
+ \@@roundupfalse
+ \fi
+ \fi
+ \expandafter\xdef\expandafter\nprt@charsbeforecomma{%
+ \thenprt@thisdigit\nprt@charsbeforecomma}%
+ \else
+ \if@@roundup
+ \expandafter\xdef\expandafter\nprt@charsbeforecomma{%
+ 1\nprt@charsbeforecomma}%
+ \@@roundupfalse
+ \fi
+ \expandafter\xdef\expandafter\nprt@charsbeforecomma{%
+ #1\nprt@charsbeforecomma}%
+ \fi
+}
+% \end{macrocode}
+% \end{macro}
+%
+% Define two new column types.
+%
+% The column type \verb|n| aligns the base number but not the exponent.
+% \begin{macrocode}
+\newcolumntype{n}[2]{>{\digits{#1}{#2}$}l<{$\nodigits}}
+% \end{macrocode}
+% Define two new column types.
+%
+% The column type \verb|n| aligns the base number as well as the exponent.
+% \begin{macrocode}
+\newcolumntype{N}[3]{%
+ >{\digits{#1}{#2}\exponentdigits{#3}$}l<{$\nodigits\noexponentdigits}}
+% \end{macrocode}
+% \iffalse
+%</package>
+% \fi
+% \Finale
+