diff options
author | Karl Berry <karl@freefriends.org> | 2024-01-25 21:22:18 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2024-01-25 21:22:18 +0000 |
commit | 487c93c1527571a5df64b2f12eda05457da672d9 (patch) | |
tree | ab1532244d765202c05cfb257f6e35db53519eca /Master/texmf-dist/doc | |
parent | 97424294d1f622e17bbdd586cd2b6dcc0083c6c6 (diff) |
non-decimal-units (25jan24)
git-svn-id: svn://tug.org/texlive/trunk@69589 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/doc')
-rw-r--r-- | Master/texmf-dist/doc/latex/non-decimal-units/README.md | 2 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/non-decimal-units/non-decimal-units.pdf | bin | 155980 -> 173818 bytes | |||
-rw-r--r-- | Master/texmf-dist/doc/latex/non-decimal-units/non-decimal-units.preamble.sty | 32 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/non-decimal-units/non-decimal-units.tex | 150 |
4 files changed, 100 insertions, 84 deletions
diff --git a/Master/texmf-dist/doc/latex/non-decimal-units/README.md b/Master/texmf-dist/doc/latex/non-decimal-units/README.md index e5e9eb728c9..83aec91ce27 100644 --- a/Master/texmf-dist/doc/latex/non-decimal-units/README.md +++ b/Master/texmf-dist/doc/latex/non-decimal-units/README.md @@ -5,7 +5,7 @@ Macros for displaying and manipulating historical non-decimal units. See [non-decimal-units.pdf](docs/non-decimal-units.pdf) for the documentation. -Contents last updated 2023-10-10. +Contents last updated 2024-01-25. Package available via CTAN at https://www.ctan.org/pkg/non-decimal-units diff --git a/Master/texmf-dist/doc/latex/non-decimal-units/non-decimal-units.pdf b/Master/texmf-dist/doc/latex/non-decimal-units/non-decimal-units.pdf Binary files differindex 19b21b0375b..b13257e0b4c 100644 --- a/Master/texmf-dist/doc/latex/non-decimal-units/non-decimal-units.pdf +++ b/Master/texmf-dist/doc/latex/non-decimal-units/non-decimal-units.pdf diff --git a/Master/texmf-dist/doc/latex/non-decimal-units/non-decimal-units.preamble.sty b/Master/texmf-dist/doc/latex/non-decimal-units/non-decimal-units.preamble.sty index 977d02cbf5c..2a9649d45b9 100644 --- a/Master/texmf-dist/doc/latex/non-decimal-units/non-decimal-units.preamble.sty +++ b/Master/texmf-dist/doc/latex/non-decimal-units/non-decimal-units.preamble.sty @@ -1,16 +1,15 @@ -\usepackage{makeidx} +\usepackage{imakeidx} \makeindex \usepackage{needspace} -\usepackage{csquotes} \usepackage[english]{babel} -\usepackage[ - backend=biber, - urldate=long, - date=long, -]{biblatex} -\addbibresource{non-decimal-units.bib} +%\usepackage[ +% backend=biber, +% urldate=long, +% date=long, +%]{biblatex} +%\addbibresource{non-decimal-units.bib} \usepackage{enumitem} \usepackage[ @@ -54,6 +53,8 @@ after doc body={\end{tcolorbox}}, } +\newcommand\nduDocBrack[1]{\brackets{\texttt{#1}}} + \AtBeginEnvironment{tcb@manual@entry}{% \needspace{4\baselineskip}% } @@ -76,6 +77,8 @@ noitemsep, } +\usepackage{csquotes} + \usepackage{fnpct} \usepackage{tabularray} @@ -85,10 +88,6 @@ \RequirePackage[autolanguage]{numprint} -\usepackage[ - danish, -]{non-decimal-units} - \RequirePackage{fontspec} \newfontfamily\mufifont{Palemonas MUFI} @@ -99,8 +98,7 @@ }, ]{unicode-alphabets} -\nduKeys{% - units/mark/symbol=\mufi{markflour}, - units/skilling/symbol=\mufi{schillgerm}, - units/penning/symbol=\mufi{20B0}, -}
\ No newline at end of file +\usepackage[ + british, + danish, +]{non-decimal-units} diff --git a/Master/texmf-dist/doc/latex/non-decimal-units/non-decimal-units.tex b/Master/texmf-dist/doc/latex/non-decimal-units/non-decimal-units.tex index 866efed85a2..66733af1d76 100644 --- a/Master/texmf-dist/doc/latex/non-decimal-units/non-decimal-units.tex +++ b/Master/texmf-dist/doc/latex/non-decimal-units/non-decimal-units.tex @@ -1,7 +1,6 @@ % !TEX TS-program = LuaLaTeX-shell-escape \documentclass[ a4paper, - margin=4cm ]{article} \usepackage{non-decimal-units.preamble} @@ -22,7 +21,7 @@ \section{Preface} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -Many historical unit systems were non-decimal. For example, the Danish rigsdaler\footnote{\url{https://en.wikipedia.org/wiki/Danish_rigsdaler}} --- where 1 rigsdaler consists of 16~mark, each again consisting of 16~skilling for a total of 96 skilling per rigsdaler --- was used from 1625 to 1875, when currency was decimalised to the current system of 1 krone = 100 øre. +Many historical unit systems were non-decimal. For example, the Danish rigsdaler currency\footnote{\url{https://en.wikipedia.org/wiki/Danish_rigsdaler}} --- where 1 rigsdaler consists of 16~mark, each again consisting of 16~skilling for a total of 96 skilling per rigsdaler --- was used from 1625 to 1875, when currency was decimalised to the current system of 1 krone = 100 øre. % https://en.wikipedia.org/wiki/Non-decimal_currency @@ -32,9 +31,9 @@ The non-decimal numbers were chosen due to their larger number of division facto This package enables creation and configuration of such units to facilitate their presentation in textual and tabular contexts, as well as simple arithmetic. -In order to do this, values are divided into \emph{segments}, which are separated by decimal points: for example, the historical Danish monetary value \nduValue{danish rigsdaler}{1.2.3} is entered as \texttt{1.2.3}, which the code then formats appropriately. +In order to do this, a \emph{unit group} consists of a number of \emph{base unit}s: for example, I can use \cs{nduValue}\nduDocBrack{danish rigsdaler}\nduDocBrack{1.2.3} to typeset the result \nduValue{danish rigsdaler}{1.2.3}, or \cs{nduValue}\nduDocBrack{british pound sterling lsd}\nduDocBrack{1.2.3} to typeset \nduValue{british pound sterling lsd}{1.2.3}. -Issues can be reported at \url{https://github.com/mikkelee/latex-units/issues}. +Issues can be reported at\\\null\hfill\url{https://github.com/mikkelee/latex-units/issues} \clearpage \section{Configuration} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -53,7 +52,7 @@ Where \meta{options} may contain one or more of the following unit systems. See \item[german] Currencies \end{description} -Alternately, one may configure new units via \refCom{nduNewBaseUnit} and \refCom{nduNewUnitGroup}. +Alternately, one may configure new units via \refCom{nduNewBaseUnit} and \refCom{nduNewUnitGroup}. Suggestions for additions are welcome! \end{docCommand} @@ -106,14 +105,11 @@ If no special configuration is made, the number of decimal points and the values { doc parameter = {=symbols only}, }, - { - doc parameter = {=numprint}, - }, } Changes which information is included in the expansion. - Because only present values will be included, \docAuxKey*{display}=\docValue*{symbols only} can be used to list the segment units (though it may be preferable to use \refCom{nduHeader} or \refCom{nduSymbol}). + Because only present values will be included, \docAuxKey*{display}=\docValue*{symbols only} can be used to list the unit symbols (though it may be preferable to use \refCom{nduHeader} or \refCom{nduSymbol}). \begin{dispExample} \nduValue{danish hartkorn} @@ -125,13 +121,6 @@ If no special configuration is made, the number of decimal points and the values {0.0...} \end{dispExample} - Finally, it is possible to use the \href{https://ctan.org/pkg/numprint}{numprint} package to format numbers, especially useful for larger values. Note that this may be counter to the formatting of some units (eg. British pounds), in which case one may prefer the \docAuxKey{use numprint} key instead. - -\begin{dispExample} -\nduValue{danish rigsdaler} - [display=numprint] - {1000} -\end{dispExample} \end{docKeys} \begin{docKey} @@ -158,7 +147,7 @@ If no special configuration is made, the number of decimal points and the values }, } -The key \docAuxKey*{replace nil with} replaces nil (empty) segments with a custom string. +The key \docAuxKey*{replace nil with} replaces nil (empty) unit values with a custom string. The key \docAuxKey*{treat zero as nil} replaces 0 with nothing, which in turn means that setting both will replace both zero and nil with the custom string. @@ -169,11 +158,11 @@ The key \docAuxKey*{treat zero as nil} replaces 0 with nothing, which in turn me {=\meta{unit name}} {initially no restriction} - When calculating or displaying a value, only the segments up to and including \meta{unit name} will be considered. + When calculating or displaying a value, only the units up to and including \meta{unit name} will be considered. - In this document, the depth has been globally set to \texttt{skilling}, but older historical sub-units can be included by locally setting the depth to eg. \texttt{hvid} (or indeed not restricting it globally). + In this document, the depth has been globally set to \texttt{skilling}, but older historical sub-units can be included by locally setting the depth to eg. \texttt{hvid} or \texttt{penning} (or indeed not restricting it globally). - If the \meta{unit name} is not present in the current unit group, it has no effect. + If the \meta{unit name} is not present in the selected unit group, it has no effect. \begin{dispExample} \nduValue{danish rigsdaler} @@ -191,7 +180,7 @@ The key \docAuxKey*{treat zero as nil} replaces 0 with nothing, which in turn me {=\meta{...}} {initially \docAuxCommand*{nobreakspace}} - When displaying a value, this string will be inserted between each segment. + When displaying a value, this string will be inserted between each sub-unit. \begin{dispExample} \nduValue{danish hartkorn}[ @@ -212,14 +201,19 @@ The key \docAuxKey*{treat zero as nil} replaces 0 with nothing, which in turn me {} {not set initially} - When displaying a value, use the \href{https://ctan.org/pkg/numprint}{numprint} package, including when using the \docAuxKey{format} key. You can of course also configure the numprint settings, either in a group or locally. + When typesetting numeric values, use the \href{https://ctan.org/pkg/numprint}{numprint} package. You can of course also configure the numprint settings, either in a group or locally. \begin{dispExample} \begingroup -\selectlanguage{ngerman} -\nduValue{danish rigsdaler} - [use numprint] - {1000.0} + \nduKeys{use numprint} + + \selectlanguage{ngerman} + Danish/German: + \nduValue{danish rigsdaler}{1000} + + \selectlanguage{english} + British/English: + \nduValue{british pound sterling lsd}{1000} \endgroup \end{dispExample} @@ -234,7 +228,7 @@ Results can be gathered in two ways, either manually via the \docAuxCommand*{ndu \begin{docCommand} {nduMath} - {\marg{unit name}\oarg{options}\marg{variable}\marg{operator}\marg{value}} + {\marg{unit group}\oarg{options}\marg{variable}\marg{operator}\marg{value}} The first arguments of \docAuxCommand*{nduMath} are identical to those of the \refCom{nduValue} macro. In addition, it has \meta{variable} and \meta{operator} (one of \texttt{+ - * /}) arguments. The command does not expand to any output. @@ -255,7 +249,7 @@ Results can be gathered in two ways, either manually via the \docAuxCommand*{ndu \begin{docCommand} {nduResult} - {\marg{unit name}\oarg{options}\marg{variable}} + {\marg{unit group}\oarg{options}\marg{variable}} The \docAuxCommand*{nduResult} macro takes a stored \meta{variable} and formats it via \meta{options} for display in the same way as \refCom{nduValue}. @@ -264,9 +258,29 @@ Results can be gathered in two ways, either manually via the \docAuxCommand*{ndu } \nduResult{danish rigsdaler}{example 1} % = 1.2.3 -And let's add an additional 15 skilling: -\nduMath{danish rigsdaler}{example 1}{+}{0.0.15} -\nduResult{danish rigsdaler}{example 1} % = 1.3.2 +And let's multiply by two: +\nduMath{danish rigsdaler}{example 1}{*}{3} +\nduResult{danish rigsdaler}{example 1} % = 4.0.9 +\end{dispExample*} + +\end{docCommand} + +\begin{docCommand} + {nduNormalize} + {\marg{unit group}\oarg{options}\marg{amount}\marg{unit}} + + The \docAuxCommand*{nduNormalize} reformats an \meta{amount} of \meta{unit}s according to the given \meta{options}, in the same way as \refCom{nduValue}. + +\begin{dispExample*}{ + title=Example usage: \docAuxCommand*{nduNormalize} macro +} +\nduNormalize{danish rigsdaler}{123}{skilling} % = 1.1.11 + +\nduNormalize{danish rigsdaler} + [unit depth=penning]{123}{penning} % = 0.0.10.0.3 + +\nduNormalize{danish rigsdaler} + [treat zero as nil]{100}{skilling} % = 1..4 \end{dispExample*} \end{docCommand} @@ -304,7 +318,8 @@ Setting either of these keys will cause all uses of \docAuxCommand*{nduValue} in a & \nduValue{danish rigsdaler}{1.2.3} \\ b & \nduValue{danish rigsdaler}{100.1.} \\ \midrule - total & \nduResult{danish rigsdaler}{example 2} \\ % = 101.3.3 + total & \nduResult{danish rigsdaler}{example 2} \\ + % = 101.3.3 \bottomrule \end{tabular} \endgroup @@ -329,14 +344,14 @@ Reformats an amount, which is useful for quick conversions. \clearpage \section{Tabular Data} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -There are a couple of ways to display values in tabular context, centered around explicitly or implicitly setting the \docAuxKey{aligned} key, which causes \docAuxCommand{nduValue} to wrap each segment in a cell of configurable width. +There are a couple of ways to display values in tabular context, centered around explicitly or implicitly setting the \docAuxKey{aligned} key, which causes \docAuxCommand{nduValue} to wrap each sub-unit in a cell of configurable width. -Additionally, all segments will be included in headers and cells, whether they contain a value or not (provided \docAuxKey{unit depth} allows it). If no value is provided for the segment, and no nil replacement is specified with the \refKey{replace nil with} key, the cell will be empty. +Additionally, all units will be included in headers and cells, whether they contain a value or not (provided \docAuxKey{unit depth} allows it). If no value is provided for the sub-unit, and no nil replacement is specified with the \refKey{replace nil with} key, the cell will be empty. \begin{docCommand} {nduHeader} - {\marg{unit name}\oarg{options}} - Convenient header showing the unit symbols. See \cpageref{units:new} for configuration of symbols. + {\marg{unit group}\oarg{options}} + Convenient header showing the unit symbols. See \cref{sec:units:new} for configuration of symbols. \end{docCommand} \subsection{Options for Tabular Data} @@ -354,7 +369,7 @@ Causes each value to be wrapped in right-aligned cells of configurable width. {=\meta{length}} {initially \texttt{3em}} -Changes the width of each cell. One may supply a bracketed comma-separated list of widths. If the list is shorter than the number of base units in the group, the last width will be repeated. See page \pageref{example:table:widths} for example. +Changes the width of each cell. One may supply a bracketed comma-separated list of widths. If the list is shorter than the number of base units in the group, the last width will be repeated. See page \cpageref{example:table:widths} for example. \end{docKey} \begin{docKeys} @@ -372,14 +387,14 @@ Changes the width of each cell. One may supply a bracketed comma-separated list }, } - The \docAuxKey{set aligned for environment} key can be set to an environment name, causing \docAuxKey*{aligned} to automatically be set for those enviroments, using \docAuxCommand*{AtBeginEnvironment}. It can be set multiple times, once for each required environment. See page \pageref{example:table:environment} for example. + The \docAuxKey{set aligned for environment} key can be set to an environment name, causing \docAuxKey*{aligned} to automatically be set for those enviroments, using \docAuxCommand*{AtBeginEnvironment}. It can be set multiple times, once for each required environment. See page \cpageref{example:table:environment} for example. - The \docAuxKey{tabularray column type} key can be used to create a column type, which automatically wraps the column contents in \docAuxCommand{nduValue}. The column type takes two arguments, a unit group and a set of key values for further configuration. Additionally, the special values \texttt{HEADER}, \texttt{RESULT}, and \texttt{SKIP} will respectively use \docAuxCommand{nduHeader}, \docAuxCommand{nduResult}, and skip the cell. See page \pageref{example:table:tabularray} for example\footnote{Thanks to Yukai Chou for help with \href{https://github.com/lvjr/tabularray}{tabularray} integration.}. + The \docAuxKey{tabularray column type} key can be used to create a column type, which automatically wraps the column contents in \docAuxCommand{nduValue}. The column type takes two arguments, a unit group and a set of key values for further configuration. Additionally, the special values \texttt{HEADER}, \texttt{RESULT}, and \texttt{SKIP} will respectively use \docAuxCommand{nduHeader}, \docAuxCommand{nduResult}, and skip the cell. See page \cpageref{example:table:tabularray} for example\footnote{Thanks to Yukai Chou for help with \href{https://github.com/lvjr/tabularray}{tabularray} integration.}. \end{docKeys} \begin{dispExample*}{ - title=Example of tabular data using \docAuxKey{set aligned for environment}, + title=Example usage: \docAuxKey{set aligned for environment} key, label=example:table:environment } \begingroup @@ -422,10 +437,9 @@ Changes the width of each cell. One may supply a bracketed comma-separated list \end{dispExample*} \begin{dispExample*}{ - title=Example of tabular data using \docAuxKey{tabularray column type}, + title=Example usage: \docAuxKey{tabularray column type} key, label=example:table:tabularray } -\begingroup % has been set in this document's preamble: % tabularray column type=U \begin{tblr}{ @@ -434,16 +448,18 @@ Changes the width of each cell. One may supply a bracketed comma-separated list U{danish rigsdaler}{add to variable=table result 2} } \toprule - & HEADER & HEADER\\ + & HEADER & HEADER \\ \midrule a & 1.2.3 & ..15 \\ b & 100.0.0 & ..10 \\ c & .1. & ..2 \\ \midrule - total & RESULT & RESULT \\ + total & RESULT & SKIP \\ \bottomrule \end{tblr} -\endgroup + +Result from \texttt{table result 2}: +\nduResult{danish rigsdaler}{table result 2} \end{dispExample*} \clearpage @@ -472,8 +488,8 @@ That is, 1 \nduSymbol{rigsdaler} consists of \clearpage \section{Creating New Units} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -\label{units:new} -If the included units are not suitable, more can be created. Pull requests are also welcome at \url{https://github.com/mikkelee/latex-units}. +\label{sec:units:new} +If the included units are not sufficient, more can be created. Pull requests are also welcome at \url{https://github.com/mikkelee/latex-units}. \begin{docCommand} {nduNewBaseUnit} @@ -485,11 +501,11 @@ Creates a new base unit. It must contain at least a \docAuxKey{symbol}, but a \d \begin{docCommand} {nduNewUnitGroup} - {\marg{unit name}\oarg{key/value pairs}\marg{ordered base units}\oarg{control sequence}} + {\marg{group name}\oarg{key/value pairs}\marg{ordered base units}\oarg{control sequence}} - In order for the math functions to work, every base unit in the group must have a conversion path to the right-most base unit, eg. if a unit group consists of base units \texttt{A, B, C}, there must be defined factors for \texttt{B\rightarrow C} and either \texttt{A\rightarrow C} or \texttt{A\rightarrow B}; if only the latter is configured, an attempt to calculate and cache it will be made internally. + In order for the math functions to work, every base unit in the group must have a conversion path to the right-most base unit, eg. if a unit group consists of base units \texttt{A, B, C}, there must be defined factors for \texttt{A\rightarrow B} and either \texttt{A\rightarrow C} or \texttt{B\rightarrow C}; if only the \texttt{A\rightarrow B} and \texttt{B\rightarrow C} factors are configured, an attempt to calculate and cache \texttt{A\rightarrow C} will be made internally. - It is possible to create shortcut macros for commonly used unit groups with optional overriding options. These macros take the same arguments as the full \refCom{nduValue} macro, except without the first argument (ie. the name of the unit). + It is possible to create shortcut macros for commonly used unit groups with optional overriding options. These macros take the same arguments as the full \refCom{nduValue} macro, except without the first argument (ie. no need for the \meta{unit group}). Including several sub units may make the math results awkward, as the algorithm is greedy. @@ -498,7 +514,7 @@ Creates a new base unit. It must contain at least a \docAuxKey{symbol}, but a \d [units/sletdaler/symbol={Sletd.}] {sletdaler, ort, skilling} [\mySldl] -\mySldl{1.2.3} +\mySldl[unit separator={~/~}]{1.2.3} \end{dispExample} \end{docCommand} @@ -506,14 +522,20 @@ Creates a new base unit. It must contain at least a \docAuxKey{symbol}, but a \d \clearpage \subsection{Options For Base Units} +When creating new units via \refCom{nduNewBaseUnit}, only the last part of the below keys is used (eg. \refKey*{units:factor} is simply \docAuxKey*{factor}). + \begin{docKey} [] - [doc label=units:symbol] - {units/\meta{unit name}/symbol} - {=\meta{symbol}} + [doc label=units:factor] + {units/\meta{unit name}/factor} + {=\meta{integer} \meta{unit name}} {} - - Configures a symbol displaying the unit. This is used in \docAuxCommand{nduValue}, \docAuxCommand{nduHeader}, and is also available via \docAuxCommand*{SYMBOL} when defining the \refKey{units:format} (see also \refKey{}). + + The conversion factor of a unit is how many of an underlying unit the given unit consists of. This can be specified multiple times. + + This is used by the math macros and keys to calculate the sums and products, but is not necessary for display. + + Can be accessed via \refCom{nduFactor}. \end{docKey} \begin{docKey} @@ -528,19 +550,15 @@ Creates a new base unit. It must contain at least a \docAuxKey{symbol}, but a \d \begin{docKey} [] - [doc label=units:factor] - {units/\meta{unit name}/factor} - {=\meta{integer} \meta{unit name}} + [doc label=units:symbol] + {units/\meta{unit name}/symbol} + {=\meta{symbol}} {} - - The conversion factor of a unit is how many of an underlying unit the given unit consists of. This can be specified multiple times. - - This is used by the math macros and keys to calculate the sums and products. - - Can be accessed via \refCom{nduFactor}. + + Configures a symbol displaying the unit. This is used in \docAuxCommand{nduValue}, \docAuxCommand{nduHeader}, and is also available via \docAuxCommand*{SYMBOL} when defining the \refKey{units:format} (see also \refKey{display}). \end{docKey} -These keys can of course also be set temporarily in \refCom{nduValue} +These keys can of course be set temporarily in \refCom{nduValue}, as seen below. \begin{dispExample} \nduValue{danish rigsdaler} |