From e0c6872cf40896c7be36b11dcc744620f10adf1d Mon Sep 17 00:00:00 2001 From: Norbert Preining Date: Mon, 2 Sep 2019 13:46:59 +0900 Subject: Initial commit --- macros/latex/contrib/currency/README.md | 56 ++++ macros/latex/contrib/currency/currency.dtx | 363 ++++++++++++++++++++ macros/latex/contrib/currency/currency.ins | 55 ++++ macros/latex/contrib/currency/currency.pdf | Bin 0 -> 175744 bytes macros/latex/contrib/currency/currency_doc.pdf | Bin 0 -> 529253 bytes macros/latex/contrib/currency/currency_doc.tex | 439 +++++++++++++++++++++++++ 6 files changed, 913 insertions(+) create mode 100644 macros/latex/contrib/currency/README.md create mode 100644 macros/latex/contrib/currency/currency.dtx create mode 100644 macros/latex/contrib/currency/currency.ins create mode 100644 macros/latex/contrib/currency/currency.pdf create mode 100644 macros/latex/contrib/currency/currency_doc.pdf create mode 100644 macros/latex/contrib/currency/currency_doc.tex (limited to 'macros/latex/contrib/currency') diff --git a/macros/latex/contrib/currency/README.md b/macros/latex/contrib/currency/README.md new file mode 100644 index 0000000000..f95dbead14 --- /dev/null +++ b/macros/latex/contrib/currency/README.md @@ -0,0 +1,56 @@ +# currency — Formatting currencies + + +## Overview + +`currency` is a LaTeX package that facilitates the formatting +of currencies (amounts and units). It is based on the `siunitx` package +for printing numbers. + +For instance, this code in the preamble defines a EUR monetary unit + +``` latex +\DefineCurrency{EUR}{name={euro},plural={euros},symbol={\euro},iso={EUR},kind=iso,base=2} +``` + +that will be used later by + +``` latex +\dEUR{123} or \dEUR[kind=plural]{123} +``` +to print `123 EUR or 123 euros`. There are many ways to change to output +(the symbol could be put in front of the amount as required by some +typographical conventions, ...). + + +See the [documentation](https://github.com/antoinelejay/currency/blob/master/currency_doc.pdf) +for examples and installation instructions. + +## License + +This work may be distributed and/or modified under the conditions of the +[LaTeX Project Public License](http://www.latex-project.org/lppl.txt) (LPPL), +version 1.3 or later. + +Please use the project's GitHub site at +for suggestions, feature requests, and bug reports. + +## Installation + +``` +pdflatex currency.ins +pdflatex currency.dtx +makeindex -s gind.ist currency.idx +makeindex -s gglo.ist -o currency.gls currency.glo +pdflatex currency.dtx + +pdflatex currency_doc.tex +biber currency_doc +pdflatex currency_doc.tex +``` + +## Availability + +This package is available on [github](https://github.com/antoinelejay/currency) and on +[CTAN](http://www.ctan.org/tex-archive/macros/latex/contrib/currency) + diff --git a/macros/latex/contrib/currency/currency.dtx b/macros/latex/contrib/currency/currency.dtx new file mode 100644 index 0000000000..4824ba50db --- /dev/null +++ b/macros/latex/contrib/currency/currency.dtx @@ -0,0 +1,363 @@ +% \iffalse meta-comment +% +% Copyright (C) 2018 by Antoine 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. +% +% \fi +% +% \iffalse +%<*driver> +\ProvidesFile{currency.dtx} +% +%\NeedsTeXFormat{LaTeX2e}[2005/12/01] +%\ProvidesPackage{currency} +%<*package> + [2018/10/22 v0.4 .dtx currency file] +% +% +%<*driver> +\documentclass{ltxdoc} +\usepackage{currency} +\usepackage{url} +\EnableCrossrefs +\CodelineIndex +\RecordChanges +\begin{document} + \DocInput{currency.dtx} + \PrintChanges + \PrintIndex +\end{document} +% +% \fi +% +% \CheckSum{0} +% +% \CharacterTable +% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z +% Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z +% Digits \0\1\2\3\4\5\6\7\8\9 +% Exclamation \! Double quote \" Hash (number) \# +% Dollar \$ Percent \% Ampersand \& +% Acute accent \' Left paren \( Right paren \) +% Asterisk \* Plus \+ Comma \, +% Minus \- Point \. Solidus \/ +% Colon \: Semicolon \; Less than \< +% Equals \= Greater than \> Question mark \? +% Commercial at \@ Left bracket \[ Backslash \\ +% Right bracket \] Circumflex \^ Underscore \_ +% Grave accent \` Left brace \{ Vertical bar \| +% Right brace \} Tilde \~} +% +% +% \changes{v0.1}{2016/05/25}{Initial version} +% \changes{v0.2}{2016/06/15}{Adding vXXX as an alias for dXXX} +% \changes{v0.3}{2017/07/04}{Dropping spurious space in the definition of cXXX} +% \changes{v0.4}{2018/10/22}{Change DeclareDocumentCommand for compability with TexLive 2018} +% +% +% \GetFileInfo{currency.dtx} +% +% \DoNotIndex{\newcommand,\newenvironment} +% +% +% \title{The \textsf{currency} package\thanks{This document +% corresponds to \textsf{currency}~\fileversion, dated \filedate.}} +% \author{Antoine Lejay \\ \texttt{Antoine.Lejay@univ-lorraine.fr}} +% +% \maketitle +% +% +% \DefineCurrency{EUR}{name={euro},plural-name={euros},symbol={\euro},iso={EUR},kind=iso} +% \DefineCurrency{USD}{name={dollar},plural-name={dollars},symbol={\$},iso={USD},kind=iso} +% +% \section{Introduction} +% +% This package creates macros for defined currencies which follow +% the ISO 4217 codes, with various formatting options for both +% the currency (code, symbols, names, ...) and the numbers (using \texttt{siunitx}). +% +% The currency code ISO 4217 specifies the code of the currency as +% a three-letters code. The first two ones are the code of the country +% according to ISO 3166. The last one is the name of the currency name. +% +% \section{Licence} +% +% 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 +% \url{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 `maintained'. +% +% The Current Maintainer of this work is Antoine Lejay. +% +% \section{Documentation and sources} +% +% This package is documented in \texttt{currency\_doc}. +% +% A source of this package is hosted in +% \begin{center} +% \url{https://github.com/antoinelejay/currency} +% \end{center} +% +% +% +% \section{Implementation} +% +% \subsection{Dependencies} +% +% \begin{macrocode} +\RequirePackage{siunitx} +\RequirePackage{pgfkeys} +\RequirePackage{etoolbox} +\RequirePackage{xparse} +\RequirePackage{expl3} +\RequirePackage{textcomp} +\RequirePackage{eurosym} +% \end{macrocode} +% The unit could be printed before or after +% \begin{macrocode} +\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} +% \end{macrocode} +% +% Defines a style currency, which is general and empty. +% The styles are then called in order +% - the currency style +% - currency (initially empty) +% - the options passed to the command + +% \begin{macrocode} +\pgfkeys{/currency/currency/.style={}} +% \end{macrocode} +% +% \begin{macrocode} +\newcommand{\CurrencySetup}[1]{% + \pgfkeys{/currency/currency/.style={#1}}% +} +\newcommand{\CurrencySetupAppend}[1]{% + \pgfkeys{/currency/currency/.append style={#1}}% +} +% \end{macrocode} +% +% \subsection{Names and symbols definitions} +% +% The commands \verb|\currencyName|, \verb|\currencyNames|, \verb|\currencyISO| and \verb|\currencySymbol| +% are used internally every time a currency is called to define the name, the plural, +% the ISO code and the symbol associated to a currency. +% +% \begin{macrocode} +\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} +% \end{macrocode} +% +% \subsection{Keys for formatting} +% +% Several keys are devoted to insert tokens before or after th unit +% and the amount, set up the font, ... +% +% \begin{macrocode} +% between the symbol and the num if before +\pgfkeys{/currency/pre-between/.initial={~}} +% between the symbol and the num if after +\pgfkeys{/currency/post-between/.initial={~}} +% tokens that are inserted before +\pgfkeys{/currency/before/.initial={}} +% append to before +\pgfkeys{/currency/before+/.code={\pgfkeys{/currency/before/.append={#1}}}} +% prepend to before +\pgfkeys{/currency/before