texlive[69589] Master/texmf-dist: non-decimal-units (25jan24)

commits+karl at tug.org commits+karl at tug.org
Thu Jan 25 22:22:18 CET 2024


Revision: 69589
          https://tug.org/svn/texlive?view=revision&revision=69589
Author:   karl
Date:     2024-01-25 22:22:18 +0100 (Thu, 25 Jan 2024)
Log Message:
-----------
non-decimal-units (25jan24)

Modified Paths:
--------------
    trunk/Master/texmf-dist/doc/latex/non-decimal-units/README.md
    trunk/Master/texmf-dist/doc/latex/non-decimal-units/non-decimal-units.pdf
    trunk/Master/texmf-dist/doc/latex/non-decimal-units/non-decimal-units.preamble.sty
    trunk/Master/texmf-dist/doc/latex/non-decimal-units/non-decimal-units.tex
    trunk/Master/texmf-dist/tex/latex/non-decimal-units/non-decimal-units.danish.tex
    trunk/Master/texmf-dist/tex/latex/non-decimal-units/non-decimal-units.sty

Modified: trunk/Master/texmf-dist/doc/latex/non-decimal-units/README.md
===================================================================
--- trunk/Master/texmf-dist/doc/latex/non-decimal-units/README.md	2024-01-25 21:22:07 UTC (rev 69588)
+++ trunk/Master/texmf-dist/doc/latex/non-decimal-units/README.md	2024-01-25 21:22:18 UTC (rev 69589)
@@ -5,7 +5,7 @@
 
 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
 

Modified: trunk/Master/texmf-dist/doc/latex/non-decimal-units/non-decimal-units.pdf
===================================================================
(Binary files differ)

Modified: trunk/Master/texmf-dist/doc/latex/non-decimal-units/non-decimal-units.preamble.sty
===================================================================
--- trunk/Master/texmf-dist/doc/latex/non-decimal-units/non-decimal-units.preamble.sty	2024-01-25 21:22:07 UTC (rev 69588)
+++ trunk/Master/texmf-dist/doc/latex/non-decimal-units/non-decimal-units.preamble.sty	2024-01-25 21:22:18 UTC (rev 69589)
@@ -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 at 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}

Modified: trunk/Master/texmf-dist/doc/latex/non-decimal-units/non-decimal-units.tex
===================================================================
--- trunk/Master/texmf-dist/doc/latex/non-decimal-units/non-decimal-units.tex	2024-01-25 21:22:07 UTC (rev 69588)
+++ trunk/Master/texmf-dist/doc/latex/non-decimal-units/non-decimal-units.tex	2024-01-25 21:22:18 UTC (rev 69589)
@@ -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 @@
 
 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 @@
 \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 @@
 		{
 			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 @@
 	{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 @@
 		},
 	}
 
-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 @@
 	{=\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 @@
 	{=\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 @@
 	{}
 	{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 @@
 
 \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 @@
 
 \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,13 +258,33 @@
 }
 \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}
+
 \clearpage
 \subsection{Options for Arithmetical Operations}
 
@@ -304,7 +318,8 @@
 	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 @@
 \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 @@
 	{=\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 @@
 		},
 	}
 
-	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 @@
 \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 @@
 	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 @@
 \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 @@
 
 \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 @@
 	[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 @@
 \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 @@
 
 \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}

Modified: trunk/Master/texmf-dist/tex/latex/non-decimal-units/non-decimal-units.danish.tex
===================================================================
--- trunk/Master/texmf-dist/tex/latex/non-decimal-units/non-decimal-units.danish.tex	2024-01-25 21:22:07 UTC (rev 69588)
+++ trunk/Master/texmf-dist/tex/latex/non-decimal-units/non-decimal-units.danish.tex	2024-01-25 21:22:18 UTC (rev 69589)
@@ -7,12 +7,12 @@
 
 \nduNewBaseUnit { rigsbankdaler } {
 	symbol = { Rbdl. } ,
-	symbol = { 96~skilling } ,
+	factor = { 96~skilling } ,
 }
 
 \nduNewBaseUnit { rigsdaler specie } {
 	symbol = { Rds. } ,
-	symbol = { 192~skilling } ,
+	factor = { 192~skilling } ,
 }
 
 \nduNewBaseUnit { speciedaler } {
@@ -75,6 +75,54 @@
 	skilling
 }[\spdl]
 
+%%%% LENGTH %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+% https://danmarkshistorien.dk/vis/materiale/oversigt-over-gamle-maal/
+
+\nduNewBaseUnit { mil } {
+	symbol = { M. } ,
+	factor = { 4~fjerdingvej } ,
+}
+
+\nduNewBaseUnit { fjerdingvej } {
+	symbol = { Fjv. } ,
+	factor = { 1000~favn } ,
+}
+
+\nduNewBaseUnit { favn } {
+	symbol = { Fa. } ,
+	factor = { 3~alen } ,
+}
+
+\nduNewBaseUnit { alen } {
+	symbol = { Al. } ,
+	factor = { 2~fod } ,
+}
+
+\nduNewBaseUnit { fod } {
+	symbol = { TODO } ,
+	factor = { 4~håndsbred } ,
+}
+
+\nduNewBaseUnit { håndsbred } {
+	symbol = { TODO } ,
+	factor = { 3~tomme } ,
+}
+
+\nduNewBaseUnit { tomme } {
+	symbol = { TODO } ,
+}
+
+\nduNewUnitGroup { danish~alen } {
+	mil,
+	fjerdingvej,
+	favn,
+	alen,
+	fod,
+	håndsbred,
+	tomme
+}[\alen]
+
 %%%% AREA %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
 \nduNewBaseUnit { tønde } {
@@ -126,3 +174,14 @@
 	lispund,
 	skålpund
 }
