summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/sepnum
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
committerNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
commite0c6872cf40896c7be36b11dcc744620f10adf1d (patch)
tree60335e10d2f4354b0674ec22d7b53f0f8abee672 /macros/latex/contrib/sepnum
Initial commit
Diffstat (limited to 'macros/latex/contrib/sepnum')
-rw-r--r--macros/latex/contrib/sepnum/sepnum-doc.pdfbin0 -> 351503 bytes
-rw-r--r--macros/latex/contrib/sepnum/sepnum-doc.tex123
-rw-r--r--macros/latex/contrib/sepnum/sepnum.sty218
3 files changed, 341 insertions, 0 deletions
diff --git a/macros/latex/contrib/sepnum/sepnum-doc.pdf b/macros/latex/contrib/sepnum/sepnum-doc.pdf
new file mode 100644
index 0000000000..ac1835de25
--- /dev/null
+++ b/macros/latex/contrib/sepnum/sepnum-doc.pdf
Binary files differ
diff --git a/macros/latex/contrib/sepnum/sepnum-doc.tex b/macros/latex/contrib/sepnum/sepnum-doc.tex
new file mode 100644
index 0000000000..0a5ce06bb4
--- /dev/null
+++ b/macros/latex/contrib/sepnum/sepnum-doc.tex
@@ -0,0 +1,123 @@
+\documentclass[pagesize=auto, fontsize=12pt, DIV=11, parskip=half]{scrartcl}
+
+\usepackage{fixltx2e}
+\usepackage{etex}
+\usepackage{lmodern}
+\usepackage[T1]{fontenc}
+\usepackage{textcomp}
+\usepackage[svgnames]{xcolor}
+\usepackage{listings}
+\usepackage{microtype}
+\usepackage{hyperref}
+
+\newcommand*{\mail}[1]{\href{mailto:#1}{\texttt{#1}}}
+\newcommand*{\pkg}[1]{\textsf{#1}}
+\newcommand*{\cs}[1]{\texttt{\textbackslash#1}}
+\makeatletter
+\newcommand*{\cmd}[1]{\cs{\expandafter\@gobble\string#1}}
+\makeatother
+\newcommand*{\meta}[1]{\textlangle\textsl{#1}\textrangle}
+\newcommand*{\marg}[1]{\texttt{\{}\meta{#1}\texttt{\}}}
+
+\addtokomafont{title}{\rmfamily}
+
+\lstset{%
+ language=[LaTeX]TeX,%
+ columns=flexible,%
+ upquote=true,%
+ numbers=left,%
+ basicstyle=\ttfamily,%
+ keywordstyle=\color{Navy},%
+ commentstyle=\color{DimGray},%
+ stringstyle=\color{SeaGreen},%
+ numberstyle=\scriptsize\color{SlateGray}%
+}
+
+\title{The \pkg{sepnum} package\thanks{This manual corresponds to \pkg{sepnum}~v2.0, dated~1996/09/05.}}
+\subtitle{Separated numbers}
+\author{Bernd Raichle\thanks{\mail{Raichle@Informatik.Uni-Stuttgart.de}}}
+\date{1996/09/05}
+
+
+\begin{document}
+
+\maketitle
+
+\begin{abstract}
+ \noindent
+ This package provides a means of formatting numbers
+ with (a) a decimal separator different of the default (`.')
+ and (b) a separator (default `,') every three digits.
+
+ First version of this package was posted to the newsgroup
+ `\texttt{de.comp.tex}' November 6th, 1995 (as `\pkg{printnum.sty}').
+\end{abstract}
+
+
+\section{Licensing condition}
+
+This program may be redistributed and/or modified under the terms
+of the \LaTeX\ Project Public License, either version~1.0 of this
+license, or (at your option) any later version.
+The latest version of this license is in \href{http://ctan.org/macros/latex/base/lppl.txt}{\texttt{CTAN:macros/latex/base/lppl.txt}}.
+
+
+\section{Usage}
+
+The macro
+%
+\begin{quote}
+ \cmd{\sepnum}\marg{c}\marg{sbc}\marg{sac}\marg{number}
+\end{quote}
+%
+produces the \meta{number} with the decimal point replaced by \meta{c}
+and the separator \meta{sbc} every three digits in the integer part,
+the separator \meta{sac} every three digits in the fractional part
+of \meta{number}. \cmd{\sepnum} is \emph{fully expandable} and \emph{not} fragile,
+unless one of \meta{c}, \meta{sbc}, or \meta{sac} is.
+
+\minisec{Example:}
+%
+\begin{itemize}
+\item a non realistic example to show the capabilities of \cmd{\sepnum} \\
+ \verb|\sepnum{,}{*}{-}{1234.5678}| $\Rightarrow$ 1*234,567-8
+\item to print a number inserting small spaces each three digits \\
+ \verb|\sepnum{.}{\,}{\,}{1234.5678}| $\Rightarrow$ 1\,234.567\,8
+\end{itemize}
+
+
+Additionally this package provides
+%
+\begin{quote}
+ \cmd{\sepnumform}\marg{c}\marg{sbc}\marg{sac}\marg{\LaTeX-counter}
+\end{quote}
+%
+to use \cmd{\sepnum} with a \LaTeX\ counter.
+
+
+\minisec{Example (with a decimal comma in the print form \cmd{\the\meta{counter}}):}
+%
+\begin{lstlisting}
+\newcounter{money}
+\renewcommand{\themoney}{\sepnumform{,}{.}{}{money}}
+
+\setcounter{money}{-1000}
+You have \themoney{} left.
+\end{lstlisting}
+%
+(For compatibility with `\pkg{printnum.sty}', the macros
+\cmd{\printnum}\marg{number} and \cmd{\print\-numKomma}\slash\cmd{\printnumTrenner}
+still exist.)
+
+
+\section{See also}
+
+\begin{itemize}
+\item Package ``\pkg{comma.sty}'' by David Carlisle which provides
+ similar features for integers only, i.\,e.\ it misses support
+ for the decimal point/comma in fixed point numbers.
+\item Package ``\pkg{numprint.sty}'' by Harald Harders supporting
+ formatting of numbers given as \texttt{1234e5} in addition.
+\end{itemize}
+
+\end{document}
diff --git a/macros/latex/contrib/sepnum/sepnum.sty b/macros/latex/contrib/sepnum/sepnum.sty
new file mode 100644
index 0000000000..5d81c61680
--- /dev/null
+++ b/macros/latex/contrib/sepnum/sepnum.sty
@@ -0,0 +1,218 @@
+%% This is file `sepnum.sty' -- separated numbers
+%%
+%% (C) 1995, 1996, 2001 Bernd Raichle
+%% Raichle@Informatik.Uni-Stuttgart.de
+%%
+%% This package provides a means of formatting numbers
+%% with (a) a decimal separator different of the default (`.')
+%% and (b) a separator (default `,') every three digits.
+%%
+%% First version of this package was posted to the newsgroup
+%% `de.comp.tex' November 6th, 1995 (as `printnum.sty').
+%%
+%%
+%% -- LICENSING CONDITION --
+%%
+%% This program may be redistributed and/or modified under the terms
+%% of the LaTeX Project Public License, either version 1.0 of this
+%% license, or (at your option) any later version.
+%% The latest version of this license is in
+%% CTAN:macros/latex/base/lppl.txt.
+%%
+%%
+%% -- USAGE --
+%%
+%% The macro
+%%
+%% \sepnum{<c>}{<sbc>}{<sac>}{<number>}
+%%
+%% produces the <number> with the decimal point replaced by <c>
+%% and the separator <sbc> every three digits in the integer part,
+%% the separator <sac> every three digits in the fractional part
+%% of <number>. \sepnum is _fully expandable_ and _not_ fragile,
+%% unless one of <c>, <sbc>, or <sac> is.
+%%
+%% Example:
+%% - a non realistic example to show the capabilities of \sepnum
+%% \sepnum{,}{*}{-}{1234.5678} => 1*234,567-8
+%% - to print a number inserting small spaces each three digits
+%% \sepnum{.}{\,}{\,}{1234.5678} => 1\,234.567\,8
+%%
+%%
+%% Additionally this package provides
+%%
+%% \sepnumform{<c>}{<sbc>}{<sac>}{<LaTeX-counter>}
+%%
+%% to use \sepnum with a LaTeX counter.
+%%
+%% Example (with a decimal comma in the print form \the<counter>):
+%% \newcounter{money}
+%% \renewcommand{\themoney}{\sepnumform{,}{.}{}{money}}
+%%
+%% \setcounter{money}{-1000}
+%% You have \themoney{} left.
+%%
+%%
+%% (For compatibility with `printnum.sty', the macros
+%% \printnum{<number>} and \printnumKomma/\printnumTrenner
+%% still exist.)
+%%
+%%
+%% -- SEE ALSO --
+%%
+%% * Package ``comma.sty'' by David Carlisle which provides
+%% similar features for integers only, i.e. it misses support
+%% for the decimal point/comma in fixed point numbers.
+%% * Package ``numprint.sty'' by Harald Harders supporting
+%% formatting of numbers given as 1234e5 in addition.
+%%
+%%
+\begingroup \expandafter\expandafter\expandafter\endgroup
+\expandafter\ifx \csname ProvidesPackage\endcsname\relax \else
+ \ProvidesPackage{sepnum}%
+ [1996/09/05 v2.0 Insert a separator every three digits (br)]
+\fi
+
+
+%
+% auxiliary macros for loops:
+%
+\newcommand{\sepnumReturnFi}{}
+\newcommand{\sepnumReturnElseFi}{}
+\newcommand{\sepnumReturnOrFi}{}
+
+\def\sepnumReturnFi#1\fi{\fi #1}
+\def\sepnumReturnElseFi#1\else#2\fi{\fi #1}
+\def\sepnumReturnOrFi#1\or#2\fi{\fi #1}
+
+%
+% \sepnum@DoNothing #1
+% don't change #1 (removes braces around argument token list!)
+%
+\newcommand{\sepnum@DoNothing}[1]{#1}
+
+%
+% \sepnum@ReverseNumber #1 #2
+% reverses all tokens in #2 and calls #1{#2} afterwards
+%
+\newcommand{\sepnum@ReverseNumber}[2]{%
+ \sepnum@DoReverseNumber{#1}{}#2\relax}
+\newcommand{\sepnum@DoReverseNumber}[3]{%
+ \ifx\relax#3\sepnumReturnElseFi{#1{#2}}%
+ \else\sepnumReturnFi{\sepnum@DoReverseNumber{#1}{#3#2}}%
+ \fi}
+
+%
+% \sepnum@ThreeDigits #1 #2 #3
+% reverses #3, inserts #1 every three tokens/digits
+% (you have to reverse #3 again using \sepnum@ReverseNumber!),
+% calls #2{#3} afterwards
+%
+\newcommand{\sepnum@ThreeDigits}[3]{%
+ \sepnum@DoThreeDigits{#1}{#2}{}0#3\relax}
+\newcommand{\sepnum@DoThreeDigits}[5]{%
+ \ifx\relax#5\sepnumReturnElseFi{#2{#3}}%
+ \else\sepnumReturnFi{%
+ \ifcase#4\noexpand\sepnum@DoNothing{}% 0
+ \sepnumReturnOrFi{\sepnum@DoThreeDigits{#1}{#2}{#5#3}1}%
+ \or % 1
+ \sepnumReturnOrFi{\sepnum@DoThreeDigits{#1}{#2}{#5#3}2}%
+ \or % 2
+ \sepnumReturnElseFi{\sepnum@DoThreeDigits{#1}{#2}{#5#3}3}%
+ \else % 3 ==> insert #1
+ \sepnumReturnFi{\sepnum@DoThreeDigits{#1}{#2}{#5#1#3}1}%
+ \fi}%
+ \fi}
+
+%
+% \sepnum@BeforeComma #1 #2
+% \sepnum@AfterComma #1 #2
+% call \sepnum@ReverseNumber and \sepnum@DoThreeDigits
+% to correctly group the number #2 every three digits
+% either with or without reversing first or afterwards.
+%
+\newcommand{\sepnum@BeforeComma}[2]{%
+ \sepnum@ReverseNumber{\sepnum@ThreeDigits{#1}\sepnum@DoNothing}{#2}}
+\newcommand{\sepnum@AfterComma}[2]{%
+ \sepnum@ThreeDigits{#1}{\sepnum@ReverseNumber\sepnum@DoNothing}{#2}}
+
+%
+%%%%%%%%%% USER MACRO %%%%%%%%%%
+%
+% \sepnum #1 #2 #3 #4
+%
+% #1 decimal comma
+% #2 separator for three digits groups before comma
+% #3 separator for three digits groups after comma
+% #4 number
+%
+\newcommand{\sepnum}[4]{%
+ \sepnum@Sign{#1}{#2}{#3}#4.\relax}
+%
+% look first for sign `+' or `-', divide given number in
+% digits before and after `.', insert #1 as decimal comma
+% (in \sepnum@SepComma)
+%
+\newcommand{\sepnum@Sign}[4]{%
+ \ifx\relax#4%
+ 0%
+ \else \sepnumReturnFi{%
+ \ifx -#4%
+ \sepnumReturnElseFi{-\sepnum@SepComma{#1}{#2}{#3}}%
+ \else \sepnumReturnFi{%
+ \ifx +#4%
+ \sepnumReturnElseFi{+\sepnum@SepComma{#1}{#2}{#3}}%
+ \else
+ \sepnumReturnFi{\sepnum@SepComma{#1}{#2}{#3}#4}%
+ \fi}%
+ \fi}%
+ \fi}
+
+\newcommand{\sepnum@SepComma}{}
+\def\sepnum@SepComma#1#2#3#4.#5\relax{%
+ \ifx$#4$0% no digits before `.' => add 0 for "0.xxx"
+ \else \sepnumReturnFi{\sepnum@BeforeComma{#2}{#4}}\fi
+ \ifx$#5$% no digits after `.'
+ \else \sepnumReturnFi{#1\sepnum@DoSepComma{#3}#5\relax}\fi}
+
+% remove `.' inserted in \sepnum
+\def\sepnum@DoSepComma#1#2.#3\relax{%
+ \sepnum@AfterComma{#1}{#2}}
+
+
+%
+%%%%%%%%%% USER MACRO %%%%%%%%%%
+%
+% \sepnumform #1 #2 #3 #4
+%
+% like \sepnum but #4 is the name of a LaTeX counter
+%
+\newcommand{\sepnumform}[4]{%
+ \expandafter\sepnum@doform
+ \expandafter{\number\value{#4}}{#1}{#2}{#3}}
+\newcommand{\sepnum@doform}[4]{%
+ \sepnum{#2}{#3}{#4}{#1}}
+
+
+%
+%%%%%%%%%% USER MACRO %%%%%%%%%%
+%
+% For compatibility with `printnum.sty':
+%
+% \printnum #1
+%
+\newcommand{\printnum}[1]{%
+ \sepnum{\printnumKomma}{\printnumTrenner}{\printnumTrenner}{#1}}
+%
+% Macros to specify comma and separator (default to get
+% european style numbers, e.g. "123.456,78" for "123456.78"):
+%
+% \printnumKomma => ,
+% \printnumTrenner => .
+%
+\newcommand{\printnumKomma}{,}
+\newcommand{\printnumTrenner}{.}
+
+\endinput
+%%
+%% End of file `sepnum.sty'.