JezK
Edit File: currency.sty
%% %% This is file `currency.sty', %% generated with the docstrip utility. %% %% The original source files were: %% %% currency.dtx (with options: `package') %% %% This is a generated file. %% %% Copyright (C) 2018 by Scott Lejay %% %% This file 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. %% \NeedsTeXFormat{LaTeX2e}[2005/12/01] \ProvidesPackage{currency} [2018/10/22 v0.4 .dtx currency file] \RequirePackage{siunitx} \RequirePackage{pgfkeys} \RequirePackage{etoolbox} \RequirePackage{xparse} \RequirePackage{expl3} \RequirePackage{textcomp} \RequirePackage{eurosym} \newif\ifcurrencynumber \pgfkeys{/currency/.cd,number/.is if=currencynumber,number=true} \newif\ifprintbefore \pgfkeys{/currency/pre/.is if=printbefore} \pgfkeys{/currency/name/.initial=ZZZ} \pgfkeys{/currency/symbol/.initial=\textcurrency} \pgfkeys{/currency/currency/.style={}} \newcommand{\CurrencySetup}[1]{% \pgfkeys{/currency/currency/.style={#1}}% } \newcommand{\CurrencySetupAppend}[1]{% \pgfkeys{/currency/currency/.append style={#1}}% } \pgfkeys{/currency/name/.store in=\currencyName} \pgfkeys{/currency/plural/.store in=\currencyNames} \pgfkeys{/currency/plural/.initial=\currencyName s} \pgfkeys{/currency/iso/.store in=\currencyISO} \pgfkeys{/currency/symbol/.store in=\currencySymbol} \pgfkeys{/currency/pre-between/.initial={~}} \pgfkeys{/currency/post-between/.initial={~}} \pgfkeys{/currency/before/.initial={}} \pgfkeys{/currency/before+/.code={\pgfkeys{/currency/before/.append={#1}}}} \pgfkeys{/currency/before</.code={\pgfkeys{/currency/before/.prefix={#1}}}} \pgfkeys{/currency/after/.initial={}} % tokens that are inserted after \pgfkeys{/currency/after+/.code={\pgfkeys{/currency/after/.append={#1}}}} \pgfkeys{/currency/after</.code={\pgfkeys{/currency/after/.prefix={#1}}}} \pgfkeys{/currency/font/.initial={}} % for setting up the fonts \pgfkeys{/currency/font+/.code={\pgfkeys{/currency/font/.append={#1}}}} \pgfkeys{/currency/prefix/.initial={}} \pgfkeys{/currency/kind/.is choice} \pgfkeys{/currency/kind/iso/.code=% {\def\currencyunit{\currencyISO}}} \pgfkeys{/currency/kind/plural/.code=% {\def\currencyunit{\currencyNames}\printbeforefalse}} \pgfkeys{/currency/kind/name/.code=% {\def\currencyunit{\currencyName}\printbeforefalse}} \pgfkeys{/currency/kind/symbol/.code=% {\def\currencyunit{\currencySymbol}}} \pgfkeys{/currency/kind=iso} \pgfkeys{/currency/cents/.is choice} \pgfkeys{/currency/cents/true/.code=% {\sisetup{zero-decimal-to-integer=true}}} \pgfkeys{/currency/cents/false/.code=% {\sisetup{zero-decimal-to-integer=true,round-precision=0}}} \pgfkeys{/currency/cents/always/.code=% {\sisetup{zero-decimal-to-integer=false,round-integer-to-decimal=true}}} \pgfkeys{/currency/cents=true} \ExplSyntaxOn \pgfkeys{/currency/.unknown/.code={% \edef\Unknown{\pgfkeyscurrentname=\pgfkeyscurrentvalue}% \keys_set:nV {siunitx} {\Unknown}% }}% \ExplSyntaxOff \ExplSyntaxOn \pgfkeys{/currency/base/.code={% \edef\SetPrecision{round-precision=\pgfkeyscurrentvalue}% \keys_set:nV {siunitx} {\SetPrecision}% }}% \ExplSyntaxOff \ExplSyntaxOn \DeclareDocumentCommand{\displayCurrency}{m o m}{ \begingroup% \sisetup{round-mode=places,round-precision=2} \IfNoValueTF{#2}% {\pgfkeys{/currency/.cd,#1,currency}}% {\pgfkeys{/currency/.cd,#1,currency,#2}}% \ifbool{currencynumber}% {\sisetup{parse-numbers=true}}% {\sisetup{parse-numbers=false}}% \edef\value{#3}% store the value of the currency \ifprintbefore% \pgfkeys{/currency/font}% \pgfkeys{/currency/before}% \text{\pgfkeys{/currency/prefix}\currencyunit}% \pgfkeys{/currency/pre-between}% \num{\value}\pgfkeys{/currency/after}% \else% print the unit after \pgfkeys{/currency/font}% \pgfkeys{/currency/before}% \num{\value}% \pgfkeys{/currency/post-between}% \text{\pgfkeys{/currency/prefix}\currencyunit}% \pgfkeys{/currency/after}% \fi% \endgroup% } \DeclareDocumentCommand{\displayCurrencySymbol}{m o}{ \begingroup% \IfNoValueTF{#2}% {\pgfkeys{/currency/.cd,#1,currency}}% {\pgfkeys{/currency/.cd,#1,currency,#2}}% \pgfkeys{/currency/font}% \pgfkeys{/currency/before}% \text{\pgfkeys{/currency/prefix}\currencyunit}% \pgfkeys{/currency/after}% \endgroup% } \ExplSyntaxOff \newcommand{\DefineCurrency}[2]{% \pgfkeys{/currency/#1/.style={#2}}%% \csgdef{d#1}{\displayCurrency{#1}} \csgdef{c#1}{\displayCurrencySymbol{#1}} }% \pgfkeys{/currency/@iso/.style={kind=iso}} \pgfkeys{/currency/@symb/.style={kind=symbol}} \pgfkeys{/currency/@sy/.style={kind=symbol}} \pgfkeys{/currency/@name/.style={kind=name}} \pgfkeys{/currency/@na/.style={kind=name}} \pgfkeys{/currency/@plural/.style={kind=plural}} \pgfkeys{/currency/@pl/.style={kind=plural}} \pgfkeys{/currency/no-parse/.style={number=false}} \endinput %% %% End of file `currency.sty'.