+
+%%%% MUFI INTEGRATION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% see https://ctan.org/pkg/unicode-alphabets
+
+\ifcsname mufi\endcsname%
+\nduKeys{
+	units/mark/symbol=\mufi{markflour},
+	units/skilling/symbol=\mufi{schillgerm},
+	units/penning/symbol=\mufi{20B0},
+}
+\fi
\ No newline at end of file

Modified: trunk/Master/texmf-dist/tex/latex/non-decimal-units/non-decimal-units.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/non-decimal-units/non-decimal-units.sty	2024-01-25 21:22:07 UTC (rev 69588)
+++ trunk/Master/texmf-dist/tex/latex/non-decimal-units/non-decimal-units.sty	2024-01-25 21:22:18 UTC (rev 69589)
@@ -1,5 +1,5 @@
-\RequirePackage{expl3}
-\ProvidesExplPackage{non-decimal-units}{2023/10/10}{1.0}{Macros for displaying and manipulating historical non-decimal units}
+\RequirePackage{expl3}[2024/01/25]
+\ProvidesExplPackage{non-decimal-units}{2024/01/25}{1.0.1}{Macros for displaying and manipulating historical non-decimal units}
 
 % License: CC-BY-SA 4.0
 % Author: Mikkel Eide Eriksen <mikkel.eriksen at gmail.com>
