diff options
author | Karl Berry <karl@freefriends.org> | 2024-02-28 21:26:31 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2024-02-28 21:26:31 +0000 |
commit | d2e9d959599d12fa20a1317cfd630476699b1cc7 (patch) | |
tree | 4483efeb37fc41ec3f70e566ec7a0d949890fd08 | |
parent | cd5a572346c8a396fed7e9c30c97e5d6ee475465 (diff) |
didec (28feb24)
git-svn-id: svn://tug.org/texlive/trunk@70229 c570f23f-e606-0410-a88d-b1316a301751
-rw-r--r-- | Master/texmf-dist/doc/latex/didec/CHANGES.md | 27 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/didec/README.md | 42 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/didec/didec.doc.sty | 157 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/didec/didec.pdf | bin | 0 -> 495045 bytes | |||
-rw-r--r-- | Master/texmf-dist/doc/latex/didec/didec.tex | 1209 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/didec/didec.sty | 1349 | ||||
-rwxr-xr-x | Master/tlpkg/bin/tlpkg-ctan-check | 3 | ||||
-rwxr-xr-x | Master/tlpkg/libexec/ctan2tds | 1 | ||||
-rw-r--r-- | Master/tlpkg/tlpsrc/collection-latexextra.tlpsrc | 1 | ||||
-rw-r--r-- | Master/tlpkg/tlpsrc/didec.tlpsrc | 0 |
10 files changed, 2788 insertions, 1 deletions
diff --git a/Master/texmf-dist/doc/latex/didec/CHANGES.md b/Master/texmf-dist/doc/latex/didec/CHANGES.md new file mode 100644 index 00000000000..388a94cf069 --- /dev/null +++ b/Master/texmf-dist/doc/latex/didec/CHANGES.md @@ -0,0 +1,27 @@ +# Changelog +All notable changes to this project will be documented in this file. + +The format is based on +[Keep a Changelog](https://keepachangelog.com/en/1.1.0/), +and this project adheres to +[Semantic Versioning](http://semver.org/spec/v2.0.0.html). + +## [Unreleased] + +### Added +### Changed +### Deprecated +### Removed +### Fixed +### Security + + + +## [1.0.0] - 2024-02-28 + +### Added +- Initial public release + + +## [-.-.-] +- Not public releases diff --git a/Master/texmf-dist/doc/latex/didec/README.md b/Master/texmf-dist/doc/latex/didec/README.md new file mode 100644 index 00000000000..d3027e39f5d --- /dev/null +++ b/Master/texmf-dist/doc/latex/didec/README.md @@ -0,0 +1,42 @@ +# The LaTeX package didec - version 1.0.0 (2024/02/28) + +> Copyright (c) 2024-2024 by Prof. Dr. Dr. Thomas F. Sturm <thomas dot sturm at unibw dot de> + +> This work may be distributed and/or modified under the +> conditions of the LaTeX Project Public License, either version 1.3 +> of this license or (at your option) any later version. +> The latest version of this license is in +> http://www.latex-project.org/lppl.txt +> and version 1.3 or later is part of all distributions of LaTeX +> version 2005/12/01 or later. + +> This work has the LPPL maintenance status `author-maintained`. + +> This work consists of all files listed in README.md + + +The `didec` package supports fixed-point arithmetic with two +decimal places (di-decimal) which is typical for financial +transactions in many currencies. +The intended use case is (personal) bookkeeping. + + +## Contents of the package + +- `README.md` this file +- `CHANGES.md` log of changes (history) +- `didec.sty` LaTeX package file (style file) +- `didec.pdf` Documentation for didec +- `didec.tex` Source code of the documentation +- `didec.doc.sty` Source code of the documentation + + +## Installation + +Copy the contents of the `didec.tds.zip` from CTAN to your local TeX file tree. + +Alternatively, put the files to their respective locations within the TeX installation: + +- `didec.sty` -> /tex/latex/didec +- all other files -> /doc/latex/didec + diff --git a/Master/texmf-dist/doc/latex/didec/didec.doc.sty b/Master/texmf-dist/doc/latex/didec/didec.doc.sty new file mode 100644 index 00000000000..0e5944e43fd --- /dev/null +++ b/Master/texmf-dist/doc/latex/didec/didec.doc.sty @@ -0,0 +1,157 @@ +% !TeX root = didec.tex +% !TeX encoding=UTF-8 +%% The LaTeX package didec - version 1.0.0 (2024/02/28) +%% didec.doc.sty: style file for the documentation +%% +%% ------------------------------------------------------------------------------------------- +%% Copyright (c) 2024-2024 by Prof. Dr. Dr. Thomas F. Sturm <thomas dot sturm at unibw dot de> +%% ------------------------------------------------------------------------------------------- +%% +%% This work may be distributed and/or modified under the +%% conditions of the LaTeX Project Public License, either version 1.3 +%% of this license or (at your option) any later version. +%% The latest version of this license is in +%% http://www.latex-project.org/lppl.txt +%% and version 1.3 or later is part of all distributions of LaTeX +%% version 2005/12/01 or later. +%% +%% This work has the LPPL maintenance status `author-maintained'. +%% +%% This work consists of all files listed in README.md +%% +% include file (style) of didec.tex (manual of the LaTeX package didec) + +\def\version{1.0.0}% +\def\datum{2024/02/28}% + +\IfFileExists{didec.doc.cfg}{\input{didec.doc.cfg}}{} + +\renewcommand*\l@subsection{\@dottedtocline{2}{1.5em}{2.7em}} +\renewcommand*\l@subsubsection{\@dottedtocline{3}{4.2em}{3.2em}} + +\RequirePackage[T1]{fontenc} +\RequirePackage[english]{babel} +\RequirePackage{lmodern,parskip,array} +\RequirePackage[svgnames,table]{xcolor} +\RequirePackage{tikz} +\RequirePackage{varioref} +\RequirePackage[makeindex]{imakeidx} +\RequirePackage[bookmarks,raiselinks,pageanchor,hyperindex,colorlinks]{hyperref} +\RequirePackage{cleveref} +\RequirePackage{varwidth,incgraph} +\RequirePackage[official]{eurosym} + +\RequirePackage[a4paper,left=2.5cm,right=2.5cm,top=1.5cm,bottom=1.5cm, + marginparsep=3mm,marginparwidth=18mm, + headheight=0mm,headsep=0cm, + footskip=1.5cm,includeheadfoot%,showframe + ]{geometry} +\RequirePackage{fancyhdr} +\fancyhf{} +\fancyfoot[C]{\thepage}% +\renewcommand{\headrulewidth}{0pt} +\renewcommand{\footrulewidth}{0pt} +\pagestyle{fancy} +\tolerance=2000% +\setlength{\emergencystretch}{20pt}% + +\RequirePackage{array,tabularx,booktabs} +\RequirePackage{lipsum} +\RequirePackage[extendedchars,encoding,filenameencoding=utf-8]{grffile} +\RequirePackage{siunitx,xfp} + +\RequirePackage{tcolorbox} +\tcbuselibrary{skins,minted,breakable,documentation,raster} + +\ifdefined\didecpackageprefix + \RequirePackage{\didecpackageprefix didec} +\else + \RequirePackage{didec} +\fi + +\definecolor{Green_Dark}{rgb}{0.078431,0.407843,0.176471} +\definecolor{Blue_Dark}{rgb}{0.090196,0.211765,0.364706} +\definecolor{Blue_Bright}{rgb}{0.858824,0.898039,0.945098} + +\colorlet{Blue_Gray}{blue!50!gray} + +\tcbset{skin=enhanced, + doc head={colback=yellow!10!white,interior style=fill}, + doc head key={colback=magenta!5!white,interior style=fill}, + color key=DarkViolet, + color value=Teal, + color color=Teal, + color counter=Orange!85!black, + color length=Orange!85!black, + index colorize, + index annotate, + beforeafter example/.style={ + before skip=4pt plus 2pt minus 1pt, + after skip=8pt plus 4pt minus 2pt + }, + docexample/.style={bicolor, + beforeafter example, + arc=0.66mm, + boxrule=0.33mm, + fonttitle=\bfseries, + fontlower=\footnotesize, + colframe=Blue_Gray, + colback=Blue_Gray!5!white, + colbacklower=white, + drop small lifted shadow, + listing engine=minted, + documentation minted options={tabsize=2,fontsize=\small,breaklines,autogobble}, + documentation minted style=colorful, + }, +} +\urlstyle{sf} + +\newtcblisting{fullexample}[1]{docexample,minted style=colorful, + listing and comment,pdf comment,freeze pdf,compilable listing,#1} + +\DeclareTotalTCBox{\myverb}{ O{} v }{tile,fontupper=\ttfamily,nobeforeafter, + tcbox raise base,boxsep=0.5mm,top=0pt,bottom=0pt,left=0pt,right=0pt,boxrule=0.3mm, + colback=yellow!10, + borderline horizontal={0.3mm}{0pt}{red!50}, + #1}{#2} + +\renewcommand*{\tcbdocnew}[1]{\textcolor{green!50!black}{\sffamily\bfseries N} #1} +\renewcommand*{\tcbdocupdated}[1]{\textcolor{blue!75!black}{\sffamily\bfseries U} #1} + +\newcommand{\formatPackageOption}[1]{package option} +\newcommand{\formatPackageOptions}[1]{Package options} + +\tcbmakedocSubKey[doc key prefix=]{docDidecKey}{didec} +\tcbmakedocSubKeys[doc key prefix=]{docDidecKeys}{didec} +\tcbmakedocSubKey[doc key prefix=, + index key formatter=\formatPackageOption, + index keys formatter=\formatPackageOptions +]{docPackageOption}{didec} +\tcbmakedocSubKeys[doc key prefix=, + index key formatter=\formatPackageOption, + index keys formatter=\formatPackageOptions +]{docPackageOptions}{didec} + + +\tcbset{ + deprecated*/.style={% + doc head={colback=black!1!white,interior style=fill}, + doc head key={colback=black!3!white,interior style=fill}, + color command={black!80!white}, + color option={black!60!white}, + }, + deprecated/.style={% + deprecated*, + before doc body command={\textcolor{black!80!white}{\textsc{Deprecated! }}} + }, +} + +\ExplSyntaxOn +\NewDocumentCommand \docColorExample { m } + { + \color_group_begin: + \color_select:n { #1 } + \rule[-1mm]{5mm}{4mm}~\docColor{#1} + \color_group_end: + } +\ExplSyntaxOff diff --git a/Master/texmf-dist/doc/latex/didec/didec.pdf b/Master/texmf-dist/doc/latex/didec/didec.pdf Binary files differnew file mode 100644 index 00000000000..b9d867eb7c5 --- /dev/null +++ b/Master/texmf-dist/doc/latex/didec/didec.pdf diff --git a/Master/texmf-dist/doc/latex/didec/didec.tex b/Master/texmf-dist/doc/latex/didec/didec.tex new file mode 100644 index 00000000000..fd3d26e0a38 --- /dev/null +++ b/Master/texmf-dist/doc/latex/didec/didec.tex @@ -0,0 +1,1209 @@ +% \LaTeX-Main\ +% !TeX encoding=UTF-8 +% !TeX spellcheck=en_US +%% +%% The LaTeX package didec - version 1.0.0 (2024/02/28) +%% didec.tex: Manual +%% +%% ------------------------------------------------------------------------------------------- +%% Copyright (c) 2024-2024 by Prof. Dr. Dr. Thomas F. Sturm <thomas dot sturm at unibw dot de> +%% ------------------------------------------------------------------------------------------- +%% +%% This work may be distributed and/or modified under the +%% conditions of the LaTeX Project Public License, either version 1.3 +%% of this license or (at your option) any later version. +%% The latest version of this license is in +%% http://www.latex-project.org/lppl.txt +%% and version 1.3 or later is part of all distributions of LaTeX +%% version 2005/12/01 or later. +%% +%% This work has the LPPL maintenance status `author-maintained'. +%% +%% This work consists of all files listed in README +%% +\documentclass[a4paper,11pt]{ltxdoc} +\usepackage{didec.doc} + +\hypersetup{ + pdftitle={Manual for the didec package}, + pdfauthor={Thomas F. Sturm}, + pdfsubject={Calculations with two decimal places}, + pdfkeywords={fixed-point arithmetic, two decimal places, calculations, cash book, bookkeeping, accountancy} +} + +\makeindex + +\pdfsuppresswarningpagegroup=1 + +\DeclareUnicodeCharacter{20AC}{\euro{}} +\didecsetup{ + decimal-separator = {,}, + grouping-separator = {.}, + currency = {}{\;€}, +} + +\didecnew{A} +\didecnew{B} +\didecnew{C} + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\begin{document} + +\begin{center} +\begin{tcolorbox}[enhanced,hbox,tikznode,left=8mm,right=8mm,boxrule=0.4pt, + colback=white,colframe=Blue_Gray, + drop lifted shadow=Blue_Gray!50,arc is angular, + before=\par\vspace*{5mm},after=\par\bigskip] +{\bfseries\LARGE The didec package}\\[3mm] +{\large Manual for version \version\ (\datum)} +\end{tcolorbox} +{\large Thomas F.~Sturm% + \footnote{Prof.~Dr.~Dr.~Thomas F.~Sturm, Institut f\"{u}r Mathematik und Informatik, + University of the Bundeswehr Munich, D-85577 Neubiberg, Germany; + email: \href{mailto:thomas.sturm@unibw.de}{thomas.sturm@unibw.de}}\par\medskip +\normalsize% +\url{https://www.ctan.org/pkg/didec}\par +\url{https://github.com/T-F-S/didec} +} +\end{center} +\bigskip +\begin{absquote} + \begin{center}\bfseries Abstract\end{center} + The \texttt{didec} package supports fixed-point arithmetic with two + decimal places (\emph{di-decimal}) which is typical for financial transactions + in many currencies. The intended use case is (personal) bookkeeping. +\end{absquote} + +\tableofcontents + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\clearpage +\section{Quick start}% +For the impatient: this package provides fixed-point arithmetic with +two decimal places. You may use it for any purpose where exactly two decimal +places are needed or suffice, but the main application case is (personal) bookkeeping. + +Say, John wants to keep track about his money. With +\begin{dispListing} +\didecnew{John} +\end{dispListing} +\didecnew{John} +a so-called \emph{didec variable} is created to store currency values. + +Now, lets fill in some money: +\begin{dispListing} +\didecset{John}{1000} +\end{dispListing} +\didecset{John}{1000} + +How much money has John now? +\begin{dispExample} +\didecuse{John} +\end{dispExample} + +Obviously, John has Euros and the amount is displayed in a German style manor. +Of course, this can be adapted to your liking, see \refCom{didecsetup}. +But now, let us spend some money. +\begin{dispExample} +\didecsub{John}{19.75} +\didecuse{John} +\end{dispExample} + +Preferably, the package functions are used inside convenient user commands. +You can choose between \LaTeX2e and \LaTeX3 programming layer functions. + +For this quick start, we make some convenience commands for John. +|\transaction| shall be one purchase made in cash and |\transaction*| one made +by credit card. +\begin{dispExample*}{breakable} +%\usepackage{booktabs} +\didecsetup{english, + currency = {\pounds}{}, + currency-negative = {-\pounds}{}, +} + +%\didecnew{John} +\didecnew{cash} +\didecnew{credit} +\didecnew{transaction} + +% Let's keep record in a table +\NewDocumentEnvironment{householdbook}{}{% + \begin{center} + \begin{tabular}{lp{9cm}rr}\toprule% + & Transaction & Expenses & Budget\\\midrule + }{% + \midrule% + \multicolumn{3}{r}{Cash} & \dideccoluse{cash}\\% + \multicolumn{3}{r}{Credit card} & \dideccoluse{credit}\\\bottomrule% + \end{tabular}% + \end{center} + } + +% One transaction +\NewDocumentCommand \transaction{ s m m } + { + \didecset{transaction}{#3}% + \didecsub{John}{transaction}% + \IfBooleanTF {#1}% + {\didecsub{credit}{transaction}CC}% + {\didecsub{cash}{transaction}}% + & #2 + & \dideccolinvuse{transaction} + & \dideccoluse{John}\\% + } + +% Ready to start our tiny accountancy + +\didecset{John}{1000} % John's money +\didecsetequal{cash}{John} % in cash +\didecset{credit}{0} % blank credit card + +\begin{householdbook} + \transaction{Coffee break with snack}{19.75} + \transaction*{Refuel}{62.87} + \transaction{Gift from Aunt Mary for helping her}{-30} + \transaction{Parking meter}{4.50} + \transaction*{Shopping for weekend}{147.23} + \transaction*{Fancy thing on the Internet}{270} + \transaction*{Cinema}{17.70} +\end{householdbook} + +\end{dispExample*} + + + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\clearpage +\section{Didec kernels and didec expressions}% + +All calculations are done on cent basis as integer operations, but all +displayed figures have two decimal places which give the name for the package +(\emph{di}-\emph{dec}imal). + +The package provides two numerical kernels which can be selected mutually +by package options \refKey{didec/int} or \refKey{didec/fp}. +The \refKey{didec/int} kernel is faster, but provides a smaller number range, +while the \refKey{didec/int} kernel is slower with a larger number range. +For ordinary people like you and me, the \refKey{didec/int} kernel will suffice +to do all personal financial calculations. +Upgrading later from \refKey{didec/int} to \refKey{didec/fp} is a matter of +just switching the package option setting. + +%------------------------------------------------------------------------------- +\begin{docPackageOptions}{{ + doc name = int, + doc description = {no value, initially set}, + }} +Selects the \meta{int} (integer) based numerical kernel with up to +9.33\footnote{joke for the mathematicians} significant figures and fast computation. +The number range for valid figures $n$ is: +\begin{center} +$ -21\;474\;836.47 \le n \le 21\;474\;836.47 $ +\end{center} +\begin{dispListing} +\usepackage[int]{didec} +\end{dispListing} +Using figures outside the valid range will result in \LaTeX\ errors complaining +about too large numbers. +\end{docPackageOptions} +%------------------------------------------------------------------------------- + + +%------------------------------------------------------------------------------- +\begin{docPackageOptions}{{ + doc name = fp, + doc description = {no value, initially unset}, + }} +Selects the \meta{fp} (floating-point) based numerical kernel with up to +16 significant figures and somewhat slower computation. +The number range for valid figures $n$ is: +\begin{center} +$ -99\;999\;999\;999\;999.99 \le n \le 99\;999\;999\;999\;999.99 $ +\end{center} +\begin{dispListing} +\usepackage[fp]{didec} +\end{dispListing} +Using figures outside the valid range will result in \emph{silent calculation errors}, +because \LaTeX3 \meta{fp} can use much larger numbers but is restricted to 16 +significant figures. +\end{docPackageOptions} +%------------------------------------------------------------------------------- + +\medskip + +In the following, a \meta{didec expr} (didec expression) denotes one of +the following: +\begin{itemize} +\item a number in floating-point notation, e.g. |123.45| +\item a number in floating-comma notation, e.g. |123,45| +\item a \meta{didec var} (didec variable), e.g. |expenses|. +\end{itemize} +Note that the notation \meta{didec expr} is inspired by \meta{int expr} and \meta{fp expr} +from \LaTeX3 but is in comparison very restricted and allows only the three choices above. +A \meta{didec expr} is always expanded and spaces are trimmed. + +\medskip + +Many provided commands or functions of the package come in three flavors, for +example: +\begin{itemize} +\item \refCom{didecadd}: This is a user command where arguments are space trimmed + and some check on variable existence is done. + Not existing variables are reported by speaking error messages (not in all cases!). +\item \refCom{didec_gadd_check:nn}: This a programming layer function + with no space trimming for arguments, but some check on variable existence is done. + Not existing variables are reported by speaking error messages (not in all cases!). +\item \refCom{didec_gadd:nn}: This a programming layer function + with no space trimming for arguments and no check on variable existence. + Not existing variables give strange errors. + This is the fasted function and base of the others above. +\end{itemize} + + +\clearpage +The following tables compare the computation time for selected functions of +the package for the two numerical kernels. Time values will differ on other +computers and also depend on selected values for the examples calculations. +Nevertheless, you get an impression of the differences. + + +%------------------------------------------------------------------------------- +\begin{tcbverbatimwrite}{\jobname.temp} +\begin{tcblisting}{ + blankest, + pdf comment, + comment style={raster columns=1,blankest,enhanced/.style=}, + comment only, + freeze pdf, + compilable listing, + run pdflatex +} +\IfFileExists{didec.doc.cfg}{\input{didec.doc.cfg}}{\def\didecpackageprefix{}} +\documentclass[a4paper,11pt]{ltxdoc} +\usepackage[a4paper,textwidth=8cm]{geometry} +\usepackage{lmodern,array,booktabs,incgraph} +\usepackage[skins,documentation]{tcolorbox} +\input{didec.tempinc} +\usepackage{l3benchmark,siunitx} +\begin{document} +\begin{inctext} +\begin{tcolorbox}[blankest] +\makeatletter +\ExplSyntaxOn +\cs_new_protected:Npn \didec_benchmark:n #1 +{ + \benchmark:n { #1 } + \tablenum[table-format=4.0]{ \fp_to_decimal:n { round( \g_benchmark_time_fp * 1 000 000 ) } }\,\unit{\micro\second} +} +\didecnew{A}\didecnew{B} +\fp_set:Nn \g_benchmark_duration_target_fp { 1 } +\begin{center} +\begin{tabular}{lr}\toprule +\multicolumn{2}{c}{ + kernel:~\texttt{\c_didec_kernel_str},~engine:~\texttt{\c_sys_engine_str} +}\\\midrule +\docAuxCommand*{didec_gset:nn} & \didec_benchmark:n{ \didec_gset:nn{A}{-9876,324} } +\\\docAuxCommand*{didec_gset_check:nn} & \didec_benchmark:n{ \didec_gset_check:nn{A}{-9876,324} } +\\\docAuxCommand*{didecset} & \didec_benchmark:n{ \didecset{A}{-9876,324} } +\\\midrule +\docAuxCommand*{didec_gset_eq:nn} & \didecset{B}{1234.56} \didec_benchmark:n{ \didec_gset_eq:nn{A}{B} } +\\\docAuxCommand*{didec_gset_eq_check:nn} & \didecset{B}{1234.56} \didec_benchmark:n{ \didec_gset_eq_check:nn{A}{B} } +\\\docAuxCommand*{didecsetequal} & \didecset{B}{1234.56} \didec_benchmark:n{ \didecsetequal{A}{B} } +\\\midrule +\docAuxCommand*{didec_gset_fp:nn} & \didec_benchmark:n{ \didec_gset_fp:nn{A}{51234.56} } +\\\docAuxCommand*{didec_gset_fp_check:nn} & \didec_benchmark:n{ \didec_gset_fp_check:nn{A}{51234.56} } +\\\docAuxCommand*{didecsetfp} & \didec_benchmark:n{ \didecsetfp{A}{51234.56} } +\\\midrule +\docAuxCommand*{didec_gadd:nn} & \didecset{A}{-987.34} \didec_benchmark:n{ \didec_gadd:nn{A}{12345} } +\\\docAuxCommand*{didec_gadd_check:nn} & \didecset{A}{-987.34}\didec_benchmark:n{ \didec_gadd_check:nn{A}{12345} } +\\\docAuxCommand*{didecadd} & \didecset{A}{-987.34} \didec_benchmark:n{ \didecadd{A}{12345} } +\\\midrule +\docAuxCommand*{didec_gadd_to:nnn} & \didec_benchmark:n{ \didec_gadd_to:nnn{A}{-4564}{12345} } +\\\docAuxCommand*{didec_gadd_to_check:nnn} & \didec_benchmark:n{ \didec_gadd_to_check:nnn{A}{-4564}{12345} } +\\\docAuxCommand*{didecadd} & \didec_benchmark:n{ \didecadd[A]{-4564}{12345} } +\\\midrule +\docAuxCommand*{didec_gmul_fp:nn} & \didecset{A}{-987.34} \didec_benchmark:n{ \didec_gmul_fp:nn{A}{0.99} } +\\\docAuxCommand*{didec_gmul_fp_check:nn} & \didecset{A}{-987.34}\didec_benchmark:n{ \didec_gmul_fp_check:nn{A}{0.99} } +\\\docAuxCommand*{didecmulfp} & \didecset{A}{-987.34} \didec_benchmark:n{ \didecmulfp{A}{0.99} } +\\\midrule +% +\docAuxCommand*{didec_if_positive:nTF} & \didecset{A}{-987.34} \didec_benchmark:n{ \didec_if_positive:nTF{A}{}{} } +\\\docAuxCommand*{didecifpositive} & \didecset{A}{-987.34} \didec_benchmark:n{ \didecifpositive{A}{}{} } +\\\docAuxCommand*{didec_compare:nNnTF} & \didecset{A}{-987.34} \didec_benchmark:n{ \didec_compare:nNnTF{A}>{12345}{}{} } +\\\docAuxCommand*{didecifgreaterthan} & \didecset{A}{-987.34} \didec_benchmark:n{ \didecifgreaterthan{A}{12345}{}{} } +\\\midrule +\docAuxCommand*{didec_to_fp:n} & \didecset{A}{-1234987.34} \didec_benchmark:n{ \setbox\z@\hbox{\didec_to_fp:n{A}} } +\\\docAuxCommand*{didec_to_fp_check:n} & \didecset{A}{-1234987.34} \didec_benchmark:n{ \setbox\z@\hbox{\didec_to_fp_check:n{A}} } +\\\docAuxCommand*{didectofp} & \didecset{A}{-1234987.34} \didec_benchmark:n{ \setbox\z@\hbox{\didectofp{A}} } +\\\midrule +\docAuxCommand*{didec_use:n} & \didecset{A}{-1234987.34} \didec_benchmark:n{ \setbox\z@\hbox{\didec_use:n{A}} } +\\\docAuxCommand*{didec_use_check:n} & \didecset{A}{-1234987.34} \didec_benchmark:n{ \setbox\z@\hbox{\didec_use_check:n{A}} } +\\\docAuxCommand*{didecuse} & \didecset{A}{-1234987.34} \didec_benchmark:n{ \setbox\z@\hbox{\didecuse{A}} } +\\\docAuxCommand*{didecformat} & \didec_benchmark:n{ \setbox\z@\hbox{\didecformat{-1234987.34}} } +\\\docAuxCommand*{didec_color_use:n} & \didecset{A}{-1234987.34} \didec_benchmark:n{ \setbox\z@\hbox{\didec_color_use:n{A}} } +\\\docAuxCommand*{didec_color_use_check:n} & \didecset{A}{-1234987.34} \didec_benchmark:n{ \setbox\z@\hbox{\didec_color_use_check:n{A}} } +\\\docAuxCommand*{dideccoluse} & \didecset{A}{-1234987.34} \didec_benchmark:n{ \setbox\z@\hbox{\dideccoluse{A}} } +\\\docAuxCommand*{dideccolformat} & \didec_benchmark:n{ \setbox\z@\hbox{\dideccolformat{-1234987.34}} } +\\\bottomrule +\end{tabular} +\end{center} +\ExplSyntaxOff +\makeatother +\end{tcolorbox} +\end{inctext} +\end{document} +\end{tcblisting} +\end{tcbverbatimwrite} +% +\begin{tcbraster}[raster column skip=0pt] +\begin{tcbverbatimwrite}{\jobname.tempinc} +\usepackage[int]{\didecpackageprefix didec} +\end{tcbverbatimwrite} +\input{\jobname.temp} +% +\begin{tcbverbatimwrite}{\jobname.tempinc} +\usepackage[fp]{\didecpackageprefix didec} +\end{tcbverbatimwrite} +\input{\jobname.temp} +\end{tcbraster} +%------------------------------------------------------------------------------- + + +\clearpage +If needed, the selected kernel can be questioned by the following: + +%------------------------------------------------------------------------------- +\begin{docCommands}[ + % doc parameter = \marg{didec var}, + ] +{ + { doc name = c_didec_kernel_str }, +} +The current kernel given as a lower case string: one of +\docValue*{int} or \docValue*{fp}. +\begin{dispExample} +\ExplSyntaxOn +\c_didec_kernel_str +\ExplSyntaxOff +\end{dispExample} +\end{docCommands} +%------------------------------------------------------------------------------- + + + +%------------------------------------------------------------------------------- +\begin{docCommands}[ + % doc parameter = \marg{didec var}, + ] +{ + { doc name = didec_if_kernel_int_p: }, + { doc name = didec_if_kernel_int:T, doc parameter = ~\marg{true code} }, + { doc name = didec_if_kernel_int:TF, doc parameter = ~\marg{true code}\marg{false code} }, + { doc name = didec_if_kernel_fp_p: }, + { doc name = didec_if_kernel_fp:T, doc parameter = ~\marg{true code} }, + { doc name = didec_if_kernel_fp:TF, doc parameter = ~\marg{true code}\marg{false code} }, +} +Conditionals which allow kernel-specific code to be used. The names follow +naturally from those of the kernels. +\begin{dispExample} +\ExplSyntaxOn +\didec_if_kernel_int:T { Integer~kernel~used. }\par +Floating~point~kernel +\didec_if_kernel_fp:TF { ~used. }{ ~not~used. } +\ExplSyntaxOff +\end{dispExample} +\end{docCommands} +%------------------------------------------------------------------------------- + + + + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\clearpage +\section{Creating didec variables}% + +%------------------------------------------------------------------------------- +\begin{docCommands}[ + doc parameter = \marg{didec var}, + ] +{ + { doc name = didecnew }, + { doc name = didec_new:n }, + } +Creates a new \meta{didec var} or raises an error if the name is already taken. +\refCom{didecnew} trims spaces while \refCom{didec_new:n} does not. +\begin{dispExample} +\didecnew{konto} +\didecset{konto}{99.75} +\didecuse{konto} +\end{dispExample} +\end{docCommands} +%------------------------------------------------------------------------------- + + +%\clearpage +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\section{Setting didec variables}% + + +%------------------------------------------------------------------------------- +\begin{docCommands}[ + doc parameter = \marg{didec var}\marg{didec expr}, + ] +{ + { doc name = didecset }, + { doc name = didec_gset:nn }, + { doc name = didec_gset_check:nn }, + } +Sets \meta{didec var} to the value of \meta{didec expr} which can be +\begin{itemize} +\item a number in floating-point notation, +\item a number in floating-comma notation, +\item another \meta{didec var}. +\end{itemize} +\refCom{didecset} trims spaces and performs an existence check for \meta{didec var}. +\refCom{didec_gset_check:nn} performs an existence check for \meta{didec var}. +Decimals places 3 and beyond are cut not rounded. +If rounding is an issue, use \refCom{didecsetfp} instead. +\begin{dispExample} +\didecset{A}{1234.56} +\didecuse{A} + +\didecset{A}{2345,6789} +\didecuse{A} + +\didecset{B}{-3500} +\didecset{A}{B} +\didecuse{A} +\end{dispExample} +\end{docCommands} +%------------------------------------------------------------------------------- + + + +%------------------------------------------------------------------------------- +\begin{docCommands}[ + doc parameter = \marg{didec var\textsubscript{1}}\marg{didec var\textsubscript{2}}, + ] +{ + { doc name = didecsetequal }, + { doc name = didec_gset_eq:nn }, + { doc name = didec_gset_eq_check:nn }, + } +Sets the \meta{didec var\textsubscript{1}} to the current value of \meta{didec var\textsubscript{2}} +\begin{dispExample} +\didecset{A}{1234.56} +\didecsetequal{B}{A} +\didecuse{A} +\didecuse{B} +\end{dispExample} +\end{docCommands} +%------------------------------------------------------------------------------- + + +\clearpage +%------------------------------------------------------------------------------- +\begin{docCommands}[ + doc parameter = \marg{didec var}\marg{didec expr}, + ] +{ + { doc name = didecsetnegative }, + { doc name = didec_gset_negative:nn }, + { doc name = didec_gset_negative_check:nn }, + } +Sets \meta{didec var} to the negated (opposite) value of \meta{didec expr}. +\refCom{didecsetnegative} trims spaces and performs an existence check for \meta{didec var}. +\begin{dispExample} +\didecsetnegative{A}{1234.56} +\didecuse{A} + +\didecsetnegative{A}{-42.55} +\didecuse{A} + +\didecset{B}{-3500} +\didecsetnegative{A}{B} +\didecuse{A} +\end{dispExample} +\end{docCommands} +%------------------------------------------------------------------------------- + + + +%------------------------------------------------------------------------------- +\begin{docCommands}[ + doc parameter = \marg{didec var}\marg{fp expr}, + ] +{ + { doc name = didecsetfp }, + { doc name = didec_gset_fp:nn }, + { doc name = didec_gset_fp_check:nn }, + } +Sets \meta{didec var} to the value of \meta{fp expr} which can +by any \LaTeX3 floating-point expression. +\refCom{didecsetfp} trims spaces and performs an existence check for \meta{didec var}. +Other didec variables can be used inside \meta{fp expr} if guarded with \refCom{didectofp}. +The result is rounded to 2 decimal places. +\refCom{didec_gset_fp_check:nn} performs an existence check for \meta{didec var}. +\begin{dispExample} +\didecsetfp{A}{2345.6789} +\didecuse{A} + +\didecsetfp{A}{ ln( 12345678 ) } +\didecuse{A} + +\didecset{A}{123456,78} +\didecsetfp{B}{ \didectofp{A} * 2.35 / 100 } +2.35\% of \didecuse{A} are \didecuse{B}. +\end{dispExample} +\end{docCommands} +%------------------------------------------------------------------------------- + + +\clearpage +%------------------------------------------------------------------------------- +\begin{docCommands} +{ + { doc name = didecadd, doc parameter = \oarg{didec var}\marg{didec expr\textsubscript{1}}\marg{didec expr\textsubscript{2}} }, + { doc name = didec_gadd:nn, doc parameter = \marg{didec var}\marg{didec expr} }, + { doc name = didec_gadd_check:nn, doc parameter = \marg{didec var}\marg{didec expr} }, + { doc name = didec_gadd_to:nnn, doc parameter = \marg{didec var}\marg{didec expr\textsubscript{1}}\marg{didec expr\textsubscript{2}} }, + { doc name = didec_gadd_to_check:nnn, doc parameter = \marg{didec var}\marg{didec expr\textsubscript{1}}\marg{didec expr\textsubscript{2}} }, + } +\begin{itemize} +\item Adds the result of computing the \meta{didec expr} to the \meta{didec var} +\item or sets \meta{didec var} to the sum of \meta{didec expr\textsubscript{1}} and \meta{didec expr\textsubscript{2}}. +\item For \refCom{didecadd}, if the optional \meta{didec var} is not available, + the sum is stored into \meta{didec expr\textsubscript{1}} which has to be a \meta{didec var} + in this case. +\end{itemize} +\begin{dispExample} +\didecset{A}{123} +\didecset{B}{5,88} +\didecadd{A}{B} +\didecuse{A} + +\didecadd[A]{B}{1000} +\didecuse{A} + +\didecadd{A}{-2750} +\didecuse{A} +\end{dispExample} +\end{docCommands} +%------------------------------------------------------------------------------- + + +%\clearpage +%------------------------------------------------------------------------------- +\begin{docCommands} +{ + { doc name = didecsub, doc parameter = \oarg{didec var}\marg{didec expr\textsubscript{1}}\marg{didec expr\textsubscript{2}} }, + { doc name = didec_gsub:nn, doc parameter = \marg{didec var}\marg{didec expr} }, + { doc name = didec_gsub_check:nn, doc parameter = \marg{didec var}\marg{didec expr} }, + { doc name = didec_gsub_to:nnn, doc parameter = \marg{didec var}\marg{didec expr\textsubscript{1}}\marg{didec expr\textsubscript{2}} }, + { doc name = didec_gsub_to_check:nnn, doc parameter = \marg{didec var}\marg{didec expr\textsubscript{1}}\marg{didec expr\textsubscript{2}} }, + } +\begin{itemize} +\item Subtracts the result of computing the \meta{didec expr} to the \meta{didec var} +\item or sets \meta{didec var} to the difference of \meta{didec expr\textsubscript{1}} and \meta{didec expr\textsubscript{2}}. +\item For \refCom{didecsub}, if the optional \meta{didec var} is not available, + the difference is stored into \meta{didec expr\textsubscript{1}} which has to be a \meta{didec var} + in this case. +\end{itemize} +\begin{dispExample} +\didecset{A}{123} +\didecset{B}{5,88} +\didecsub{A}{B} +\didecuse{A} + +\didecsub[A]{B}{1000} +\didecuse{A} + +\didecsub{A}{-2750} +\didecuse{A} +\end{dispExample} +\end{docCommands} +%------------------------------------------------------------------------------- + + +\clearpage +%------------------------------------------------------------------------------- +\begin{docCommands} +{ + { doc name = didecmulfp, doc parameter = \oarg{didec var\textsubscript{2}}\marg{didec var}\marg{fp expr} }, + { doc name = didec_gmul_fp:nn, doc parameter = \marg{didec var}\marg{fp expr} }, + { doc name = didec_gmul_fp_check:nn, doc parameter = \marg{didec var}\marg{fp expr} }, + { doc name = didec_gmul_fp_to:nnn, doc parameter = \marg{didec var\textsubscript{2}}\marg{didec var}\marg{fp expr} }, + { doc name = didec_gmul_fp_to_check:nnn, doc parameter = \marg{didec var\textsubscript{2}}\marg{didec var}\marg{fp expr} }, + } +\begin{itemize} +\item Multiplies \meta{didec var} with the result of computing the \meta{fp expr} +\item and sets \meta{didec var} or respectively \meta{didec var\textsubscript{2}} to the result. +\end{itemize} +\begin{dispExample} +\didecset{A}{123} +\didecmulfp{A}{0.9675} +\didecuse{A} + +\didecmulfp[B]{A}{ln(42)} +\didecuse{B} +\end{dispExample} +\end{docCommands} +%------------------------------------------------------------------------------- + + + +%------------------------------------------------------------------------------- +\begin{docCommands} +{ + { doc name = didecdivfp, doc parameter = \oarg{didec var\textsubscript{2}}\marg{didec var}\marg{fp expr} }, + { doc name = didec_gdiv_fp:nn, doc parameter = \marg{didec var}\marg{fp expr} }, + { doc name = didec_gdiv_fp_check:nn, doc parameter = \marg{didec var}\marg{fp expr} }, + { doc name = didec_gdiv_fp_to:nnn, doc parameter = \marg{didec var\textsubscript{2}}\marg{didec var}\marg{fp expr} }, + { doc name = didec_gdiv_fp_to_check:nnn, doc parameter = \marg{didec var\textsubscript{2}}\marg{didec var}\marg{fp expr} }, + } +\begin{itemize} +\item Divides \meta{didec var} by the result of computing the \meta{fp expr} +\item and sets \meta{didec var} or respectively \meta{didec var\textsubscript{2}} to the result. +\end{itemize} +\begin{dispExample} +\didecset{A}{123} +\didecdivfp{A}{0.9675} +\didecuse{A} + +\didecdivfp[B]{A}{ln(42)} +\didecuse{B} +\end{dispExample} +\end{docCommands} +%------------------------------------------------------------------------------- + + +%------------------------------------------------------------------------------- +\begin{docCommands} +{ + { doc name = didecsetsum, doc parameter = \oarg{didec var}\marg{sum of didec exp} }, +} +Sets \meta{didec var} to the result of computing the given \meta{sum of didec exp}.\par +Here, \meta{sum of didec exp} = \meta{didec exp\textsubscript{1}} ++ \meta{didec exp\textsubscript{2}} + \ldots + \meta{didec exp\textsubscript{n}} +\begin{dispExample} +\didecset{A}{123} +\didecset{B}{-32.15} +\didecsetsum{A}{ A + B + -22.5 } +\didecuse{A} +\end{dispExample} +\end{docCommands} +%------------------------------------------------------------------------------- + + + +\clearpage +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\section{Using didecs}% + + +%------------------------------------------------------------------------------- +\begin{docCommands} +{ + { doc name = didectoint, doc parameter = \marg{didec var} }, + { doc name = didec_to_int:n, doc parameter = \marg{didec var} }, + { doc name = didec_to_int_check:n, doc parameter = \marg{didec var} }, +} +Expresses the \meta{didec var} as Cent integer value, i.e. 100 times the +value. +All functions are expandable. +\begin{dispExample} +\didecset{A}{27123.45} +\didectoint{A} + +\didecset{A}{-17} +\didectoint{A} +\end{dispExample} +\end{docCommands} +%------------------------------------------------------------------------------- + + + +%------------------------------------------------------------------------------- +\begin{docCommands} +{ + { doc name = didectofp, doc parameter = \marg{didec var} }, + { doc name = didec_to_fp:n, doc parameter = \marg{didec var} }, + { doc name = didec_to_fp_check:n, doc parameter = \marg{didec var} }, +} +Expresses the \meta{didec var} as floating-point value. +All functions are expandable. +\begin{dispExample} +\didecset{A}{27123.45} +\didectofp{A} + +\didecset{A}{-17} +\didectofp{A} +\end{dispExample} +\end{docCommands} +%------------------------------------------------------------------------------- + + + +%------------------------------------------------------------------------------- +\begin{docCommands} +{ + { doc name = didectofc, doc parameter = \marg{didec var} }, + { doc name = didec_to_fc:n, doc parameter = \marg{didec var} }, + { doc name = didec_to_fc_check:n, doc parameter = \marg{didec var} }, +} +Expresses the \meta{didec var} as floating-comma value. +All functions are expandable. +\begin{dispExample} +\didecset{A}{27123.45} +\didectofc{A} + +\didecset{A}{-17} +\didectofc{A} +\end{dispExample} +\end{docCommands} +%------------------------------------------------------------------------------- + + +\clearpage +%------------------------------------------------------------------------------- +\begin{docCommands} +{ + { doc name = didecuse, doc parameter = \oarg{key list}\marg{didec var} }, + { doc name = didec_use:n, doc parameter = \marg{didec var} }, + { doc name = didec_use_check:n, doc parameter = \marg{didec var} }, +} +Expresses the \meta{didec var} as formatted value. +With \refCom{didecsetup}, the standard format can be set. +This standard format can be overwritten by \meta{key list}. +\begin{dispExample} +\didecset{A}{123456.78} +\didecuse{A} + +\didecuse[ + currency = {\pounds}{}, + decimal-separator = {.}, + grouping-separator = {,}, + ]{A} +\end{dispExample} +\end{docCommands} +%------------------------------------------------------------------------------- + + + +%------------------------------------------------------------------------------- +\begin{docCommands} +{ + { doc name = dideccoluse, doc parameter = \oarg{key list}\marg{didec var} }, + { doc name = didec_color_use:n, doc parameter = \marg{didec var} }, + { doc name = didec_color_use_check:n, doc parameter = \marg{didec var} }, +} +Expresses the \meta{didec var} as colorized formatted value. +With \refCom{didecsetup}, the standard format can be set. +This standard format can be overwritten by \meta{key list}. +\begin{dispExample} +\didecset{A}{123456.78} +\dideccoluse{A} + +\didecset{A}{-125} +\dideccoluse{A} + +\dideccoluse[color-negative=didec-blue]{A} +\end{dispExample} +\end{docCommands} +%------------------------------------------------------------------------------- + + +%------------------------------------------------------------------------------- +\begin{docCommands} +{ + { doc name = dideccolinvuse, doc parameter = \oarg{key list}\marg{didec var} }, + { doc name = didec_color_inverse_use:n, doc parameter = \marg{didec var} }, + { doc name = didec_color_inverse_use_check:n, doc parameter = \marg{didec var} }, +} +Expresses the \meta{didec var} as colorized formatted value. +The coloring is switched between positive and negative. +The standard +coloring and format can be overwritten by \meta{key list}. +\begin{dispExample} +\didecset{A}{123456.78} +\dideccolinvuse{A} + +\didecset{A}{-125} +\dideccolinvuse{A} +\end{dispExample} +\end{docCommands} +%------------------------------------------------------------------------------- + + +\clearpage +%------------------------------------------------------------------------------- +\begin{docCommands} +{ + { doc name = didecformat, doc parameter = \oarg{key list}\marg{didec expr} }, + { doc name = dideccolformat, doc parameter = \oarg{key list}\marg{didec expr} }, + { doc name = dideccolinvformat, doc parameter = \oarg{key list}\marg{didec expr} }, +} +Like \refCom{didecuse}, \refCom{dideccoluse}, \refCom{dideccolinvuse}, +but accepts a \meta{didec expr} instead of a \meta{didec var}. +If the \meta{didec expr} is a \meta{didec var}, +\refCom{didecuse}, \refCom{dideccoluse}, \refCom{dideccolinvuse} are more efficient. +\begin{dispExample} +\didecformat{123456.78}\\ +\didecformat{A}\\ +\didecformat[english]{123456.78}\\ +\dideccolformat{123456.78}\\ +\dideccolinvformat{123456.78} +\end{dispExample} +\end{docCommands} +%------------------------------------------------------------------------------- + + +%------------------------------------------------------------------------------- +\begin{docCommands} +{ + { doc name = didecsetup, doc parameter = \marg{key list} }, +} +Sets all keys of the given \meta{key list}. See the following documentation +for available settings. +\begin{dispExample} +\didecsetup{ + currency = {\pounds}{}, + decimal-separator = {.}, + grouping-separator = {,}, +} +\didecset{A}{123456.78} +\didecuse{A} +\end{dispExample} +\end{docCommands} +%------------------------------------------------------------------------------- + + +\clearpage +%------------------------------------------------------------------------------- +\begin{docDidecKeys} +{ + { + doc name = decimal-separator, + doc parameter = {=\marg{separator}}, + doc description = {initially |,|}, + }, +} +Sets some \meta{separator} as decimal separator. +\begin{dispExample} +\didecset{A}{123456.78} +\didecuse[ decimal-separator={\#} ]{A} \par +\end{dispExample} +\end{docDidecKeys} +%------------------------------------------------------------------------------- + + + +%------------------------------------------------------------------------------- +\begin{docDidecKeys} +{ + { + doc name = grouping-separator, + doc parameter = {=\marg{separator}}, + doc description = {initially |.|}, + }, +} +Sets some \meta{separator} as grouping separator. +\begin{dispExample} +\didecset{A}{123456.78} +\didecuse[ grouping-separator={'} ]{A} +\end{dispExample} +\end{docDidecKeys} +%------------------------------------------------------------------------------- + + + +%------------------------------------------------------------------------------- +\begin{docDidecKeys} +{ + { + doc name = currency, + doc parameter = {=\marg{prefix}\marg{postfix}}, + doc description = {initially empty}, + }, +} +Sets some \meta{prefix} and \meta{postfix} to denote the currency of the +didec variable. +This also sets\\ +\refKey{didec/currency-negative}\brackets{\meta{prefix}-}\marg{postfix} +\begin{dispExample} +\didecset{A}{123456.78} +\didecuse[ currency = {\pounds}{} ]{A} \par +\didecuse[ currency = {}{\:Gulden} ]{A} +\end{dispExample} +\end{docDidecKeys} +%------------------------------------------------------------------------------- + + + +%------------------------------------------------------------------------------- +\begin{docDidecKeys} +{ + { + doc name = currency-negative, + doc parameter = {=\marg{prefix}\marg{postfix}}, + doc description = {initially empty}, + }, +} +Sets some \meta{prefix} and \meta{postfix} to denote the currency of the +didec variable, if the resulting value is negative. Otherwise, the settings of +\refKey{didec/currency} are used. +Note that you need to set a minus sign |-| explicitly, if you want to see it. +Also note that setting \refKey{didec/currency} overwrites values given +by \refKey{didec/currency-negative}. +\begin{dispExample} +\didecset{A}{-123456.78} +\didecuse{A}\par +\didecuse[ currency-negative = {$-$}{\;€} ]{A} \par +\didecuse[ currency-negative = {(}{\;€)} ]{A} \par +\didecuse[ currency-negative = {(}{)\;€} ]{A} \par +\didecuse[ currency-negative = {-€}{} ]{A} \par +\end{dispExample} +\end{docDidecKeys} +%------------------------------------------------------------------------------- + + +\clearpage +%------------------------------------------------------------------------------- +\begin{docDidecKeys}[ + doc parameter = , + doc description = style, +] +{ + { doc name = german }, + { doc name = english }, + { doc name = french }, + { doc name = float }, +} +Styles to set some format preferences combined. +Any currency settings are removed and should be applied afterwards, +if needed. +Note that \refCom{didectofp} is more efficient than \refCom{didecuse} with +style \refKey{didec/float}. +\begin{center} +\begin{tabular}{>{\ttfamily}l>{\ttfamily}c>{\ttfamily}c>{\ttfamily}c>{\ttfamily}c}\toprule + & german & english & french & float\\\midrule +decimal-separator & , & . & , & . \\ +grouping-separator & . & , & |\;| & \\\bottomrule +\end{tabular} +\end{center} +\begin{dispExample} +\didecset{A}{12345678.90} +\didecuse[german]{A} \par +\didecuse[english]{A} \par +\didecuse[french]{A} \par +\didecuse[float]{A} \par +\end{dispExample} +\end{docDidecKeys} +%------------------------------------------------------------------------------- + + +%------------------------------------------------------------------------------- +\begin{docDidecKeys} +{ + { + doc name = color-positive, + doc parameter = {=\meta{positive color}}, + doc description = {initially |didec-green|}, + }, + { + doc name = color-negative, + doc parameter = {=\meta{negative color}}, + doc description = {initially |didec-red|}, + }, +} +Sets \meta{positive color} to denote positive (and zero) values +and \meta{negative color} to denote negative values. +Any valid |l3color| \meta{color expression} can be used. +The package defines additional colors +\begin{itemize} +\item\docColorExample{didec-green} +\item\docColorExample{didec-red} +\item\docColorExample{didec-blue} +\end{itemize} +\begin{dispExample} +\didecset{A}{123456.78} +\dideccoluse[ color-positive = magenta ]{A} +\end{dispExample} +\end{docDidecKeys} +%------------------------------------------------------------------------------- + + + + +%------------------------------------------------------------------------------- +\begin{docCommands} +{ + { doc name = didecwrite, doc parameter = \marg{didec var}\marg{stream} }, + { doc name = didec_write:nn, doc parameter = \marg{didec var}\marg{stream} }, + { doc name = didec_write_check:nn, doc parameter = \marg{didec var}\marg{stream} }, +} +Writes \refCom{didecset}\marg{didec var}\marg{current value} to the given +already opened output \meta{stream}. +\begin{dispListing} +\didecwrite{A}{output} +% writes to output: +% \didecset{A}{VALUE} +\end{dispListing} +\end{docCommands} +%------------------------------------------------------------------------------- + + +\clearpage +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\section{Didec conditionals}% +%------------------------------------------------------------------------------- +\begin{docCommands}[ + doc parameter = \marg{didec var}\marg{true code}\marg{false code}, + ] +{ + { doc name = didecifpositive }, + { doc name = didec_if_positive_p:n, doc parameter = \marg{didec var} }, + { doc name = didec_if_positive:nTF, }, + { doc name = didec_if_positive:nT, doc parameter = \marg{didec var}\marg{true code} }, + { doc name = didec_if_positive:nF, doc parameter = \marg{didec var}\marg{false code} }, + } +Evaluates the \meta{didec var} +and returns |true| or executes the \meta{true code} if the value is positive, +otherwise returns |false| or executes the \meta{false code}. +\begin{dispExample} +\didecset{A}{2799.50} +\didecuse{A} is \didecifpositive{A}{positive}{not positive}. + +\didecset{B}{-584} +\didecuse{B} is \didecifpositive{B}{positive}{not positive}. + +\didecset{A}{0} +\didecuse{A} is \didecifpositive{A}{positive}{not positive}. +\end{dispExample} +\end{docCommands} +%------------------------------------------------------------------------------- + + +%------------------------------------------------------------------------------- +\begin{docCommands}[ + doc parameter = \marg{didec var}\marg{true code}\marg{false code}, + ] +{ + { doc name = didecifnegative }, + { doc name = didec_if_negative_p:n, doc parameter = \marg{didec var} }, + { doc name = didec_if_negative:nTF, }, + { doc name = didec_if_negative:nT, doc parameter = \marg{didec var}\marg{true code} }, + { doc name = didec_if_negative:nF, doc parameter = \marg{didec var}\marg{false code} }, + } +Evaluates the \meta{didec var} +and returns |true| or executes the \meta{true code} if the value is negative, +otherwise returns |false| or executes the \meta{false code}. +\begin{dispExample} +\didecset{A}{2799.50} +\didecuse{A} is \didecifnegative{A}{negative}{not negative}. + +\didecset{B}{-584} +\didecuse{B} is \didecifnegative{B}{negative}{not negative}. + +\didecset{A}{0} +\didecuse{A} is \didecifnegative{A}{negative}{not negative}. +\end{dispExample} +\end{docCommands} +%------------------------------------------------------------------------------- + + +\clearpage +%------------------------------------------------------------------------------- +\begin{docCommands}[ + doc parameter = \marg{didec var}\marg{true code}\marg{false code}, + ] +{ + { doc name = didecifzero }, + { doc name = didec_if_zero_p:n, doc parameter = \marg{didec var} }, + { doc name = didec_if_zero:nTF, }, + { doc name = didec_if_zero:nT, doc parameter = \marg{didec var}\marg{true code} }, + { doc name = didec_if_zero:nF, doc parameter = \marg{didec var}\marg{false code} }, + } +Evaluates the \meta{didec var} +and returns |true| or executes the \meta{true code} if the value is zero, +otherwise returns |false| or executes the \meta{false code}. +\begin{dispExample} +\didecset{A}{2799.50} +\didecuse{A} is \didecifzero{A}{zero}{not zero}. + +\didecset{B}{-584} +\didecuse{B} is \didecifzero{B}{zero}{not zero}. + +\didecset{A}{0} +\didecuse{A} is \didecifzero{A}{zero}{not zero}. +\end{dispExample} +\end{docCommands} +%------------------------------------------------------------------------------- + + + + + + +%------------------------------------------------------------------------------- +\begin{docCommands}[ + doc parameter = \marg{didec expr\textsubscript{1}}\marg{didec expr\textsubscript{2}}\marg{true code}\marg{false code}, + ] +{ + { doc name = dideciflowerthan }, + { doc name = didecifequal }, + { doc name = didecifgreaterthan }, + { doc name = didec_compare_p:nNn, doc parameter = \marg{didec expr\textsubscript{1}}\meta{relation}\marg{didec expr\textsubscript{2}} }, + { doc name = didec_compare:nNnTF, doc parameter = \marg{didec expr\textsubscript{1}}\meta{relation}\marg{didec expr\textsubscript{2}}\marg{true code}\marg{false code} }, + { doc name = didec_compare:nNnT, doc parameter = \marg{didec expr\textsubscript{1}}\meta{relation}\marg{didec expr\textsubscript{2}}\marg{true code} }, + { doc name = didec_compare:nNnF, doc parameter = \marg{didec expr\textsubscript{1}}\meta{relation}\marg{didec expr\textsubscript{2}}\marg{false code} }, + } +Compares the \meta{didec expr\textsubscript{1}} and the \meta{didec expr\textsubscript{2}}, +and returns |true| or executes the \meta{true code} if the \meta{relation} (given by function respectively) +is obeyed, otherwise returns |false| or executes the \meta{false code}. +\begin{dispExample} +\didecset{A}{2799.50} +\didecset{B}{-584} +\didecuse{A} is \dideciflowerthan{A}{B}{lower}{not lower} than \didecuse{B} + +\didecuse{A} is \didecifequal{A}{B}{equal}{not equal} to \didecuse{B} + +\didecuse{A} is \didecifequal{A}{A}{equal}{not equal} to \didecuse{A} + +\didecuse{A} is \didecifgreaterthan{A}{B}{greater}{not greater} than \didecuse{B} +\end{dispExample} +\end{docCommands} +%------------------------------------------------------------------------------- + + +\clearpage +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\section{Viewing didecs}% + +%------------------------------------------------------------------------------- +\begin{docCommands} +{ + { doc name = didec_show:n, doc parameter = \marg{didec var} }, + } +Displays the content of \meta{didec var} in the terminal. +\begin{dispListing} +\didecset{A}{2799.50} +\ExplSyntaxOn +\didec_show:n{A} +\ExplSyntaxOff +\end{dispListing} +\end{docCommands} +%------------------------------------------------------------------------------- + + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\clearpage +\phantomsection +\printindex + +\end{document} diff --git a/Master/texmf-dist/tex/latex/didec/didec.sty b/Master/texmf-dist/tex/latex/didec/didec.sty new file mode 100644 index 00000000000..885e28b2583 --- /dev/null +++ b/Master/texmf-dist/tex/latex/didec/didec.sty @@ -0,0 +1,1349 @@ +%% The LaTeX package didec - version 1.0.0 (2024/02/28) +%% didec.sty: numbers with two decimal places +%% !TeX encoding=UTF-8 +%% +%% ------------------------------------------------------------------------------------------- +%% Copyright (c) 2024-2024 by Prof. Dr. Dr. Thomas F. Sturm <thomas dot sturm at unibw dot de> +%% ------------------------------------------------------------------------------------------- +%% +%% This work may be distributed and/or modified under the +%% conditions of the LaTeX Project Public License, either version 1.3 +%% of this license or (at your option) any later version. +%% The latest version of this license is in +%% http://www.latex-project.org/lppl.txt +%% and version 1.3 or later is part of all distributions of LaTeX +%% version 2005/12/01 or later. +%% +%% This work has the LPPL maintenance status `author-maintained'. +%% +%% This work consists of all files listed in README.md +%% +\NeedsTeXFormat{LaTeX2e}[2023-11-01] +\ProvidesExplPackage{didec}{2024/02/28}{1.0.0} + {Fixed-point arithmetic with two decimal places} + +%------- package options ------------------- + +\DeclareKeys + { + int .code:n = + { + \prg_set_conditional:Nnn \didec_if_kernel_int: { p, T, TF } { \prg_return_true: } + \prg_set_conditional:Nnn \didec_if_kernel_fp: { p, T, TF } { \prg_return_false: } + }, + fp .code:n = + { + \prg_set_conditional:Nnn \didec_if_kernel_int: { p, T, TF } { \prg_return_false: } + \prg_set_conditional:Nnn \didec_if_kernel_fp: { p, T, TF } { \prg_return_true: } + }, + } + +\ProcessKeyOptions + +\cs_if_exist:NF \didec_if_kernel_int_p: + { + \SetKeys{ int } + } + +%------- integer kernel (int) ------------------- + +\if_predicate:w \didec_if_kernel_int_p: + +\str_const:Nn \c_didec_kernel_str { int } + +% <int> +% test on existence of didec variable #1 +% adapted from \cs_if_exist:c +\prg_new_conditional:Npnn \didec_if_exist:n #1 { p, T, F, TF } + { + \if_cs_exist:w g_didec_var_#1_int \cs_end: + \exp_after:wN \use_i:nn + \else: + \exp_after:wN \use_ii:nn + \fi: + { + \exp_after:wN \if_meaning:w \cs:w g_didec_var_#1_int \cs_end: \scan_stop: + \prg_return_false: + \else: + \prg_return_true: + \fi: + } + \prg_return_false: + } + +% <int> +% #1 integer value +\prg_new_conditional:Npnn \__didec_if_negative:n #1 { TF } + { + \if_int_compare:w #1 < \c_zero_int + \prg_return_true: + \else: + \prg_return_false: + \fi: + } + +% <int> +% #1 didec variable +\prg_new_conditional:Npnn \didec_if_negative:n #1 { p, T, F, TF } + { + \if_int_compare:w \didec_to_int:n { #1 } < \c_zero_int + \prg_return_true: + \else: + \prg_return_false: + \fi: + } + +% <int> +% #1 didec variable +\prg_new_conditional:Npnn \didec_if_positive:n #1 { p, T, F, TF } + { + \if_int_compare:w \didec_to_int:n { #1 } > \c_zero_int + \prg_return_true: + \else: + \prg_return_false: + \fi: + } + +% <int> +% #1 didec variable +\prg_new_conditional:Npnn \didec_if_zero:n #1 { p, T, F, TF } + { + \if_int_compare:w \didec_to_int:n { #1 } = \c_zero_int + \prg_return_true: + \else: + \prg_return_false: + \fi: + } + +% <int> +% #1 didec variable +% #2 relation +% #3 didec variable +\prg_new_conditional:Npnn \didec_compare:nNn #1#2#3 { p, T, F, TF } + { + \if_int_compare:w \__didec_eval:n { #1 } #2 \__didec_eval:n { #3 } + \prg_return_true: + \else: + \prg_return_false: + \fi: + } + +% <int> +% #1 didec variable +\cs_new:Npn \didec_to_int:n #1 + { + \int_use:c { g_didec_var_#1_int } + } + +% <int> +% #1 didec variable +\cs_new_protected:Npn \didec_new:n #1 + { + \didec_if_exist:nTF { #1 } + { + \msg_error:nne { didec }{ already-defined }{ #1 } + } + { + \int_new:c { g_didec_var_#1_int } + } + } + +% <int> +% Sets didec variable #1 to the current value of didec variable #2 +\cs_new_protected:Npn \didec_gset_eq:nn #1#2 + { + \int_gset_eq:cc { g_didec_var_#1_int }{ g_didec_var_#2_int } + } + +% <int> +% set didec variable #1 to integer value #2 +\cs_new_protected:Npn \__didec_gset_int:nn #1#2 + { + \int_gset:cn { g_didec_var_#1_int }{ #2 } + } + +% <int> +% add integer #2 to didec variable #1 +\cs_new_protected:Npn \__didec_gadd_int:nn #1#2 + { + \int_gadd:cn { g_didec_var_#1_int }{ #2 } + } + +\fi: + +%------- floating point kernel (fp) ------------------- + +\if_predicate:w \didec_if_kernel_fp_p: + +\str_const:Nn \c_didec_kernel_str { fp } + +% <fp> +% test on existence of didec variable #1 +% adapted from \cs_if_exist:c +\prg_new_conditional:Npnn \didec_if_exist:n #1 { p, T, F, TF } + { + \if_cs_exist:w g_didec_var_#1_fp \cs_end: + \exp_after:wN \use_i:nn + \else: + \exp_after:wN \use_ii:nn + \fi: + { + \exp_after:wN \if_meaning:w \cs:w g_didec_var_#1_fp \cs_end: \scan_stop: + \prg_return_false: + \else: + \prg_return_true: + \fi: + } + \prg_return_false: + } + +% <fp> +% #1 large integer value +\prg_new_conditional:Npnn \__didec_if_negative:n #1 { TF } + { + \exp_last_unbraced:Ne \token_if_eq_charcode:NNTF { \tl_head:n { #1 } }{ - } + { + \prg_return_true: + } + { + \prg_return_false: + } + } + +% <fp> +% #1 didec variable +\prg_new_conditional:Npnn \didec_if_negative:n #1 { p, T, F, TF } + { + \exp_last_unbraced:Ne \token_if_eq_charcode:NNTF { \exp_args:Ne \tl_head:n { \didec_to_int:n { #1 } } }{ - } + { + \prg_return_true: + } + { + \prg_return_false: + } + } + +% <fp> +% #1 didec variable +\prg_new_conditional:Npnn \didec_if_positive:n #1 { p, T, F, TF } + { + \exp_args:Ne \__didec_if_positive_token:n { \exp_args:Ne \tl_head:n { \didec_to_int:n { #1 } } } + } + +% <fp> +% #1 didec variable +\cs_new:Npn \__didec_if_positive_token:n #1 + { + \token_if_eq_charcode:NNTF { #1 }{ - } + { + \prg_return_false: + } + { + \token_if_eq_charcode:NNTF { #1 }{ 0 } + { + \prg_return_false: + } + { + \prg_return_true: + } + } + } + +% <fp> +% #1 didec variable +\prg_new_conditional:Npnn \didec_if_zero:n #1 { p, T, F, TF } + { + \exp_last_unbraced:Ne \token_if_eq_charcode:NNTF { \exp_args:Ne \tl_head:n { \didec_to_int:n { #1 } } }{ 0 } + { + \prg_return_true: + } + { + \prg_return_false: + } + } + +% <fp> +% #1 didec variable +% #2 relation +% #3 didec variable +\prg_new_conditional:Npnn \didec_compare:nNn #1#2#3 { p, T, F, TF } + { + \fp_compare:nNnTF { \__didec_eval:n { #1 } } #2 { \__didec_eval:n { #3 } } + { + \prg_return_true: + } + { + \prg_return_false: + } + } + +% <fp> +% #1 didec variable +\cs_new:Npn \didec_to_int:n #1 + { + \fp_use:c { g_didec_var_#1_fp } + } + +% <fp> +% #1 didec variable +\cs_new_protected:Npn \didec_new:n #1 + { + \didec_if_exist:nTF { #1 } + { + \msg_error:nne { didec }{ already-defined }{ #1 } + } + { + \fp_new:c { g_didec_var_#1_fp } + } + } + +% <fp> +% Sets didec variable #1 to the current value of didec variable #2 +\cs_new_protected:Npn \didec_gset_eq:nn #1#2 + { + \fp_gset_eq:cc { g_didec_var_#1_fp }{ g_didec_var_#2_fp } + } + +% <fp> +% set didec variable #1 to integer value #2 +\cs_new_protected:Npn \__didec_gset_int:nn #1#2 + { + \fp_gset:cn { g_didec_var_#1_fp }{ #2 } + } + +% <fp> +% add integer #2 to didec variable #1 +\cs_new_protected:Npn \__didec_gadd_int:nn #1#2 + { + \fp_gadd:cn { g_didec_var_#1_fp }{ #2 } + } + + +\fi: + + +%------- didec variables ------------------- + + +\cs_new:Npn \__didec_if_exist_else_error:nT #1#2 + { + \didec_if_exist:nTF { #1 } + { + #2 + } + { + \msg_error:nne { didec }{ no-variable }{ #1 } + } + } + + +% set didec variable #1 to didec expression #2 +% #1 didec variable +% #2 didec expression +\cs_new_protected:Npn \didec_gset:nn #1#2 + { + \__didec_gset_int:nn { #1 }{ \__didec_eval:n { #2 } } + } + + +% set didec variable #1 to didec expression #2 +% #1 didec variable +% #2 didec expression +\cs_new_protected:Npn \didec_gset_negative:nn #1#2 + { + \__didec_gset_int:nn { #1 }{ - \__didec_eval:n { #2 } } + } + + +% set didec variable #1 to floating-point expression #2 +% #1 didec variable +% #2 floating-point expression +\cs_new_protected:Npn \didec_gset_fp:nn #1#2 + { + \__didec_gset_int:nn { #1 }{ \fp_to_int:n { (#2)*100 } } + } + + +% add didec expression #2 to didec variable #1 +% #1 didec variable +% #2 didec expression +\cs_new_protected:Npn \didec_gadd:nn #1#2 + { + \__didec_gadd_int:nn { #1 }{ \__didec_eval:n { #2 } } + } + + +% add sum of didec expression #2 and #3 to didec variable #1 +% #1 didec variable +% #2 didec expression +% #3 didec expression +\cs_new_protected:Npn \didec_gadd_to:nnn #1#2#3 + { + \__didec_gset_int:nn { #1 }{ \__didec_eval:n { #2 } + \__didec_eval:n { #3 } } + } + + +% subtract didec expression #2 from didec variable #1 +% #1 didec variable +% #2 didec expression +\cs_new_protected:Npn \didec_gsub:nn #1#2 + { + \__didec_gadd_int:nn { #1 }{ - \__didec_eval:n { #2 } } + } + + +% set didec variable #1 to the difference of didec expression #2 and #3 +% #1 didec variable +% #2 didec expression +% #3 didec expression +\cs_new_protected:Npn \didec_gsub_to:nnn #1#2#3 + { + \__didec_gset_int:nn { #1 }{ \__didec_eval:n { #2 } - \__didec_eval:n { #3 } } + } + + +% multiply didec variable #1 with floating-point expression #2 +% #1 didec variable +% #2 floating-point expression +\cs_new_protected:Npn \didec_gmul_fp:nn #1#2 + { + \__didec_gset_int:nn { #1 }{ \fp_to_int:n { \didec_to_int:n { #1 } * (#2) } } + } + + +% set didec variable #1 to the product of didec variable #2 with floating-point expression #3 +% #1 didec variable +% #2 didec variable +% #3 floating-point expression +\cs_new_protected:Npn \didec_gmul_fp_to:nnn #1#2#3 + { + \__didec_gset_int:nn { #1 }{ \fp_to_int:n { \didec_to_int:n { #2 } * (#3) } } + } + + +% divide didec variable #1 by floating-point expression #2 +% #1 didec variable +% #2 floating-point expression +\cs_new_protected:Npn \didec_gdiv_fp:nn #1#2 + { + \__didec_gset_int:nn { #1 }{ \fp_to_int:n { \didec_to_int:n { #1 } / (#2) } } + } + + +% set didec variable #1 to the quotient of didec variable #2 with floating-point expression #3 +% #1 didec variable +% #2 didec variable +% #3 floating-point expression +\cs_new_protected:Npn \didec_gdiv_fp_to:nnn #1#2#3 + { + \__didec_gset_int:nn { #1 }{ \fp_to_int:n { \didec_to_int:n { #2 } / (#3) } } + } + + +%------- formatting didec variables ------------------- + + +% fp value of didec variable #1 +% #1 didec variable +\cs_new:Npn \didec_to_fp:n #1 + { + \exp_args:Nf \__didec_format:nn { \didec_to_int:n {#1} }{ . } + } + + +% fp value of didec variable #1 +% #1 didec variable +\cs_new:Npn \didec_to_fc:n #1 + { + \exp_args:Nf \__didec_format:nn { \didec_to_int:n {#1} }{ , } + } + + +% #1 (large) integer value (from didec variable) +% #2 decimal separator +\cs_new:Npn \__didec_format:nn #1#2 + { + \__didec_if_negative:nTF { #1 } + { - \exp_args:No \__didec_format_pos:nn { \use_none:n #1 }{ #2 } } + { \__didec_format_pos:nn { #1 }{ #2 } } + } + +\cs_new:Npn \__didec_format_pos:nn #1#2 + { + \exp_args:Ne \__didec_format_pos_i:w { \tl_count:n {#1} }{ #2 } #1 \q_nil \q_nil \q_nil \q_nil \q_nil \q_nil \q_stop + } + +\cs_new:Npn \__didec_format_pos_i:w #1#2#3#4#5#6#7#8#9 \q_stop + { + \if_case:w #1 \exp_stop_f: + \or: 0 #2 0 #3 % 1 + \or: 0 #2 #3#4 % 2 + \or: #3 #2 #4#5 % 3 + \or: #3#4 #2 #5#6 % 4 + \or: #3#4#5 #2 #6#7 % 5 + \or: #3#4#5#6 #2 #7#8 % 6 + \or: #3#4#5#6#7 #2 #8 \__didec_format_pos_ii:w { 0 }{ #2 } #9 \q_stop % 7 + \or: #3#4#5#6#7#8 #2 \__didec_format_pos_ii:w { 1 }{ #2 } #9 \q_stop % 8 + \or: #3#4#5#6#7#8 \__didec_format_pos_ii:w { 2 }{ #2 } #9 \q_stop % 9 + \or: #3#4#5#6#7#8 \__didec_format_pos_ii:w { 3 }{ #2 } #9 \q_stop % 10 + \or: #3#4#5#6#7#8 \__didec_format_pos_ii:w { 4 }{ #2 } #9 \q_stop % 11 + \or: #3#4#5#6#7#8 \__didec_format_pos_ii:w { 5 }{ #2 } #9 \q_stop % 12 + \or: #3#4#5#6#7#8 \__didec_format_pos_ii:w { 6 }{ #2 } #9 \q_stop % 13 + \or: #3#4#5#6#7#8 \__didec_format_pos_ii:w { 7 }{ #2 } #9 \q_stop % 14 + \or: #3#4#5#6#7#8 \__didec_format_pos_ii:w { 8 }{ #2 } #9 \q_stop % 15 + \or: #3#4#5#6#7#8 \__didec_format_pos_ii:w { 9 }{ #2 } #9 \q_stop % 16 + \else 0 #2 00 % error + \fi: + } + +\cs_new:Npn \__didec_format_pos_ii:w #1#2#3#4#5#6#7#8#9 \q_stop + { + \if_case:w #1 \exp_stop_f: + #3 % 0 = 7 = 13 + \or: #3#4 % 1 = 8 = 14 + \or: #3 #2 #4#5 % 2 = 9 = 15 + \or: #3#4 #2 #5#6 % 3 = 10 = 16 + \or: #3#4#5 #2 #6#7 % 4 = 11 + \or: #3#4#5#6 #2 #7#8 % 5 = 12 + \or: #3#4#5#6#7 #2 #8 \__didec_format_pos_ii:w { 0 }{ #2 } #9 \q_stop % 6 = 13 + \or: #3#4#5#6#7#8 #2 \__didec_format_pos_ii:w { 1 }{ #2 } #9 \q_stop % 7 = 14 + \or: #3#4#5#6#7#8 \__didec_format_pos_ii:w { 2 }{ #2 } #9 \q_stop % 8 = 15 + \or: #3#4#5#6#7#8 \__didec_format_pos_ii:w { 3 }{ #2 } #9 \q_stop % 9 = 16 + \fi: + } + + +% #1 (large) integer value (from didec variable) +% #2 positive extra +% #3 negative extra +\cs_new:Npn \__didec_format_group:nnn #1#2#3 + { + \__didec_if_negative:nTF { #1 } + { + #3 + \l__didec_currency_negative_prefix_tl + \exp_args:No \__didec_format_group_pos:nnn + { \use_none:n #1 } + { \l__didec_decimal_separator_tl } + { \l__didec_grouping_separator_tl } + \l__didec_currency_negative_postfix_tl + } + { + #2 + \l__didec_currency_prefix_tl + \__didec_format_group_pos:nnn + { #1 } + { \l__didec_decimal_separator_tl } + { \l__didec_grouping_separator_tl } + \l__didec_currency_postfix_tl + } + } + +\cs_new:Npn \__didec_format_group_pos:nnn #1#2#3 + { + \exp_args:Ne \__didec_format_group_pos_i:w { \tl_count:n {#1} }{ #2 }{ #3 } #1 \q_nil \q_nil \q_nil \q_nil \q_nil \q_stop + } + +\cs_new:Npn \__didec_format_group_pos_i:w #1#2#3#4#5#6#7#8#9 \q_stop + { + \if_case:w #1 \exp_stop_f: + \or: 0 #2 0 #4 % 1 + \or: 0 #2 #4#5 % 2 + \or: #4 #2 #5#6 % 3 + \or: #4#5 #2 #6#7 % 4 + \or: #4#5#6 #2 #7#8 % 5 + \or: #4 #3 #5#6#7 #2 #8 \__didec_format_group_pos_ii:w { 0 }{ #2 }{ #3 } #9 \q_stop % 6 + \or: #4#5 #3 #6#7#8 #2 \__didec_format_group_pos_ii:w { 1 }{ #2 }{ #3 } #9 \q_stop % 7 + \or: #4#5#6 #3 #7#8 \__didec_format_group_pos_ii:w { 2 }{ #2 }{ #3 } #9 \q_stop % 8 + \or: #4 #3 #5#6#7 #3 #8 \__didec_format_group_pos_ii:w { 3 }{ #2 }{ #3 } #9 \q_stop % 9 + \or: #4#5 #3 #6#7#8 #3 \__didec_format_group_pos_ii:w { 4 }{ #2 }{ #3 } #9 \q_stop % 10 + \or: #4#5#6 #3 #7#8 \__didec_format_group_pos_ii:w { 5 }{ #2 }{ #3 } #9 \q_stop % 11 + \or: #4 #3 #5#6#7 #3 #8 \__didec_format_group_pos_ii:w { 6 }{ #2 }{ #3 } #9 \q_stop % 12 + \or: #4#5 #3 #6#7#8 #3 \__didec_format_group_pos_ii:w { 7 }{ #2 }{ #3 } #9 \q_stop % 13 + \or: #4#5#6 #3 #7#8 \__didec_format_group_pos_ii:w { 8 }{ #2 }{ #3 } #9 \q_stop % 14 + \or: #4 #3 #5#6#7 #3 #8 \__didec_format_group_pos_ii:w { 9 }{ #2 }{ #3 } #9 \q_stop % 15 + \or: #4#5 #3 #6#7#8 #3 \__didec_format_group_pos_ii:w { 10 }{ #2 }{ #3 } #9 \q_stop % 16 + \else 1 #2 00 % error + \fi: + } + +\cs_new:Npn \__didec_format_group_pos_ii:w #1#2#3#4#5#6#7#8#9 \q_stop + { + \if_case:w #1 \exp_stop_f: + #4 % 0 = 6 = 11 + \or: #4#5 % 1 = 7 = 12 + \or: #4 #2 #5#6 % 2 = 8 = 13 + \or: #4#5 #2 #6#7 % 3 = 9 = 14 + \or: #4#5#6 #2 #7#8 % 4 = 10 = 15 + \or: #4 #3 #5#6#7 #2 #8 \__didec_format_group_pos_ii:w { 0 }{ #2 }{ #3 } #9 \q_stop % 5 = 11 = 16 + \or: #4#5 #3 #6#7#8 #2 \__didec_format_group_pos_ii:w { 1 }{ #2 }{ #3 } #9 \q_stop % 6 = 12 + \or: #4#5#6 #3 #7#8 \__didec_format_group_pos_ii:w { 2 }{ #2 }{ #3 } #9 \q_stop % 7 = 13 + \or: #4 #3 #5#6#7 #3 #8 \__didec_format_group_pos_ii:w { 3 }{ #2 }{ #3 } #9 \q_stop % 8 = 14 + \or: #4#5 #3 #6#7#8 #3 \__didec_format_group_pos_ii:w { 4 }{ #2 }{ #3 } #9 \q_stop % 9 = 15 + \or: #4#5#6 #3 #7#8 \__didec_format_group_pos_ii:w { 5 }{ #2 }{ #3 } #9 \q_stop % 10 = 16 + \fi: + } + + +% #1 didec variable +% #2 stream +\cs_new_protected:Npn \didec_write:nn #1#2 + { + \iow_now:Ne #2 + { + \c_backslash_str didecset + { #1 } + { \didec_to_fp:n { #1 } } + \c_percent_str + } + } + + +% #1 didec variable +% #2 stream +\cs_new_protected:Npn \didec_write_check:nn #1#2 + { + \__didec_if_exist_else_error:nT { #1 } + { + \didec_write:nn { #1 }{ #2 } + } + } + + + +%------- number scanner ------------------- + +% Evaluates #1 and leaves the result in the input stream as an integer denotation +% #1 can be a single didec variable or a number with floating-comma or floating-point +\cs_new:Npn \__didec_eval:n #1 + { + \exp_args:Ne \__didec_eval_expanded:n { \exp_args:Ne \tl_trim_spaces:n { #1 } } + } + + +\cs_new:Npn \__didec_eval_expanded:n #1 + { + \didec_if_exist:nTF { #1 } + { + \didec_to_int:n { #1 } + } + { + \__didec_eval_p_a:w #1.\q_nil \q_stop + } + } + + +\cs_new:Npn \__didec_eval_p_a:w #1.#2#3 \q_stop + { + \quark_if_nil:NTF #2 + { + \__didec_eval_c_a:w #1,\q_nil\q_stop + } + { + #1\__didec_eval_p_b:w #2#3 + } + } + +\cs_new:Npn \__didec_eval_p_b:w #1. \q_nil + { + \__didec_eval_c:w #1 00 \q_stop + } + +\cs_new:Npn \__didec_eval_c_a:w #1,#2#3 \q_stop + { + \quark_if_nil:NTF #2 + { + #100 + } + { + #1\__didec_eval_c_b:w #2#3 + } + } + +\cs_new:Npn \__didec_eval_c_b:w #1, \q_nil + { + \__didec_eval_c:w #1 00 \q_stop + } + +\cs_new:Npn \__didec_eval_c:w #1#2#3 \q_stop + { + #1#2 + } + + +%------- didec variables (extended) ------------------- + +% #1 didec variable +\cs_new_protected:Npn \didec_show:n #1 + { + \__didec_if_exist_else_error:nT { #1 } + { + \didec_if_kernel_int:T + { + \int_show:c { g_didec_var_#1_int } + } + \didec_if_kernel_fp:T + { + \fp_show:c { g_didec_var_#1_fp } + } + } + } + +% #1 didec variable +\cs_new:Npn \didec_to_int_check:n #1 + { + \__didec_if_exist_else_error:nT { #1 } + { + \didec_to_int:n { #1 } + } + } + +% #1 didec variable +\cs_new:Npn \didec_to_fp_check:n #1 + { + \__didec_if_exist_else_error:nT { #1 } + { + \didec_to_fp:n { #1 } + } + } + +% #1 didec variable +\cs_new:Npn \didec_to_fc_check:n #1 + { + \__didec_if_exist_else_error:nT { #1 } + { + \didec_to_fc:n { #1 } + } + } + + +% set didec variable #1 to integer value #2 +\cs_new_protected:Npn \__didec_gset_int_check:nn #1#2 + { + \__didec_if_exist_else_error:nT { #1 } + { + \__didec_gset_int:nn { #1 }{ #2 } + } + } + +% Sets didec variable #1 to the current value of didec variable #2 +\cs_new_protected:Npn \didec_gset_eq_check:nn #1#2 + { + \__didec_if_exist_else_error:nT { #1 } + { + \__didec_if_exist_else_error:nT { #2 } + { + \didec_gset_eq:nn { #1 }{ #2 } + } + } + } + +% set didec variable #1 to didec expression #2 +% #1 didec variable +% #2 didec expression +\cs_new_protected:Npn \didec_gset_check:nn #1#2 + { + \__didec_if_exist_else_error:nT { #1 } + { + \didec_gset:nn { #1 }{ #2 } + } + } + +% set didec variable #1 to didec expression #2 +% #1 didec variable +% #2 didec expression +\cs_new_protected:Npn \didec_gset_negative_check:nn #1#2 + { + \__didec_if_exist_else_error:nT { #1 } + { + \didec_gset_negative:nn { #1 }{ #2 } + } + } + +% set didec variable #1 to floating-point expression #2 +% #1 didec variable +% #2 floating-point expression +\cs_new_protected:Npn \didec_gset_fp_check:nn #1#2 + { + \__didec_if_exist_else_error:nT { #1 } + { + \didec_gset_fp:nn { #1 }{ #2 } + } + } + +% add didec expression #2 to didec variable #1 +% #1 didec variable +% #2 didec expression +\cs_new_protected:Npn \didec_gadd_check:nn #1#2 + { + \__didec_if_exist_else_error:nT { #1 } + { + \didec_gadd:nn { #1 }{ #2 } + } + } + +% add sum of didec expression #2 and #3 to didec variable #1 +% #1 didec variable +% #2 didec expression +% #3 didec expression +\cs_new_protected:Npn \didec_gadd_to_check:nnn #1#2#3 + { + \__didec_if_exist_else_error:nT { #1 } + { + \didec_gadd_to:nnn { #1 }{ #2 }{ #3 } + } + } + +% subtract didec expression #2 from didec variable #1 +% #1 didec variable +% #2 didec expression +\cs_new_protected:Npn \didec_gsub_check:nn #1#2 + { + \__didec_if_exist_else_error:nT { #1 } + { + \didec_gsub:nn { #1 }{ #2 } + } + } + +% set didec variable #1 to the difference of didec expression #2 and #3 +% #1 didec variable +% #2 didec expression +% #3 didec expression +\cs_new_protected:Npn \didec_gsub_to_check:nnn #1#2#3 + { + \__didec_if_exist_else_error:nT { #1 } + { + \didec_gsub_to:nnn { #1 }{ #2 }{ #3 } + } + } + +% multiply didec variable #1 with floating-point expression #2 +% #1 didec variable +% #2 floating-point expression +\cs_new_protected:Npn \didec_gmul_fp_check:nn #1#2 + { + \__didec_if_exist_else_error:nT { #1 } + { + \didec_gmul_fp:nn { #1 }{ #2 } + } + } + +% set didec variable #1 to the product of didec variable #2 with floating-point expression #3 +% #1 didec variable +% #2 didec variable +% #3 floating-point expression +\cs_new_protected:Npn \didec_gmul_fp_to_check:nnn #1#2#3 + { + \__didec_if_exist_else_error:nT { #1 } + { + \didec_gmul_fp_to:nnn { #1 }{ #2 }{ #3 } + } + } + +% divide didec variable #1 by floating-point expression #2 +% #1 didec variable +% #2 floating-point expression +\cs_new_protected:Npn \didec_gdiv_fp_check:nn #1#2 + { + \__didec_if_exist_else_error:nT { #1 } + { + \didec_gdiv_fp:nn { #1 }{ #2 } + } + } + +% set didec variable #1 to the quotient of didec variable #2 with floating-point expression #3 +% #1 didec variable +% #2 didec variable +% #3 floating-point expression +\cs_new_protected:Npn \didec_gdiv_fp_to_check:nnn #1#2#3 + { + \__didec_if_exist_else_error:nT { #1 } + { + \didec_gdiv_fp_to:nnn { #1 }{ #2 }{ #3 } + } + } + + +%------- formatting didec variables (extended) ------------------- + +\tl_new:N \l__didec_decimal_separator_tl +\tl_new:N \l__didec_grouping_separator_tl +\tl_new:N \l__didec_currency_prefix_tl +\tl_new:N \l__didec_currency_postfix_tl +\tl_new:N \l__didec_currency_negative_prefix_tl +\tl_new:N \l__didec_currency_negative_postfix_tl + +\keys_define:nn { didec } + { + decimal-separator .tl_set:N = \l__didec_decimal_separator_tl, + grouping-separator .tl_set:N = \l__didec_grouping_separator_tl, + currency .code:n = + { + \tl_set:No \l__didec_currency_prefix_tl { \use_i:nn #1 } + \tl_set:No \l__didec_currency_postfix_tl { \use_ii:nn #1 } + \tl_set:No \l__didec_currency_negative_prefix_tl { \use_i:nn #1 - } + \tl_set:No \l__didec_currency_negative_postfix_tl { \use_ii:nn #1 } + }, + currency-negative .code:n = + { + \tl_set:No \l__didec_currency_negative_prefix_tl { \use_i:nn #1 } + \tl_set:No \l__didec_currency_negative_postfix_tl { \use_ii:nn #1 } + }, + german .meta:n = + { + decimal-separator = {,}, + grouping-separator = {.}, + currency = {}{}, + }, + english .meta:n = + { + decimal-separator = {.}, + grouping-separator = {,}, + currency = {}{}, + }, + french .meta:n = + { + decimal-separator = {,}, + grouping-separator = {\;}, + currency = {}{}, + }, + float .meta:n = + { + decimal-separator = {.}, + grouping-separator = , + currency = {}{}, + }, + color-positive .code:n = + { + \color_set:nn { didec-positive }{ #1 } + }, + color-negative .code:n = + { + \color_set:nn { didec-negative }{ #1 } + }, + } + +\color_set:nn { didec-gray }{ black!85!white } + +\color_set:nnn { didec-green }{ rgb }{ 0, 0.35, 0 } +\color_set:nnn { didec-red }{ rgb }{ 0.35, 0, 0 } +\color_set:nnn { didec-blue }{ rgb }{ 0, 0, 0.35 } + + +\keys_set:nn { didec } + { + german, + color-positive = didec-green, + color-negative = didec-red, + } + +% #1 didec variable +\cs_new:Npn \didec_use:n #1 + { + \exp_args:Nf \__didec_format_group:nnn { \didec_to_int:n {#1} }{}{} + } + +% #1 didec variable +\cs_new:Npn \didec_use_check:n #1 + { + \__didec_if_exist_else_error:nT { #1 } + { + \didec_use:n { #1 } + } + } + +% #1 didec variable +\cs_new:Npn \didec_color_use:n #1 + { + \color_group_begin: + \exp_args:Nf \__didec_format_group:nnn { \didec_to_int:n {#1} } + { \color_select:n { didec-positive } } + { \color_select:n { didec-negative } } + \color_group_end: + } + +% #1 didec variable +\cs_new:Npn \didec_color_use_check:n #1 + { + \__didec_if_exist_else_error:nT { #1 } + { + \didec_color_use:n { #1 } + } + } + +% #1 didec variable +\cs_new:Npn \didec_color_inverse_use:n #1 + { + \color_group_begin: + \exp_args:Nf \__didec_format_group:nnn { \didec_to_int:n {#1} } + { \color_select:n { didec-negative } } + { \color_select:n { didec-positive } } + \color_group_end: + } + +% #1 didec variable +\cs_new:Npn \didec_color_inverse_use_check:n #1 + { + \__didec_if_exist_else_error:nT { #1 } + { + \didec_color_inverse_use:n { #1 } + } + } + + +%------- messages ------------------- + +\msg_new:nnnn { didec }{ already-defined } + { Didec~variable~'#1'~already~defined. } + { You~tried~to~create~a~new~didec~variable~'#1',~but~it~was~already~defined~elsewhere. } + + +\msg_new:nnnn { didec }{ no-variable } + { Unknown~didec~variable~'#1'. } + { The~didec~variable~'#1'~you~used~is~unknown. } + + + +%------- didec user functions ------------------- + +% #1 didec variable +\NewExpandableDocumentCommand \didectoint { m } + { + \exp_args:Ne \didec_to_int_check:n{ \tl_trim_spaces:n { #1 } } + } + +% #1 didec variable +\NewExpandableDocumentCommand \didectofp { m } + { + \exp_args:Ne \didec_to_fp_check:n{ \tl_trim_spaces:n { #1 } } + } + +% #1 didec variable +\NewExpandableDocumentCommand \didectofc { m } + { + \exp_args:Ne \didec_to_fc_check:n{ \tl_trim_spaces:n { #1 } } + } + +% #1 didec variable +\NewDocumentCommand \didecnew { m } + { + \exp_args:Ne \didec_new:n{ \tl_trim_spaces:n { #1 } } + } +\NewCommandCopy \didecnewvar \didecnew + +% Sets didec variable #1 to the current value of didec variable #2 +\NewDocumentCommand \didecsetequal { m m } + { + \exp_args:Nee \didec_gset_eq_check:nn { \tl_trim_spaces:n { #1 } }{ \tl_trim_spaces:n { #2 } } + } + +% set didec variable #1 to didec expression #2 +% #1 didec variable +% #2 didec expression +\NewDocumentCommand \didecset { m m } + { + \exp_args:Ne \didec_gset_check:nn { \tl_trim_spaces:n { #1 } }{ #2 } + } + +% set didec variable #1 to didec expression #2 +% #1 didec variable +% #2 didec expression +\NewDocumentCommand \didecsetnegative { m m } + { + \exp_args:Ne \didec_gset_negative_check:nn { \tl_trim_spaces:n { #1 } }{ #2 } + } + +% set didec variable #1 to floating-point expression #2 +% #1 didec variable +% #2 floating-point expression +\NewDocumentCommand \didecsetfp { m m } + { + \exp_args:Ne \didec_gset_fp_check:nn { \tl_trim_spaces:n { #1 } }{ #2 } + } + + +% #1 didec variable +% #2 didec expression / variable +% #3 didec expression +\NewDocumentCommand \didecadd { o m m } + { + \IfNoValueTF {#1} + { + \exp_args:Ne \didec_gadd_check:nn { \tl_trim_spaces:n { #2 } }{ #3 } + } + { + \exp_args:Ne \didec_gadd_to_check:nnn { \tl_trim_spaces:n { #1 } }{ #2 }{ #3 } + } + } + + +% #1 didec variable +% #2 didec expression / variable +% #3 didec expression +\NewDocumentCommand \didecsub { o m m } + { + \IfNoValueTF {#1} + { + \exp_args:Ne \didec_gsub_check:nn { \tl_trim_spaces:n { #2 } }{ #3 } + } + { + \exp_args:Ne \didec_gsub_to_check:nnn { \tl_trim_spaces:n { #1 } }{ #2 }{ #3 } + } + } + +% #1 didec variable +% #2 didec variable +% #3 floating-point expression +\NewDocumentCommand \didecmulfp { o m m } + { + \IfNoValueTF {#1} + { + \exp_args:Ne \didec_gmul_fp_check:nn { \tl_trim_spaces:n { #2 } }{ #3 } + } + { + \exp_args:Nee \didec_gmul_fp_to_check:nnn { \tl_trim_spaces:n { #1 } }{ \tl_trim_spaces:n { #2 } }{ #3 } + } + } + +% #1 didec variable +% #2 didec variable +% #3 floating-point expression +\NewDocumentCommand \didecdivfp { o m m } + { + \IfNoValueTF {#1} + { + \exp_args:Ne \didec_gdiv_fp_check:nn { \tl_trim_spaces:n { #2 } }{ #3 } + } + { + \exp_args:Nee \didec_gdiv_fp_to_check:nnn { \tl_trim_spaces:n { #1 } }{ \tl_trim_spaces:n { #2 } }{ #3 } + } + } + + +% Deprecated +\NewDocumentCommand \didecmul { >{\TrimSpaces} O{#2} >{\TrimSpaces} m >{\TrimSpaces} m } + { + \__didec_gset_int_check:nn { #1 }{ \fp_to_int:n { \__didec_eval:n { #2 } / 100 * \__didec_eval:n { #3 } } } + } + + +% Deprecated +\NewDocumentCommand \didecdiv { >{\TrimSpaces} O{#2} >{\TrimSpaces} m >{\TrimSpaces} m } + { + \__didec_gset_int_check:nn { #1 }{ \fp_to_int:n { \__didec_eval:n { #2 } / \__didec_eval:n { #3 } * 100 } } + } + + +% Deprecated +\NewDocumentCommand \didecpercent { >{\TrimSpaces} O{#2} >{\TrimSpaces} m >{\TrimSpaces} m } + { + \__didec_gset_int_check:nn { #1 }{ \fp_to_int:n { \__didec_eval:n { #2 } / \__didec_eval:n { #3 } * 10000 } } + } + + +\cs_new:Npn \__didec_sum:w #1#2+#3#4 \q_stop + { + \exp_args:Nne \didec_gadd:nn { #1 }{ #2 } + \quark_if_nil:NF #3 + { + \__didec_sum:w {#1} #3#4 \q_stop + } + } + +\didec_new:n {__@temp@__} + +% #1 didec variable +% #2 sum of didec expressions +\NewDocumentCommand \didecsetsum { m m } + { + \__didec_if_exist_else_error:nT { #1 } + { + \__didec_gset_int:nn {__@temp@__}{ 0 } + \__didec_sum:w {__@temp@__} #2 + \q_nil \q_stop + \didec_gset_eq:nn { #1 }{__@temp@__} + } + } + + +% Deprecated +% #1 type (german,english,float) +% #2 didec expression +\NewDocumentCommand \didecprint { O{german} m } + { + \didecset{__@temp@__}{ #2 } + \didecuse [ #1 ]{__@temp@__} + } + + +\tl_new:N \g__didec_temp_tl + +% Deprecated +% #1 type (german,english,float) +% #2 didec expression +% #3 target macro without backslash +\NewDocumentCommand \didecstore { O{german} m >{\TrimSpaces}m } + { + \didecset{__@temp@__}{ #2 } + \group_begin: + \keys_set:nn { didec }{ #1 } + \tl_gset:Ne \g__didec_temp_tl { \didec_use:n { __@temp@__ } } + \group_end: + \cs_set_eq:cN { #3 } \g__didec_temp_tl + } + +% #1 key list +% #2 didec variable +\NewDocumentCommand \didecuse { o m } + { + \IfNoValueTF {#1} + { + \exp_args:Ne \didec_use_check:n { \tl_trim_spaces:n { #2 } } + } + { + \group_begin: + \keys_set:nn { didec }{ #1 } + \exp_args:Ne \didec_use_check:n { \tl_trim_spaces:n { #2 } } + \group_end: + } + } + +% #1 key list +% #2 didec variable +\NewDocumentCommand \dideccoluse { o m } + { + \IfNoValueTF {#1} + { + \exp_args:Ne \didec_color_use_check:n { \tl_trim_spaces:n { #2 } } + } + { + \group_begin: + \keys_set:nn { didec }{ #1 } + \exp_args:Ne \didec_color_use_check:n { \tl_trim_spaces:n { #2 } } + \group_end: + } + } + +% #1 key list +% #2 didec variable +\NewDocumentCommand \dideccolinvuse { o m } + { + \IfNoValueTF {#1} + { + \exp_args:Ne \didec_color_inverse_use_check:n { \tl_trim_spaces:n { #2 } } + } + { + \group_begin: + \keys_set:nn { didec }{ #1 } + \exp_args:Ne \didec_color_inverse_use_check:n { \tl_trim_spaces:n { #2 } } + \group_end: + } + } + +% #1 key list +% #2 didec expression +\NewDocumentCommand \didecformat { o m } + { + \didec_gset:nn { __@temp@__ }{ #2 } + \IfNoValueTF {#1} + { + \didec_use:n { __@temp@__ } + } + { + \group_begin: + \keys_set:nn { didec }{ #1 } + \didec_use:n { __@temp@__ } + \group_end: + } + } + +% #1 key list +% #2 didec expression +\NewDocumentCommand \dideccolformat { o m } + { + \didec_gset:nn { __@temp@__ }{ #2 } + \IfNoValueTF {#1} + { + \didec_color_use:n { __@temp@__ } + } + { + \group_begin: + \keys_set:nn { didec }{ #1 } + \didec_color_use:n { __@temp@__ } + \group_end: + } + } + +% #1 key list +% #2 didec expression +\NewDocumentCommand \dideccolinvformat { o m } + { + \didec_gset:nn { __@temp@__ }{ #2 } + \IfNoValueTF {#1} + { + \didec_color_inverse_use:n { __@temp@__ } + } + { + \group_begin: + \keys_set:nn { didec }{ #1 } + \didec_color_inverse_use:n { __@temp@__ } + \group_end: + } + } + +% #1 key list +\NewDocumentCommand \didecsetup { m } + { + \keys_set:nn { didec }{ #1 } + } + +% #1 didec variable +% #2 stream +\NewDocumentCommand \didecwrite { m m } + { + \exp_args:Ne \didec_write_check:nn { \tl_trim_spaces:n { #1 } }{ #2 } + } + + +%------- didec conditionals ------------------- + +% #1 didec variable +\NewDocumentCommand \didecifnegative { m } + { + \exp_args:Ne \didec_if_negative:nTF { \tl_trim_spaces:n { #1 } } + } +\NewCommandCopy \didecifnegativ \didecifnegative % Deprecated + +% #1 didec variable +\NewDocumentCommand \didecifpositive { m } + { + \exp_args:Ne \didec_if_positive:nTF { \tl_trim_spaces:n { #1 } } + } +\NewCommandCopy \didecifpositiv \didecifpositive % Deprecated + +% #1 didec variable +\NewDocumentCommand \didecifzero { m } + { + \exp_args:Ne \didec_if_zero:nTF { \tl_trim_spaces:n { #1 } } + } +\NewCommandCopy \didecifnull \didecifzero % Deprecated + +% #1 didec expression +% #2 didec expression +\NewDocumentCommand \dideciflowerthan { m m } + { + \didec_compare:nNnTF { #1 } < { #2 } + } + +% #1 didec expression +% #2 didec expression +\NewDocumentCommand \didecifequal { m m } + { + \didec_compare:nNnTF { #1 } = { #2 } + } + +% #1 didec expression +% #2 didec expression +\NewDocumentCommand \didecifgreaterthan { m m } + { + \didec_compare:nNnTF { #1 } > { #2 } + } diff --git a/Master/tlpkg/bin/tlpkg-ctan-check b/Master/tlpkg/bin/tlpkg-ctan-check index 3be26e7c2ba..597182a402f 100755 --- a/Master/tlpkg/bin/tlpkg-ctan-check +++ b/Master/tlpkg/bin/tlpkg-ctan-check @@ -265,7 +265,8 @@ my @TLP_working = qw( dejavu dejavu-otf delim delimseasy delimset delimtxt democodetools denisbdoc derivative dhua diabetes-logbook diadia diagbox diagmac2 dialogl diagnose dice dichokey - dickimaw dictsym diffcoeff digestif digiconfigs dijkstra dimnum din1505 + dickimaw dictsym didec diffcoeff digestif digiconfigs + dijkstra dimnum din1505 dinat dinbrief dingbat directory dirtree dirtytalk disser ditaa dithesis dk-bib dlfltxb dnaseq dnp doc-pictex docbytex doclicense diff --git a/Master/tlpkg/libexec/ctan2tds b/Master/tlpkg/libexec/ctan2tds index bf3a6a7662b..c22ba460184 100755 --- a/Master/tlpkg/libexec/ctan2tds +++ b/Master/tlpkg/libexec/ctan2tds @@ -2145,6 +2145,7 @@ $standardtex 'dehyph', '.', 'dehyph-exptl','de.*-x-.*\.tex|\.pat', 'dialogl', '[^c]\.sty|listout\.tex', # not dialogl-doc.sty + 'didec', 'didec\.sty', # not didec.doc.sty 'din1505', 'NULL', # no tex files, only natbib.cfg, would be system-wide 'dirtree', '\.tex|' . $standardtex, 'digestif', 'NULL', # script diff --git a/Master/tlpkg/tlpsrc/collection-latexextra.tlpsrc b/Master/tlpkg/tlpsrc/collection-latexextra.tlpsrc index 2ede6653c75..fc2cf8d45d0 100644 --- a/Master/tlpkg/tlpsrc/collection-latexextra.tlpsrc +++ b/Master/tlpkg/tlpsrc/collection-latexextra.tlpsrc @@ -366,6 +366,7 @@ depend diagbox depend diagnose depend dialogl depend dichokey +depend didec depend dimnum depend dinbrief depend directory diff --git a/Master/tlpkg/tlpsrc/didec.tlpsrc b/Master/tlpkg/tlpsrc/didec.tlpsrc new file mode 100644 index 00000000000..e69de29bb2d --- /dev/null +++ b/Master/tlpkg/tlpsrc/didec.tlpsrc |