@@ -11,37 +11,37 @@
 \keys_define:nn { non-decimal-units }
 {
 	% nil/zero
-	replace~nil~with 			.tl_set:N		= \l_ndu_replace_nil_with_tl ,
-	treat~zero~as~nil 			.bool_set:N 	= \l_ndu_treat_zero_as_nil_bool ,
+	replace~nil~with 			.tl_set:N		= \l__ndu_replace_nil_with_tl ,
+	treat~zero~as~nil 			.bool_set:N 	= \l__ndu_treat_zero_as_nil_bool ,
 	treat~zero~as~nil 			.default:n 		= true ,
 
 	% formatting
-	unit~separator 				.tl_set:N		= \l_ndu_unit_separator_tl ,
+	unit~separator 				.tl_set:N		= \l__ndu_unit_separator_tl ,
 	unit~separator				.default:n		= { \nobreakspace } ,
-	default~format				.tl_set:N		= \l_ndu_default_format_tl ,
+	default~format				.tl_set:N		= \l__ndu_default_format_tl ,
 	default~format				.default:n		= { \VALUE\nobreakspace\SYMBOL } ,
 	display						.choice: ,
 	display						.choices:nn		= 
-		{ values~only, symbols~only, formatted, numprint }
-		{ \tl_set_eq:NN \l_ndu_display_choice_tl \l_keys_choice_tl } ,
+		{ values~only, symbols~only, formatted }
+		{ \tl_set_eq:NN \l__ndu_display_choice_tl \l_keys_choice_tl } ,
 	display						.default:n		= { formatted } ,
-	unit~depth					.tl_set:N		= \l_ndu_unit_depth_tl ,
-	use~numprint	 			.bool_set:N 	= \l_ndu_use_numprint_bool ,
+	unit~depth					.tl_set:N		= \l__ndu_unit_depth_tl ,
+	use~numprint	 			.bool_set:N 	= \l__ndu_use_numprint_bool ,
 	use~numprint	 			.default:n 		= true ,
 
 	% tabular alignment
-	aligned						.bool_set:N		= \l_ndu_aligned_bool ,
+	aligned						.bool_set:N		= \l__ndu_aligned_bool ,
 	aligned						.default:n 		= true ,
 	cell~widths					.code:n			= {
-			\seq_set_from_clist:Nn \l_ndu_cell_widths_seq {#1}
+			\seq_set_from_clist:Nn \l__ndu_cell_widths_seq {#1}
 		} ,
 	cell~widths 				.default:n 		= 3em ,
 
 	% math
-	normalize 					.bool_set:N		= \l_ndu_normalize_bool ,
+	normalize 					.bool_set:N		= \l__ndu_normalize_bool ,
 	normalize 					.default:n 		= true ,
-	current~variable			.tl_set:N		= \l_ndu_current_variable_tl ,
-	current~operator			.tl_set:N		= \l_ndu_current_operator_tl ,
+	current~variable			.tl_set:N		= \l__ndu_current_variable_tl ,
+	current~operator			.tl_set:N		= \l__ndu_current_operator_tl ,
 	add~to~variable				.meta:n			= {
 			current~variable = {#1} ,
 			current~operator = {+}
@@ -70,14 +70,23 @@
 }
 
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-% Errors
+% Errors and log messages
 % 
 
 \msg_new:nnnn
+{ non-decimal-units } { base-unit-exists }
+{ A ~ base ~ unit ~ named ~ #1 ~ already ~ exists }
+{ You ~ will ~ need ~ to ~ give ~ it ~ another ~ name ~ or ~ load ~ less ~ units. }
+
+\msg_new:nnnn
+{ non-decimal-units } { unit-group-exists }
+{ A ~ unit ~ group ~ named ~ #1 ~ already ~ exists }
+{ You ~ will ~ need ~ to ~ give ~ it ~ another ~ name ~ or ~ load ~ less ~ units. }
+
+\msg_new:nnnn
 { non-decimal-units } { missing-base-unit }
 { No ~ base ~ unit ~ exists ~ named ~ #1 }
 { You ~ will ~ need ~ to ~ add ~ it ~ with ~ nduNewBaseUnit. }
-% 
 
 \msg_new:nnnn
 { non-decimal-units } { missing-unit-group }
@@ -89,35 +98,51 @@
 { No ~ conversion ~ factor ~ exists ~ between ~ #1 ~ and ~ #2 }
 { You ~ will ~ need ~ to ~ add ~ it ~ when ~ creating ~ the ~ base ~ unit ~ or ~ via ~ nduKeys. }
 
+\msg_new:nnn
+{ non-decimal-units } { calculating-factor }
+{ Calculating ~ conversion ~ factor ~ between ~ #1 ~ and ~ #2 ~ via ~ #3 }
+
+\msg_new:nnn
+{ non-decimal-units } { found-factor }
+{ Found ~ conversion ~ factor ~ between ~ #1 ~ and ~ #2: ~ #3 }
+
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 % Unit setup
 % 
 
 \NewDocumentCommand { \nduNewBaseUnit } { m m } {
-	\prop_clear_new:c { l_ndu_factors_#1_prop }
+	\tl_if_exist:cT { l__ndu_factors_#1_prop }
+	{
+		\msg_error:nnn { non-decimal-units } { base-unit-exists } { #1 }
+	}
+	\prop_clear_new:c { l__ndu_factors_#1_prop }
 	\keys_define:nn { non-decimal-units / units / #1 } {
 		factor				.code			= {
 			\regex_extract_once:nnN { (\d+)\ (\D+) } { ##1 } \l_tmpa_seq
-			\prop_put:cxx { l_ndu_factors_#1_prop } { \seq_item:Nn \l_tmpa_seq 3 } { \seq_item:Nn \l_tmpa_seq 2 }
+			\prop_put:cee { l__ndu_factors_#1_prop } { \seq_item:Nn \l_tmpa_seq 3 } { \seq_item:Nn \l_tmpa_seq 2 }
 		} ,
-		symbol				.tl_set:c		= { l_ndu_symbol_#1_tl } ,
-		format				.tl_set:c		= { l_ndu_format_#1_tl } ,
+		symbol				.tl_set:c		= { l__ndu_symbol_#1_tl } ,
+		format				.tl_set:c		= { l__ndu_format_#1_tl } ,
 	}
 	\keys_set:nn { non-decimal-units / units / #1 } { #2 }
 }
 
-\NewDocumentCommand { \nduNewUnitGroup } { m o m o }
+\NewDocumentCommand { \nduNewUnitGroup } { m O{} m o }
 {
-	\seq_set_from_clist:cn { l_ndu_group_#1_seq } {#3}
+	\tl_if_exist:cT { l__ndu_group_#1_seq }
+	{
+		\msg_error:nnn { non-decimal-units } { unit-group-exists } { #1 }
+	}
+	\seq_set_from_clist:cn { l__ndu_group_#1_seq } {#3}
 
 	% set base unit to rightmost item
-	\seq_get_right:cN { l_ndu_group_#1_seq } \l_tmpa_tl
-	\tl_set_eq:cN { l_ndu_base_unit_#1_tl } \l_tmpa_tl
+	\seq_get_right:cN { l__ndu_group_#1_seq } \l_tmpa_tl
+	\tl_set_eq:cN { l__ndu_base_unit_#1_tl } \l_tmpa_tl
 
 	% store keys for unit group
-	\tl_clear_new:c { l_ndu_options_#1_tl }
+	\tl_clear_new:c { l__ndu_options_#1_tl }
 	\IfValueT {#2} {
-		\tl_set:cn { l_ndu_options_#1_tl } {#2}
+		\tl_set:cn { l__ndu_options_#1_tl } {#2}
 	}
 
 	% optionally create macro
@@ -124,12 +149,7 @@
 	\IfValueT {#4} {
 		\NewDocumentCommand { #4 } { O{} m } {
 			\group_begin:
-				\IfValueTF {#2} {
-					\nduValue{#1}[#2,##1]{##2}
-				}
-				{
-					\nduValue{#1}[##1]{##2}
-				}
+				\nduValue{#1}[#2,##1]{##2}
 			\group_end:
 		}
 	}
@@ -145,11 +165,11 @@
 	% #1: output result (int)
 	% #2: from unit (tl)
 	% #3: to unit (tl)
-	\tl_if_exist:cF { l_ndu_factors_#2_prop }
+	\tl_if_exist:cF { l__ndu_factors_#2_prop }
 	{
 		\msg_error:nnn { non-decimal-units } { missing-base-unit } { #2 }
 	}
-	\tl_if_exist:cF { l_ndu_factors_#3_prop }
+	\tl_if_exist:cF { l__ndu_factors_#3_prop }
 	{
 		\msg_error:nnn { non-decimal-units } { missing-base-unit } { #3 }
 	}
@@ -158,20 +178,22 @@
 		\int_set:Nn #1 { 1 }
 	}
 	{
-		\prop_if_in:cnTF { l_ndu_factors_#2_prop } { #3 }
+		\prop_if_in:cnTF { l__ndu_factors_#2_prop } { #3 }
 		{
-			\prop_get:cnN  { l_ndu_factors_#2_prop } { #3 } \l_tmpa_tl
+			\prop_get:cnN  { l__ndu_factors_#2_prop } { #3 } \l_tmpa_tl
+%			\msg_term:nnnee { non-decimal-units } { found-factor } { #2 } { #3 } { \tl_use:N \l_tmpa_tl }
 			\int_set:Nn #1 { \l_tmpa_tl }
 		}{
 			\int_zero_new:N \l__ndu_factor_product_int
-			\prop_map_inline:cn { l_ndu_factors_#2_prop } {
+			\prop_map_inline:cn { l__ndu_factors_#2_prop } {
 				\str_if_eq:nnF {#3} {##1}
 				{
+%					\msg_term:nnnee { non-decimal-units } { calculating-factor } { #2 } { #3 } { ##1 }
 					\int_zero_new:N \l__ndu_sub_factor_int
 					\ndu_get_factor:Nnn \l__ndu_sub_factor_int { ##1 } { #3 }
 					\int_set:Nn \l__ndu_factor_product_int { ##2 * \l__ndu_sub_factor_int }
 					\int_set:Nn #1 { \l__ndu_factor_product_int }
-					\prop_put:cnx { l_ndu_factors_#2_prop } { #3 } { \int_use:N \l__ndu_factor_product_int }
+					\prop_put:cnV { l__ndu_factors_#2_prop } { #3 } \l__ndu_factor_product_int
 				}
 			}
 		}
@@ -200,7 +222,7 @@
 	% #2: unit group (seq)
 	% #3: base unit (tl)
 	% #4: value (int)
-	% #5: unit (tl)
+	% #5: unit depth (tl)
 	\seq_clear:N #1
 
 	\int_zero_new:N \l__ndu_remainder_int
@@ -220,11 +242,11 @@
 		% while (remainder >= factor_to_base):
 		\int_while_do:nn {\l__ndu_remainder_int >= \l__ndu_factor_int} {
 			% remainder -= factor_to_base
-			\int_sub:Nn \l__ndu_remainder_int \l__ndu_factor_int
+			\int_sub:Nn \l__ndu_remainder_int { \l__ndu_factor_int }
 			% result[i] += 1
 			\int_incr:N \l__ndu_sum_int
 		}
-		\seq_put_right:Nx #1 {\int_use:N \l__ndu_sum_int}
+		\seq_put_right:NV #1 \l__ndu_sum_int
 		
 		% stop when we hit the desired unit depth
 		\str_if_eq:NNT {##1} {#5} {
@@ -234,9 +256,11 @@
 }
 \cs_generate_variant:Nn \ndu_repr_to_seq:NNNNN {
 	NccNc,
-	Ncccc
+	Ncccc,
+	NccNN
 }
 
+% convenience function
 \cs_new_protected:Nn \ndu_repr_to_seq:NnN
 {
 	% parameters
@@ -245,10 +269,10 @@
 	% #3: value (int)
 	\ndu_repr_to_seq:NccNc
 		#1
-		{ l_ndu_group_#2_seq }
-		{ l_ndu_base_unit_#2_tl }
+		{ l__ndu_group_#2_seq }
+		{ l__ndu_base_unit_#2_tl }
 		#3
-		{ l_ndu_base_unit_#2_tl }
+		{ l__ndu_base_unit_#2_tl }
 
 }
 \cs_generate_variant:Nn \ndu_repr_to_seq:NnN {
@@ -267,7 +291,7 @@
 
 	\seq_map_indexed_inline:Nn #2
 	{
-		\tl_set:Nx \l__ndu_value_tl { \seq_item:Nn #4 {##1} }
+		\tl_set:Ne \l__ndu_value_tl { \seq_item:Nn #4 {##1} }
 		\tl_if_blank:VF \l__ndu_value_tl {
 			\ndu_get_factor:NnV \l_tmpa_int { ##2 } { #3 }
 			\int_add:Nn #1 { \l__ndu_value_tl * \l_tmpa_int }
@@ -278,6 +302,7 @@
 	NccN
 }
 
+% convenience function
 \cs_new_protected:Nn \ndu_seq_to_repr:NnN
 {
 	% parameters
@@ -286,8 +311,8 @@
 	% #3: values (seq)
 	\ndu_seq_to_repr:NccN
 		#1
-		{ l_ndu_group_#2_seq }
-		{ l_ndu_base_unit_#2_tl }
+		{ l__ndu_group_#2_seq }
+		{ l__ndu_base_unit_#2_tl }
 		#3
 }
 \cs_generate_variant:Nn \ndu_seq_to_repr:NnN {
@@ -308,33 +333,33 @@
 	\tl_if_blank:nTF {#2}
 	{
 		% only output something if we are replacing nil
-		\tl_if_empty:NTF {\l_ndu_replace_nil_with_tl}
+		\tl_if_empty:NTF {\l__ndu_replace_nil_with_tl}
 		{
 			\prg_return_false:
 		}
 		{
-			\tl_set_eq:NN #1 \l_ndu_replace_nil_with_tl
+			\tl_set_eq:NN #1 \l__ndu_replace_nil_with_tl
 			\prg_return_true:
 		}
 	}
 	{
 		\bool_if:nTF {
-			\l_ndu_treat_zero_as_nil_bool &&
+			\l__ndu_treat_zero_as_nil_bool &&
 			\int_compare_p:n { #2 = 0 }
 		} {
 			% only output something if we are replacing nil
-			\tl_if_empty:NTF {\l_ndu_replace_nil_with_tl}
+			\tl_if_empty:NTF {\l__ndu_replace_nil_with_tl}
 			{
 				\prg_return_false:
 			}
 			{
-				\tl_set_eq:NN #1 \l_ndu_replace_nil_with_tl
+				\tl_set_eq:NN #1 \l__ndu_replace_nil_with_tl
 				\prg_return_true:
 			}
 		}
 		{
 			% else output directly
-			\tl_set:Nx #1 { #2 }
+			\tl_set:Ne #1 { #2 }
 			\prg_return_true:
 		}
 	}
@@ -341,20 +366,15 @@
 }
 \prg_generate_conditional_variant:Nnn \ndu_if_not_nil_or_zero:Nn
 {
-	Nx
+	Ne
 }
 {
 	T,TF
 }
 
-% placeholder tokens for \ndu_format_display_helper
-\tl_new:N \VALUE
-\tl_new:N \SYMBOL
-
 \tl_const:Nn \c__ndu_values_only_tl { values~only }
 \tl_const:Nn \c__ndu_symbols_only_tl { symbols~only }
 \tl_const:Nn \c__ndu_formatted_tl { formatted }
-\tl_const:Nn \c__ndu_numprint_tl { numprint }
 
 \cs_new_protected:Nn \ndu__numprint_helper:nn
 {
@@ -368,13 +388,13 @@
 	% #2: format (tl)
 	% #3: symbol (tl)
 	% #4: value (int)
-	\tl_case:Nn \l_ndu_display_choice_tl {
+	\tl_case:Nn \l__ndu_display_choice_tl {
 		\c__ndu_symbols_only_tl {
 			\tl_set:Nn #1 { #3 }
 		}
 		\c__ndu_values_only_tl {
 			\tl_set:Nn #1 {
-				\bool_if:NTF \l_ndu_use_numprint_bool
+				\bool_if:NTF \l__ndu_use_numprint_bool
 					{ \ndu__numprint_helper:nn {} {#4} }
 					{ #4 }
 			}
@@ -383,19 +403,15 @@
 			\tl_set:Nn #1 { #2 }
 			\tl_replace_all:Nnn #1 { \SYMBOL } { #3 }
 			\tl_replace_all:Nnn #1 { \VALUE } {
-				\bool_if:NTF \l_ndu_use_numprint_bool
+				\bool_if:NTF \l__ndu_use_numprint_bool
 					{ \ndu__numprint_helper:nn {} {#4} }
 					{ #4 }
 			}
 		}
-		\c__ndu_numprint_tl {
-			\tl_set:Nn #1 { \ndu__numprint_helper:nn {#3} {#4} }
-		}
 	}
 }
 \cs_generate_variant:Nn \ndu_format_display_helper:Nnnn {
-	NVVn,
-	NVVx
+	NVVV
 }
 
 \cs_new_protected:Nn \ndu_format_values:NNNN
@@ -411,36 +427,40 @@
 	\seq_map_indexed_inline:Nn #3
 	{
 		\tl_clear_new:N \l__ndu_formatted_segment
+
+		% get symbol
 		\tl_clear_new:N \l__ndu_symbol_tl
-		\tl_set:Nx \l__ndu_symbol_tl { \tl_use:c { l_ndu_symbol_ \seq_item:Nn #2 {##1} _tl } }
+		\tl_set:Ne \l__ndu_symbol_tl { \tl_use:c { l__ndu_symbol_ \seq_item:Nn #2 {##1} _tl } }
 
+		% get format
 		\tl_clear_new:N \l__ndu_format_tl
-		\tl_if_empty:cTF { l_ndu_format_ \seq_item:Nn #2 {##1} _tl }
+		\tl_if_empty:cTF { l__ndu_format_ \seq_item:Nn #2 {##1} _tl }
 		{
-			\tl_set_eq:NN \l__ndu_format_tl \l_ndu_default_format_tl
+			\tl_set_eq:NN \l__ndu_format_tl \l__ndu_default_format_tl
 		}
 		{
-			\tl_set_eq:Nc \l__ndu_format_tl { l_ndu_format_ \seq_item:Nn #2 {##1} _tl }
+			\tl_set_eq:Nc \l__ndu_format_tl { l__ndu_format_ \seq_item:Nn #2 {##1} _tl }
 		}
 
+		% build formatted segment and append to putput
 		\ndu_if_not_nil_or_zero:NnT \l_tmpa_tl { ##2 }
 		{
-			\ndu_format_display_helper:NVVx
+			\ndu_format_display_helper:NVVV
 				\l__ndu_formatted_segment
 				\l__ndu_format_tl
 				\l__ndu_symbol_tl
-				{ \l_tmpa_tl }
-			\seq_put_right:Nx \l__ndu_formatted_segments_seq \l__ndu_formatted_segment
+				\l_tmpa_tl
+			\seq_put_right:NV \l__ndu_formatted_segments_seq \l__ndu_formatted_segment
 		}
 
 		% stop when we hit the desired unit depth
-		\tl_set:Nx \l__ndu_unit_tl { \seq_item:Nn #2 {##1} }
-		\tl_if_eq:NNT \l__ndu_unit_tl \l_ndu_unit_depth_tl
+		\tl_set:Ne \l__ndu_unit_tl { \seq_item:Nn #2 {##1} }
+		\tl_if_eq:NNT \l__ndu_unit_tl \l__ndu_unit_depth_tl
 		{
 			\seq_map_break:
 		}
 	}
-	\tl_set:Nn #1 { \seq_use:Nn {\l__ndu_formatted_segments_seq} {#4} }
+	\tl_set:Nn #1 { \seq_use:Nn \l__ndu_formatted_segments_seq {#4} }
 }
 \cs_generate_variant:Nn \ndu_format_values:NNNN {
 	NcNN
@@ -470,15 +490,18 @@
 	% parameter
 	% #1: output result (box)
 	% #2: contents (tl)
-	% #3: box index
+	% #3: unit index
 	\box_clear_new:N #1
+
+	% find configured width for index
 	\dim_zero_new:N \l__ndu_cell_width_dim
-	\tl_set:Nx \l_tmpa_tl { \seq_item:Nn \l_ndu_cell_widths_seq { #3 } }
+	\tl_set:Ne \l_tmpa_tl { \seq_item:Nn \l__ndu_cell_widths_seq { #3 } }
 	\ndu_if_valid_dim:VF \l_tmpa_tl
 	{
-		\seq_get_right:NN \l_ndu_cell_widths_seq \l_tmpa_tl
+		\seq_get_right:NN \l__ndu_cell_widths_seq \l_tmpa_tl
 	}
 	\dim_set:Nn \l__ndu_cell_width_dim { \l_tmpa_tl }
+
 	\hbox_set_to_wd:Nnn #1 { \l__ndu_cell_width_dim } { #2 }
 }
 \cs_generate_variant:Nn \ndu_make_box:Nnn {
@@ -497,7 +520,7 @@
 	\seq_map_indexed_inline:Nn #2
 	{
 		\tl_clear_new:N \l__ndu_value_tl
-		\ndu_if_not_nil_or_zero:NxTF \l__ndu_value_tl { \seq_item:Nn #3 ##1 }
+		\ndu_if_not_nil_or_zero:NeTF \l__ndu_value_tl { \seq_item:Nn #3 ##1 }
 		{
 			\ndu_make_box:cnn
 				{ l__ndu_cell_ \int_to_alph:n {##1} _box }
@@ -511,10 +534,10 @@
 				{ ##1 }
 		}
 
-		\tl_put_right:Nx #1 { \box_use:c { l__ndu_cell_ \int_to_alph:n {##1} _box } }
+		\tl_put_right:Ne #1 { \box_use:c { l__ndu_cell_ \int_to_alph:n {##1} _box } }
 
 		% stop when we hit the desired unit depth
-		\tl_if_eq:NnT \l_ndu_unit_depth_tl {##2}
+		\tl_if_eq:NnT \l__ndu_unit_depth_tl {##2}
 		{
 			\seq_map_break:
 		}
@@ -531,21 +554,19 @@
 
 \cs_new_protected:Nn \ndu_set_options:nn
 {
-	% set keys for unit group
-	\tl_if_eq:cnF { l_ndu_options_#1_tl } { \c_novalue_tl }
+	\tl_if_exist:cF { l__ndu_group_#1_seq }
 	{
-		\keys_set:nv { non-decimal-units } { l_ndu_options_#1_tl } 
+		\msg_error:nnn { non-decimal-units } { missing-unit-group } { #1 }
 	}
 
+	% set keys for unit group
+	\keys_set:nv { non-decimal-units } { l__ndu_options_#1_tl } 
+
 	% set keys provided by command
-	\IfValueT {#2} { \keys_set:nn { non-decimal-units } { #2 } }
+	\keys_set:nn { non-decimal-units } { #2 }
 }
 
-\NewDocumentCommand \nduValue { m o m } {
-	\tl_if_exist:cF { l_ndu_group_#1_seq }
-	{
-		\msg_error:nnn { non-decimal-units } { missing-unit-group } { #1 }
-	}
+\NewDocumentCommand \nduValue { m O{} m } {
 	\group_begin:
 		\ndu_set_options:nn {#1} {#2}
 
@@ -554,7 +575,7 @@
 		\seq_set_split:Nnn \l_tmpa_seq { . } {#3}
 
 		% should we normalize the input?
-		\bool_if:nT \l_ndu_normalize_bool
+		\bool_if:nT \l__ndu_normalize_bool
 		{
 			\ndu_seq_to_repr:NnN
 				\l__ndu_normalized_int
@@ -567,25 +588,25 @@
 		}
 
 		% are we outputting aligned cells?
-		\bool_if:NTF \l_ndu_aligned_bool
+		\bool_if:NTF \l__ndu_aligned_bool
 		{
 			\ndu_format_values_aligned:NcN
 				\l__ndu_result_tl
-				{ l_ndu_group_#1_seq }
+				{ l__ndu_group_#1_seq }
 				\l_tmpa_seq
 		}
 		{
 			\ndu_format_values:NcNN
 				\l__ndu_result_tl
-				{ l_ndu_group_#1_seq }
+				{ l__ndu_group_#1_seq }
 				\l_tmpa_seq
-				\l_ndu_unit_separator_tl
+				\l__ndu_unit_separator_tl
 		}
 
 		% should we do any math?
-		\tl_if_empty:NF \l_ndu_current_variable_tl
+		\tl_if_empty:NF \l__ndu_current_variable_tl
 		{
-			\nduMath{#1}[#2]{\l_ndu_current_variable_tl}{\l_ndu_current_operator_tl}{#3}
+			\nduMath{#1}[#2]{\l__ndu_current_variable_tl}{\l__ndu_current_operator_tl}{#3}
 		}
 
 		% output
@@ -593,19 +614,60 @@
 	\group_end:
 }
 
+\NewDocumentCommand \nduNormalize { m O{} m m } {
+	\group_begin:
+		\ndu_set_options:nn {#1} {#2}
+
+		\tl_clear_new:N \l__ndu_result_tl
+
+		\int_zero_new:N \l__ndu_amount_int
+		\int_set:Nn \l__ndu_amount_int {#3}
+		\tl_clear_new:N \l__ndu_unit_tl
+		\tl_set:Nn \l__ndu_unit_tl {#4}
+
+		\ndu_repr_to_seq:NccNN
+			\l_tmpa_seq
+			{ l__ndu_group_#1_seq }
+			{ l__ndu_base_unit_#1_tl }
+			\l__ndu_amount_int
+			\l__ndu_unit_tl
+
+		% are we outputting aligned cells?
+		\bool_if:NTF \l__ndu_aligned_bool
+		{
+			\ndu_format_values_aligned:NcN
+				\l__ndu_result_tl
+				{ l__ndu_group_#1_seq }
+				\l_tmpa_seq
+		}
+		{
+			\ndu_format_values:NcNN
+				\l__ndu_result_tl
+				{ l__ndu_group_#1_seq }
+				\l_tmpa_seq
+				\l__ndu_unit_separator_tl
+		}
+
+		% should we do any math?
+		\tl_if_empty:NF \l__ndu_current_variable_tl
+		{
+			\nduMath{#1}[#2]{\l__ndu_current_variable_tl}{\l__ndu_current_operator_tl}{#3}
+		}
+
+		% output
+		\tl_use:N \l__ndu_result_tl
+	\group_end:
+}
+
 \tl_const:Nn \c__ndu_plus_tl { + }
 \tl_const:Nn \c__ndu_minus_tl { - }
 
-\NewDocumentCommand \nduMath { m o m m m } {
-	\tl_if_exist:cF { l_ndu_group_#1_seq }
-	{
-		\msg_error:nnn { non-decimal-units } { missing-unit-group } { #1 }
-	}
+\NewDocumentCommand \nduMath { m O{} m m m } {
 	\group_begin:
 		\ndu_set_options:nn {#1} {#2}
 
-		\int_if_exist:cF { g_ndu_variable_#3_int } {
-			\int_zero_new:c { g_ndu_variable_#3_int }
+		\int_if_exist:cF { g__ndu_variable_#3_int } {
+			\int_zero_new:c { g__ndu_variable_#3_int }
 		}
 
 		\int_zero_new:N \l__ndu_operand_int
@@ -631,8 +693,8 @@
 			\int_set:Nn \l__ndu_operand_int { #5 }
 		}
 
-		\int_gset:cn { g_ndu_variable_#3_int } {
-			\int_use:c { g_ndu_variable_#3_int }
+		\int_gset:cn { g__ndu_variable_#3_int } {
+			\int_use:c { g__ndu_variable_#3_int }
 			#4
 			\l__ndu_operand_int
 		}
@@ -639,16 +701,12 @@
 	\group_end:
 }
 
-\NewDocumentCommand \nduResult { m o m } {
-	\tl_if_exist:cF { l_ndu_group_#1_seq }
-	{
-		\msg_error:nnn { non-decimal-units } { missing-unit-group } { #1 }
-	}
+\NewDocumentCommand \nduResult { m O{} m } {
 	\group_begin:
 		\ndu_set_options:nn {#1} {#2}
 
-		\int_if_exist:cF { g_ndu_variable_#3_int } {
-			\int_zero_new:c { g_ndu_variable_#3_int }
+		\int_if_exist:cF { g__ndu_variable_#3_int } {
+			\int_zero_new:c { g__ndu_variable_#3_int }
 		}
 
 		\tl_clear_new:N \l__ndu_result_tl
@@ -656,22 +714,22 @@
 		\ndu_repr_to_seq:Nnc
 			\l_tmpa_seq
 			{ #1 }
-			{ g_ndu_variable_#3_int }
+			{ g__ndu_variable_#3_int }
 
 		% are we outputting aligned cells?
-		\bool_if:NTF \l_ndu_aligned_bool
+		\bool_if:NTF \l__ndu_aligned_bool
 		{
 			\ndu_format_values_aligned:NcN
 				\l__ndu_result_tl
-				{ l_ndu_group_#1_seq }
+				{ l__ndu_group_#1_seq }
 				\l_tmpa_seq
 		}
 		{
 			\ndu_format_values:NcNN
 				\l__ndu_result_tl
-				{ l_ndu_group_#1_seq }
+				{ l__ndu_group_#1_seq }
 				\l_tmpa_seq
-				\l_ndu_unit_separator_tl
+				\l__ndu_unit_separator_tl
 		}
 
 		% output
@@ -679,27 +737,23 @@
 	\group_end:
 }
 
-\NewDocumentCommand \nduHeader { m o } {
-	\tl_if_exist:cF { l_ndu_group_#1_seq }
-	{
-		\msg_error:nnn { non-decimal-units } { missing-unit-group } { #1 }
-	}
+\NewDocumentCommand \nduHeader { m O{} } {
 	\group_begin:
 		\ndu_set_options:nn {#1} {#2}
 		\tl_set:Nn \l__ndu_result_tl { \leavevmode }
 
 		% build boxes
-		\seq_set_eq:Nc \l_tmpa_seq { l_ndu_group_#1_seq }
+		\seq_set_eq:Nc \l_tmpa_seq { l__ndu_group_#1_seq }
 		\seq_map_indexed_inline:Nn \l_tmpa_seq
 		{
 			\ndu_make_box:cnn
 				{ l__ndu_cell_ \int_to_alph:n {##1} _box }
-				{ \hfill \tl_use:c { l_ndu_symbol_ ##2 _tl } }
+				{ \hfill \tl_use:c { l__ndu_symbol_ ##2 _tl } }
 				{ ##1 }
 			\tl_put_right:Nn \l__ndu_result_tl { \box_use:c { l__ndu_cell_ \int_to_alph:n {##1} _box } }
 
 			% stop when we hit the desired unit depth
-			\tl_if_eq:NnT \l_ndu_unit_depth_tl {##2}
+			\tl_if_eq:NnT \l__ndu_unit_depth_tl {##2}
 			{
 				\seq_map_break:
 			}
@@ -711,7 +765,7 @@
 }
 
 \NewDocumentCommand \nduSymbol { m } {
-	\tl_use:c { l_ndu_symbol_#1_tl }
+	\tl_use:c { l__ndu_symbol_#1_tl }
 }
 
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -718,10 +772,6 @@
 % Column type for tabularray
 % 
 
-% TODO: using the font key is pretty hacky...
-% need to ask if theres a better option
-% https://github.com/lvjr/tabularray/issues
-
 \keys_define:nn { non-decimal-units }
 {
 	tabularray~column~type		.code			= {
@@ -750,7 +800,7 @@
 		\c__ndu_RESULT_tl {
 			\nduResult
 			{ #1 }
-			{ \l_ndu_current_variable_tl }
+			{ \l__ndu_current_variable_tl }
 		}
 		\c__ndu_SKIP_tl {
 			% nothing
@@ -763,7 +813,7 @@
 		% elenganter solution?
 		\cs_if_exist:cTF { \ndu__tblr_cell_get_csname: }
 			% or use a specific bool, e.g., \ndu__do_math_bool
-			{ \tl_clear:N \l_ndu_current_variable_tl }
+			{ \tl_clear:N \l__ndu_current_variable_tl }
 			{ \cs_gset:cpn { \ndu__tblr_cell_get_csname: } {} }
 		\nduValue
 			{ #1 }
@@ -790,9 +840,4 @@
 	german	 					.code:n 		= { \input{non-decimal-units.german} } ,
 }
 
-\IfFormatAtLeastTF { 2022-06-01 } {
-    \ProcessKeyOptions [ non-decimal-units / options ]
-}{
-    \RequirePackage { l3keys2e }
-    \ProcessKeysOptions { non-decimal-units / options }
-}
\ No newline at end of file
+\ProcessKeyOptions [ non-decimal-units / options ]



More information about the tex-live-commits mailing list.