summaryrefslogtreecommitdiff
path: root/macros/latex
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2024-01-26 03:00:51 +0000
committerNorbert Preining <norbert@preining.info>2024-01-26 03:00:51 +0000
commit2eae12e56ca15396e8ff63b3a9b0d450d675dc5e (patch)
tree7e6e61de2a219478694da749de27e15fe7c69ac8 /macros/latex
parent768d5db2700eb846ed6616dc4839993f193b22cd (diff)
CTAN sync 202401260300
Diffstat (limited to 'macros/latex')
-rw-r--r--macros/latex/contrib/nicematrix/nicematrix-code.dtx119
-rw-r--r--macros/latex/contrib/nicematrix/nicematrix-code.pdfbin973857 -> 968305 bytes
-rw-r--r--macros/latex/contrib/nicematrix/nicematrix-french.pdfbin596978 -> 597386 bytes
-rw-r--r--macros/latex/contrib/nicematrix/nicematrix-french.tex13
-rw-r--r--macros/latex/contrib/nicematrix/nicematrix.pdfbin611795 -> 612085 bytes
-rw-r--r--macros/latex/contrib/nicematrix/nicematrix.tex10
-rw-r--r--macros/latex/contrib/non-decimal-units/README.md2
-rw-r--r--macros/latex/contrib/non-decimal-units/docs/non-decimal-units.pdfbin155980 -> 173818 bytes
-rw-r--r--macros/latex/contrib/non-decimal-units/docs/non-decimal-units.preamble.sty32
-rw-r--r--macros/latex/contrib/non-decimal-units/docs/non-decimal-units.tex150
-rw-r--r--macros/latex/contrib/non-decimal-units/latex/non-decimal-units.danish.tex63
-rw-r--r--macros/latex/contrib/non-decimal-units/latex/non-decimal-units.sty331
-rw-r--r--macros/latex/contrib/siunitx/CHANGELOG.md14
-rw-r--r--macros/latex/contrib/siunitx/siunitx-code.pdfbin647774 -> 647826 bytes
-rw-r--r--macros/latex/contrib/siunitx/siunitx-number.dtx32
-rw-r--r--macros/latex/contrib/siunitx/siunitx-print.dtx7
-rw-r--r--macros/latex/contrib/siunitx/siunitx.dtx4
-rw-r--r--macros/latex/contrib/siunitx/siunitx.pdfbin705523 -> 705443 bytes
-rw-r--r--macros/latex/contrib/siunitx/siunitx.tex12
-rw-r--r--macros/latex/contrib/unicode-math-input/unicode-math-input.pdfbin107101 -> 107152 bytes
-rw-r--r--macros/latex/contrib/unicode-math-input/unicode-math-input.sty42
-rw-r--r--macros/latex/contrib/unicode-math-input/unicode-math-input.tex4
22 files changed, 436 insertions, 399 deletions
diff --git a/macros/latex/contrib/nicematrix/nicematrix-code.dtx b/macros/latex/contrib/nicematrix/nicematrix-code.dtx
index dea9c0ecd7..73cf741334 100644
--- a/macros/latex/contrib/nicematrix/nicematrix-code.dtx
+++ b/macros/latex/contrib/nicematrix/nicematrix-code.dtx
@@ -17,8 +17,8 @@
%
% \fi
% \iffalse
-\def\myfileversion{6.26c}
-\def\myfiledate{2024/01/02}
+\def\myfileversion{6.26d}
+\def\myfiledate{2024/01/25}
%
%
%<*batchfile>
@@ -739,104 +739,6 @@ version 2005/12/01 or later.
}
% \end{macrocode}
%
-% \bigskip
-% Since we will do ourself the expansion of the preamble of the array, we will
-% modify |\@mkpream| of \pkg{array} in order to skip the operation of expansion
-% done by |\@mkpream|.
-% \begin{macrocode}
-\cs_set_eq:NN \@@_old_mkpream: \@mkpream
-\cs_set_protected:Npn \@@_mkpream: #1
- {
-% \end{macrocode}
-% The command |\@@_mkpream_colortbl:| will be empty when \pkg{colortbl} is not loaded.
-% \begin{macrocode}
- \@@_mkpream_colortbl:
- \gdef\@preamble{} \@lastchclass 4 \@firstamptrue
- \let\@sharp\relax
- \def\@startpbox##1{\unexpanded\expandafter{\expandafter
- \@startpbox\expandafter{##1}}}\let\@endpbox\relax
- \let\do@row@strut\relax
- \let\ar@align@mcell\relax
- \@temptokena{#1} % \@tempswatrue
- % \@whilesw\if@tempswa\fi{\@tempswafalse\the\NC@list}%
- \count@\m@ne
- \let\the@toks\relax
- \prepnext@tok
-% \end{macrocode}
-% We have slightly modified the code of the original version of |\@mkpream| in
-% order to have something compatible with |\ExplSyntaxOn|.
-% \begin{macrocode}
- \exp_args:NV \tl_map_variable:NNn \@temptokena \@nextchar
- {\@testpach
- \ifcase \@chclass \@classz \or \@classi \or \@classii
- \or \save@decl \or \or \@classv \or \@classvi
- \or \@classvii \or \@classviii
- \or \@classx
- \or \@classx \fi
- \@lastchclass\@chclass}%
- \ifcase\@lastchclass
- \@acol \or
- \or
- \@acol \or
- \@preamerr \thr@@ \or
- \@preamerr \tw@ \@addtopreamble\@sharp \or
- \or
- \else \@preamerr \@ne \fi
- \def\the@toks{\the\toks}
-% \end{macrocode}
-% After an utilisation of the modified version of |\@mkpream|, we come back to
-% the original version because there may be occurrences of the classical
-% |{array}| in the cells of our array (of \pkg{nicematrix}).
-% \begin{macrocode}
- \cs_gset_eq:NN \@mkpream \@@_old_mkpream:
- }
-% \end{macrocode}
-% The classes of REVTeX do their own redefinition of |\array| and that's why the
-% previous mechanism is not compatible with REVTeX. However, it would probably
-% be possible to do something similar for REVTeX...
-% \begin{macrocode}
-\hook_gput_code:nnn { begindocument } { . }
- {
- \bool_if:NTF \c_@@_revtex_bool
- { \cs_set_eq:NN \@@_redefine_mkpream: \prg_do_nothing: }
- {
- \IfPackageLoadedTF { arydshln }
- { \cs_set_eq:NN \@@_redefine_mkpream: \prg_do_nothing: }
- {
- \cs_new_protected:Npn \@@_redefine_mkpream:
- { \cs_set_eq:NN \@mkpream \@@_mkpream: }
- }
- }
- }
-% \end{macrocode}
-%
-% \bigskip
-% \begin{macrocode}
-\cs_new_protected:Npn \@@_mkpream_colortbl: { }
-\hook_gput_code:nnn { begindocument } { . }
- {
- \IfPackageLoadedTF { colortbl }
- {
- \cs_set_protected:Npn \@@_mkpream_colortbl:
- {
-% \end{macrocode}
-% The following lines are a patch added to |\@mkpream| by \pkg{colortbl} (by
-% storing the version of |\@mkpream| provided by \pkg{array} in
-% |\@mkpreamarray|). Since you do a redefinition of |\@mkpream|, you have to add
-% the following lines in our redefinition when \pkg{colortbl} is loaded.
-% \begin{macrocode}
- \cs_set_eq:NN \CT@setup \relax
- \cs_set_eq:NN \CT@color \relax
- \cs_set_eq:NN \CT@do@color \relax
- \cs_set_eq:NN \color \relax
- \cs_set_eq:NN \CT@column@color \relax
- \cs_set_eq:NN \CT@row@color \relax
- \cs_set_eq:NN \CT@cell@color \relax
- }
- }
- { }
- }
-% \end{macrocode}
%
% \bigskip
% \section{Parameters}
@@ -1825,7 +1727,7 @@ version 2005/12/01 or later.
% couple of the form : \texttt{\{\textsl{label}\}\{\textsl{text of the
% tabularnote}\}}. The first component is the optional argument (between square
% brackets) of the command |\tabularnote| (if the optional argument is not used,
-% the value will be the special marker |\c_novalue_tl|).
+% the value will be the special marker expressed by |\c_novalue_tl|).
% \item During the composition of the caption (value of |\l_@@_caption_tl|), the
% tabular notes will be numbered from $1$ to |\g_@@_notes_caption_int| and the
% notes themselves will be stored in |\g_@@_notes_in_caption_seq|. The structure
@@ -1981,7 +1883,8 @@ version 2005/12/01 or later.
% \bigskip
% For the version in normal conditions, that is to say not in the |caption|.
% |#1| is the optional argument of |\tabularnote| (maybe equal to the special
-% marker |\c_novalue_tl|) and |#2| is the mandatory argument of |\tabularnote|.
+% marker expressed by |\c_novalue_tl|) and |#2| is the mandatory argument of
+% |\tabularnote|.
% \begin{macrocode}
\cs_new_protected:Npn \@@_tabularnote:nn #1 #2
{
@@ -2002,7 +1905,7 @@ version 2005/12/01 or later.
% \texttt{\{\textsl{label}\}\{\textsl{text of the tabularnote}\}}.
% \end{center}
% If the user have used |\tabularnote| without the optional argument, the
-% \texttt{\textsl{label}} will be the special marker |\c_novalue_tl|.
+% \texttt{\textsl{label}} will be the special marker expressed by |\c_novalue_tl|.
%
% When we will go through the sequence |\g_@@_notes_seq|, we will count in
% |\l_tmpb_int| the notes without explicit label in order to have the
@@ -3537,13 +3440,7 @@ version 2005/12/01 or later.
% \begin{macrocode}
\cs_new_protected:Npn \@@_array:
{
-% \end{macrocode}
-% The following line is only a speed-up: it's a redefinition of |\@mkpream|
-% of \pkg{array} in order to speed up the compilation by deleting one line of
-% code in |\@mkpream| (the expansion of the preamble). In the classes of REVTeX,
-% that command |\@@_redefine_mkpream:| will be nullified (no speed-up).
% \begin{macrocode}
- \@@_redefine_mkpream:
\dim_set:Nn \col@sep
{ \bool_if:NTF \l_@@_tabular_bool \tabcolsep \arraycolsep }
\dim_compare:nNnTF \l_@@_tabular_width_dim = \c_zero_dim
@@ -5270,7 +5167,6 @@ version 2005/12/01 or later.
% the corresponding key in the optional argument of the specifier).
% \begin{macrocode}
\str_set_eq:NN \l_@@_hpos_col_str \c_@@_j_str
- % \tl_set:Nn \l_tmpa_tl { #1 }
\@@_keys_p_column:n { #1 }
\@@_make_preamble_ii_iv:nnn { #2 } { minipage } { }
}
@@ -15118,11 +15014,10 @@ version 2005/12/01 or later.
\pgf@y
+ ( \box_ht:N \strutbox + \extrarowheight ) * \arraystretch
}
- } % modified 6.13c
+ }
\@@_qpoint:n { row - \l_@@_last_i_tl - base }
\dim_set:Nn \l_@@_y_final_dim
{ \fp_to_dim:n { \pgf@y - ( \box_dp:N \strutbox ) * \arraystretch } }
- % modified 6.13c
\int_step_inline:nnn \l_@@_first_col_int \g_@@_col_total_int
{
\cs_if_exist:cT
diff --git a/macros/latex/contrib/nicematrix/nicematrix-code.pdf b/macros/latex/contrib/nicematrix/nicematrix-code.pdf
index f05f5fc311..b31eaa65ba 100644
--- a/macros/latex/contrib/nicematrix/nicematrix-code.pdf
+++ b/macros/latex/contrib/nicematrix/nicematrix-code.pdf
Binary files differ
diff --git a/macros/latex/contrib/nicematrix/nicematrix-french.pdf b/macros/latex/contrib/nicematrix/nicematrix-french.pdf
index 5245e44dce..4797714502 100644
--- a/macros/latex/contrib/nicematrix/nicematrix-french.pdf
+++ b/macros/latex/contrib/nicematrix/nicematrix-french.pdf
Binary files differ
diff --git a/macros/latex/contrib/nicematrix/nicematrix-french.tex b/macros/latex/contrib/nicematrix/nicematrix-french.tex
index 3ba956b397..149fc5dd33 100644
--- a/macros/latex/contrib/nicematrix/nicematrix-french.tex
+++ b/macros/latex/contrib/nicematrix/nicematrix-french.tex
@@ -833,7 +833,7 @@ préambule (ce n'est pas le cas avec |\multicolumn|).
\begin{center}
\fvset{commandchars=\~\#\+}
\begin{BVerbatim}
-\begin{NiceTabular}{@{}c!{\qquad}ccc~emphase#!{\qquad}+ccc~@{}}
+\begin{NiceTabular}{@{}c!{\qquad}ccc~emphase#!{\qquad}+ccc@{}}
\toprule
Rang & ~emphase#\Block{1-3}{Premier groupe}+ & & & \Block{1-3}{Deuxième groupe} \\
& 1A & 1B & 1C & 2A & 2B & 2C \\
@@ -873,7 +873,7 @@ Voici le même exemple avec la clé |C| pour le premier bloc.
\begin{center}
\fvset{commandchars=\~\#\+}
\begin{BVerbatim}
-\begin{NiceTabular}{@{}c!{\qquad}ccc~emphase#!{\qquad}+ccc~@{}}
+\begin{NiceTabular}{@{}c!{\qquad}ccc~emphase#!{\qquad}+ccc@{}}
\toprule
Rang & ~emphase#\Block[C]{1-3}{Premier groupe}+ & & & \Block{1-3}{Deuxième groupe} \\
& 1A & 1B & 1C & 2A & 2B & 2C \\
@@ -2066,7 +2066,9 @@ commande |\columncolor| de \pkg{colortbl}. Sa syntaxe est similaire à celle de
son nom à la commande |\rowcolors| de \pkg{colortbl}. Le \emph{s} rappelle qu'il
y a deux couleurs. Elle colorie alternativement les rangées avec les deux
couleurs à partir de la rangée dont le numéro est donné en premier argument
-(obligatoire), comme le fait la commande |\rowcolors| de \pkg{xcolor}.
+(obligatoire), comme le fait la commande |\rowcolors| de \pkg{xcolor}. L'un des
+deux arguments de couleur peut être vide (et alors aucune couleur n'est
+appliquée dans les rangées correspondantes).
En fait, le premier argument (obligatoire) peut, plus généralement, contenir
une liste d'intervalles correspondant à l'ensemble des rangées sur lesquelles
@@ -3624,9 +3626,10 @@ $\begin{bNiceMatrix}[margin,hvlines]
\index{Pointillés@\textbf{Pointillés (lignes en ---)}|)}
-\subsection{Délimiteurs dans le préambule de l'environnement}
+\section{Délimiteurs dans le préambule de l'environnement}
\index{blkarray@\pkg{blkarray} (extension)}
+\index{delimiteurs@délimiteurs dans les préambules}
Pour les environnements à préambule (|{NiceArray}|, |{pNiceArray}|, etc.), il
est possible de placer des délimiteurs verticaux directement dans le
@@ -4042,7 +4045,7 @@ En dépit de son nom, la commande |\SubMatrix| peut également être utilisée d
\smallskip
\begin{BVerbatim}[baseline=c]
-\begin{NiceTabular}{~@{}ll~@{}}
+\begin{NiceTabular}{~LetterAt{}ll~LetterAt{}}
\toprule
Part A & the first part \\
\Block{2-1}{Part B} & a first sub-part \\
diff --git a/macros/latex/contrib/nicematrix/nicematrix.pdf b/macros/latex/contrib/nicematrix/nicematrix.pdf
index e1f5e455dd..6f728aa977 100644
--- a/macros/latex/contrib/nicematrix/nicematrix.pdf
+++ b/macros/latex/contrib/nicematrix/nicematrix.pdf
Binary files differ
diff --git a/macros/latex/contrib/nicematrix/nicematrix.tex b/macros/latex/contrib/nicematrix/nicematrix.tex
index e1cd2af742..74f6c7ae15 100644
--- a/macros/latex/contrib/nicematrix/nicematrix.tex
+++ b/macros/latex/contrib/nicematrix/nicematrix.tex
@@ -1,5 +1,6 @@
% -*- coding: utf-8 ; -*- This file should be compiled with XeLaTeX only
-\documentclass[dvipsnames]{article}% dvipsnames is for xcolor (loaded by TikZ, loaded by nicematrix)
+\documentclass[dvipsnames]{article}% dvipsnames is for xcolor (loaded by TikZ,
+ % loaded by nicematrix) ℤ
\usepackage{xltxtra}
\usepackage{geometry}
@@ -2007,7 +2008,8 @@ takes its name from the command |\rowcolors| of \pkg{colortbl}. The \emph{s}
emphasizes the fact that there is \emph{two} colors. This command colors
alternately the rows of the tabular with the two colors (provided in second
and third argument), beginning with the row whose number is given in first
-(mandatory) argument.
+(mandatory) argument. One of the arguments of color may be empty (no color is
+applied in the corresponding rows).
In fact, the first (mandatory) argument is, more generally, a comma separated
list of intervals describing the rows involved in the action of |\rowcolors|
@@ -3542,6 +3544,8 @@ $\begin{bNiceMatrix}[margin,hvlines]
\index{blkarray@\pkg{blkarray} (package)}
+\index{delimiters@delimiters in the preambles}
+
\label{delimiters-in-preamble}
In the environments with preamble (|{NiceArray}|, |{pNiceArray}|, etc.), it's
@@ -3946,7 +3950,7 @@ Despite its name, the command |\SubMatrix| may also be used within a
\medskip
\begin{BVerbatim}[baseline=c]
-\begin{NiceTabular}{~@{}ll~@{}}
+\begin{NiceTabular}{~LetterAt{}ll~LetterAt{}}
\toprule
Part A & the first part \\
\Block{2-1}{Part B} & a first sub-part \\
diff --git a/macros/latex/contrib/non-decimal-units/README.md b/macros/latex/contrib/non-decimal-units/README.md
index e5e9eb728c..83aec91ce2 100644
--- a/macros/latex/contrib/non-decimal-units/README.md
+++ b/macros/latex/contrib/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/macros/latex/contrib/non-decimal-units/docs/non-decimal-units.pdf b/macros/latex/contrib/non-decimal-units/docs/non-decimal-units.pdf
index 19b21b0375..b13257e0b4 100644
--- a/macros/latex/contrib/non-decimal-units/docs/non-decimal-units.pdf
+++ b/macros/latex/contrib/non-decimal-units/docs/non-decimal-units.pdf
Binary files differ
diff --git a/macros/latex/contrib/non-decimal-units/docs/non-decimal-units.preamble.sty b/macros/latex/contrib/non-decimal-units/docs/non-decimal-units.preamble.sty
index 977d02cbf5..2a9649d45b 100644
--- a/macros/latex/contrib/non-decimal-units/docs/non-decimal-units.preamble.sty
+++ b/macros/latex/contrib/non-decimal-units/docs/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/macros/latex/contrib/non-decimal-units/docs/non-decimal-units.tex b/macros/latex/contrib/non-decimal-units/docs/non-decimal-units.tex
index 866efed85a..66733af1d7 100644
--- a/macros/latex/contrib/non-decimal-units/docs/non-decimal-units.tex
+++ b/macros/latex/contrib/non-decimal-units/docs/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}
diff --git a/macros/latex/contrib/non-decimal-units/latex/non-decimal-units.danish.tex b/macros/latex/contrib/non-decimal-units/latex/non-decimal-units.danish.tex
index a57fd8d402..bf222b2e10 100644
--- a/macros/latex/contrib/non-decimal-units/latex/non-decimal-units.danish.tex
+++ b/macros/latex/contrib/non-decimal-units/latex/non-decimal-units.danish.tex
@@ -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
diff --git a/macros/latex/contrib/non-decimal-units/latex/non-decimal-units.sty b/macros/latex/contrib/non-decimal-units/latex/non-decimal-units.sty
index 5358a0acdb..2cd0bd9377 100644
--- a/macros/latex/contrib/non-decimal-units/latex/non-decimal-units.sty
+++ b/macros/latex/contrib/non-decimal-units/latex/non-decimal-units.sty
@@ -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@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,47 +98,58 @@
{ 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
\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,53 +333,48 @@
\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:
}
}
}
\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,70 @@
}
% 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
+ \tl_use:N \l__ndu_result_tl
+ \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
@@ -596,16 +662,12 @@
\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,24 +693,20 @@
\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
}
\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,17 +765,13 @@
}
\NewDocumentCommand \nduSymbol { m } {
- \tl_use:c { l_ndu_symbol_#1_tl }
+ \tl_use:c { l__ndu_symbol_#1_tl }
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 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 ]
diff --git a/macros/latex/contrib/siunitx/CHANGELOG.md b/macros/latex/contrib/siunitx/CHANGELOG.md
index b113b8d9d3..e6cccfce52 100644
--- a/macros/latex/contrib/siunitx/CHANGELOG.md
+++ b/macros/latex/contrib/siunitx/CHANGELOG.md
@@ -7,6 +7,17 @@ Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to
## [Unreleased]
+## [v3.3.10] - 2024-01-25
+
+### Changed
+- Load `color` package in `begindocument/before` hook
+- Normalize exponents when `exponent-mode = threshold` (see issue
+ [\#716](https://github.com/josephwright/siunitx/issues/711))
+
+### Fixed
+- Prevent accidental expansion of `\mathord` (see issue
+ [\#716](https://github.com/josephwright/siunitx/issues/716))
+
## [v3.3.9] - 2023-11-14
### Fixed
@@ -2049,7 +2060,8 @@ Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to
### Added
- First public testing release (as `si`)
-[Unreleased]: https://github.com/josephwright/siunitx/compare/v3.3.9...HEAD
+[Unreleased]: https://github.com/josephwright/siunitx/compare/v3.3.10...HEAD
+[v3.3.10]: https://github.com/josephwright/siunitx/compare/v3.3.9...v3.3.10
[v3.3.9]: https://github.com/josephwright/siunitx/compare/v3.3.8...v3.3.9
[v3.3.8]: https://github.com/josephwright/siunitx/compare/v3.3.7...v3.3.8
[v3.3.7]: https://github.com/josephwright/siunitx/compare/v3.3.6...v3.3.7
diff --git a/macros/latex/contrib/siunitx/siunitx-code.pdf b/macros/latex/contrib/siunitx/siunitx-code.pdf
index 34e9f85ef3..8b1fb01210 100644
--- a/macros/latex/contrib/siunitx/siunitx-code.pdf
+++ b/macros/latex/contrib/siunitx/siunitx-code.pdf
Binary files differ
diff --git a/macros/latex/contrib/siunitx/siunitx-number.dtx b/macros/latex/contrib/siunitx/siunitx-number.dtx
index 6397e3239f..19e2c32e9b 100644
--- a/macros/latex/contrib/siunitx/siunitx-number.dtx
+++ b/macros/latex/contrib/siunitx/siunitx-number.dtx
@@ -1,6 +1,6 @@
% \iffalse meta-comment
%
-% File: siunitx-number.dtx Copyright (C) 2014-2019,2021-2023 Joseph Wright
+% File: siunitx-number.dtx Copyright (C) 2014-2019,2021-2024 Joseph Wright
%
% It may be distributed and/or modified under the conditions of the
% LaTeX Project Public License (LPPL), either version 1.3c of this
@@ -2273,9 +2273,9 @@
% \begin{macro}[EXP]{\@@_exponent_engineering:nnNw}
% \begin{macro}[EXP]{\@@_exponent_engineering_uncert:nn}
% \begin{macro}[EXP]{\@@_exponent_engineering_uncert_S:nnn}
-% \begin{macro}[EXP]{\@@_exponent_threshold:nnnnnnn}
-% \begin{macro}[EXP]{\@@_exponent_threshold:nn, \@@_exponent_threshold:en}
-% \begin{macro}[EXP]{\@@_exponent_threshold:nnnnnnnn}
+% \begin{macro}[EXP]
+% {\@@_exponent_threshold:nnnnnnn, \@@_exponent_threshold_aux:nnnnnnn}
+% \begin{macro}[EXP]{\@@_exponent_threshold:n, \@@_exponent_threshold:e}
% Manipulating an exponent is done using a single expansion function
% \emph{unless} dealing with engineering-style output. The latter is easier
% to handle by first converting to scientific output, then post-processing.
@@ -2582,22 +2582,27 @@
% \begin{macrocode}
\cs_new:Npn \@@_exponent_threshold:nnnnnnn #1#2#3#4#5#6#7
{
- \@@_exponent_threshold:en
+ \@@_exponent_threshold:e
{
\@@_exponent_scientific:nnnnnnn
{#1} {#2} {#3} {#4} {#5} {#6} {#7}
}
- { {#1} {#2} {#3} {#4} {#5} {#6} {#7} }
}
-\cs_new:Npn \@@_exponent_threshold:nn #1#2
- { \@@_exponent_threshold:nnnnnnnn #1 {#2} }
-\cs_generate_variant:Nn \@@_exponent_threshold:nn { e }
-\cs_new:Npn \@@_exponent_threshold:nnnnnnnn #1#2#3#4#5#6#7#8
+\cs_new:Npn \@@_exponent_threshold:n #1
+ { \@@_exponent_threshold_aux:nnnnnnn #1 }
+\cs_generate_variant:Nn \@@_exponent_threshold:n { e }
+\cs_new:Npn \@@_exponent_threshold_aux:nnnnnnn #1#2#3#4#5#6#7
{
\bool_lazy_and:nnTF
{ \int_compare_p:nNn {#6#7} > \l_@@_lower_threshold_int }
{ \int_compare_p:nNn {#6#7} < \l_@@_upper_threshold_int }
- { \exp_not:n {#8} }
+ {
+ \exp_not:n { {#1} {#2} }
+ \@@_exponent_shift:nnn { -#6#7 } {#3} {#4}
+ \@@_exponent_uncert:n {#5}
+ { }
+ { 0 }
+ }
{ \exp_not:n { {#1} {#2} {#3} {#4} {#5} {#6} {#7} } }
}
% \end{macrocode}
@@ -2623,7 +2628,6 @@
% \end{macro}
% \end{macro}
% \end{macro}
-% \end{macro}
%
% \begin{macro}{\@@_digits:NN}
% \begin{macro}[EXP]{\@@_digits:nnnnnnn}
@@ -4117,7 +4121,7 @@
{
\tl_if_blank:nTF {#1}
{ \use:n }
- { \mathord }
+ { \exp_not:N \mathord }
{ \exp_not:n {#2} }
}
\cs_new:Npn
@@ -4520,7 +4524,7 @@
{
\exp_not:n {#2}
\bool_if:NTF \l_@@_tight_bool
- { \mathord }
+ { \exp_not:N \mathord }
{ \use:n }
{ \exp_not:n { \pm } }
\exp_not:n {#2}
diff --git a/macros/latex/contrib/siunitx/siunitx-print.dtx b/macros/latex/contrib/siunitx/siunitx-print.dtx
index 6e1a89f629..8d969925dd 100644
--- a/macros/latex/contrib/siunitx/siunitx-print.dtx
+++ b/macros/latex/contrib/siunitx/siunitx-print.dtx
@@ -1,6 +1,6 @@
% \iffalse meta-comment
%
-% File: siunitx-print.dtx Copyright (C) 2016-2019,2021-2023 Joseph Wright
+% File: siunitx-print.dtx Copyright (C) 2016-2019,2021-2024 Joseph Wright
%
% It may be distributed and/or modified under the conditions of the
% LaTeX Project Public License (LPPL), either version 1.3c of this
@@ -344,7 +344,10 @@
% Color support is always required; to avoid a potential clash we delay to
% the start of the document.
% \begin{macrocode}
-\AtBeginDocument { \RequirePackage { color } }
+\cs_if_exist:NTF \hook_gput_code:nnn
+ { \hook_gput_code:nnn { begindocument / before } { siunitx } }
+ { \AtBeginDocument }
+ { \RequirePackage { color } }
% \end{macrocode}
%
% Required variants.
diff --git a/macros/latex/contrib/siunitx/siunitx.dtx b/macros/latex/contrib/siunitx/siunitx.dtx
index e4ba230584..fb2dc9b5af 100644
--- a/macros/latex/contrib/siunitx/siunitx.dtx
+++ b/macros/latex/contrib/siunitx/siunitx.dtx
@@ -1,6 +1,6 @@
% \iffalse meta-comment
%
-% File: siunitx.dtx Copyright (C) 2008-2019,2021-2023 Joseph Wright
+% File: siunitx.dtx Copyright (C) 2008-2019,2021-2024 Joseph Wright
%
% It may be distributed and/or modified under the conditions of the
% LaTeX Project Public License (LPPL), either version 1.3c of this
@@ -121,7 +121,7 @@
%
% Identify the package and give the over all version information.
% \begin{macrocode}
-\ProvidesExplPackage {siunitx} {2023-11-14} {3.3.9}
+\ProvidesExplPackage {siunitx} {2024-01-25} {3.3.10}
{A comprehensive (SI) units package}
% \end{macrocode}
%
diff --git a/macros/latex/contrib/siunitx/siunitx.pdf b/macros/latex/contrib/siunitx/siunitx.pdf
index 9a3994d340..9c6da0ea29 100644
--- a/macros/latex/contrib/siunitx/siunitx.pdf
+++ b/macros/latex/contrib/siunitx/siunitx.pdf
Binary files differ
diff --git a/macros/latex/contrib/siunitx/siunitx.tex b/macros/latex/contrib/siunitx/siunitx.tex
index 37da412751..59ecd43acd 100644
--- a/macros/latex/contrib/siunitx/siunitx.tex
+++ b/macros/latex/contrib/siunitx/siunitx.tex
@@ -1,6 +1,6 @@
\iffalse meta-comment
-File: siunitx.tex Copyright (C) 2014-2023 Joseph Wright
+File: siunitx.tex Copyright (C) 2014-2024 Joseph Wright
It may be distributed and/or modified under the conditions of the
LaTeX Project Public License (LPPL), either version 1.3c of this
@@ -475,7 +475,7 @@ the unit to each number.
\cs{qtyproduct}\oarg{options}\marg{numbers}\marg{unit}
\end{syntax}
\end{function}
-Runs of products of of numbers with units can be handled using the
+Runs of products of numbers with units can be handled using the
\cs{qtyproduct} function. The behaviour of this function is similar to
\cs{numproduct}, but with the addition of a unit to each number.
\begin{LaTeXdemo}
@@ -1527,11 +1527,9 @@ scientific notation from the input
\end{LaTeXdemo}
\DescribeOption{exponent-thresholds}
When the \opt{exponent-mode} is set to \opt{threshold}, values outside of a
-threshold range for the exponent are always printed in scientific form. Within
-the threshold, they are printed as-given in the input: typically this would be
-without an exponent. The threshold range itself is controlled by
-\opt{exponent-thresholds}, which is given as
-\texttt{\meta{min}:\meta{max}} (Table~\ref{tab:threshold}).
+threshold range for the exponent are always printed in scientific form. The
+threshold range itself is controlled by \opt{exponent-thresholds}, which is
+given as \texttt{\meta{min}:\meta{max}} (Table~\ref{tab:threshold}).
\begin{LaTeXdemo}[code and float]
\begin{table}
\caption{Thresholds for exponents.%
diff --git a/macros/latex/contrib/unicode-math-input/unicode-math-input.pdf b/macros/latex/contrib/unicode-math-input/unicode-math-input.pdf
index 2bfddf791b..f5c9f1594c 100644
--- a/macros/latex/contrib/unicode-math-input/unicode-math-input.pdf
+++ b/macros/latex/contrib/unicode-math-input/unicode-math-input.pdf
Binary files differ
diff --git a/macros/latex/contrib/unicode-math-input/unicode-math-input.sty b/macros/latex/contrib/unicode-math-input/unicode-math-input.sty
index b9696c3a32..6d5a014c23 100644
--- a/macros/latex/contrib/unicode-math-input/unicode-math-input.sty
+++ b/macros/latex/contrib/unicode-math-input/unicode-math-input.sty
@@ -14,7 +14,7 @@
\RequirePackage{expl3}
\RequirePackage{iftex}
-\ProvidesExplPackage{unicode-math-input}{2024-01-18}{0.1.0}{Allow entering Unicode symbols in math formulas}
+\ProvidesExplPackage{unicode-math-input}{2024-01-25}{0.1.1}{Allow entering Unicode symbols in math formulas}
\makeatletter
\AtBeginDocument{
@@ -357,36 +357,34 @@
\cs_new_eq:NN \umiFrac \frac
% ======== after the superscript collection, \umiPrime\umiPrime... should be replaced with \dprime etc. smartly
-\cs_new_protected:Npn \umiPrime{ \__umi_prime } % indirection layer for fast meaning-equality checking
+\cs_new_protected:Npn \umiPrime{ \__umi_prime 1 } % note. Keep this short for fast meaning-equality checking
\cs_new_eq:NN \umiPrimeNormalDefinition \umiPrime
-\cs_new_protected:Npn \__umi_prime {
- \peek_meaning_collect_inline:Nn \umiPrime {
- % note that ##1 misses one \prime as expands to this current function
- \int_case:nnF { \tl_count:n {##1} } {
- 1 {\__umi_alternatives_iisafe \dprime {\prime\prime}}
- 2 {\__umi_alternatives_iisafe \trprime{\prime\prime\prime}}
- 3 {\__umi_alternatives_iisafe \qprime {\prime\prime\prime\prime}}
+\cs_new_protected:Npn \__umi_prime #1 {
+ \peek_meaning_remove:NTF \umiPrime {
+ \exp_args:Nf \__umi_prime {\int_eval:n{#1+1}}
+ } {
+ \int_case:nnF { #1 } {
+ 2 {\__umi_alternatives_iisafe \dprime {\prime\prime}}
+ 3 {\__umi_alternatives_iisafe \trprime{\prime\prime\prime}}
+ 4 {\__umi_alternatives_iisafe \qprime {\prime\prime\prime\prime}}
} {
- % complicated way to repeat '\prime' <count #1> times
- \cs_gset_eq:NN \umiPrime \prime
- \prime ##1
- \cs_gset_eq:NN \umiPrime \umiPrimeNormalDefinition
+ \prg_replicate:nn {#1} {\prime}
}
}
}
% similar for backprime
-\cs_new_protected:Npn \umiBackprime{ \__umi_backprime }
+\cs_new_protected:Npn \umiBackprime{ \__umi_backprime 1 }
\cs_new_eq:NN \umiBackprimeNormalDefinition \umiBackprime
-\cs_new_protected:Npn \__umi_backprime {
- \peek_meaning_collect_inline:Nn \umiBackprime {
- \int_case:nnF { \tl_count:n {##1} } {
- 1 {\__umi_alternatives_iisafe \backdprime {\backprime\backprime}}
- 2 {\__umi_alternatives_iisafe \backtrprime {\backprime\backprime\backprime}}
+\cs_new_protected:Npn \__umi_backprime #1 {
+ \peek_meaning_remove:NTF \umiBackprime {
+ \exp_args:Nf \__umi_backprime {\int_eval:n{#1+1}}
+ } {
+ \int_case:nnF { #1 } {
+ 2 {\__umi_alternatives_iisafe \backdprime {\backprime\backprime}}
+ 3 {\__umi_alternatives_iisafe \backtrprime {\backprime\backprime\backprime}}
} {
- \cs_gset_eq:NN \umiBackprime \backprime
- \backprime ##1
- \cs_gset_eq:NN \umiBackprime \umiBackprimeNormalDefinition
+ \prg_replicate:nn {#1} {\backprime}
}
}
}
diff --git a/macros/latex/contrib/unicode-math-input/unicode-math-input.tex b/macros/latex/contrib/unicode-math-input/unicode-math-input.tex
index 61fe577ced..e7b4b217a5 100644
--- a/macros/latex/contrib/unicode-math-input/unicode-math-input.tex
+++ b/macros/latex/contrib/unicode-math-input/unicode-math-input.tex
@@ -1,5 +1,5 @@
%! TEX program = lualatex
-\ProvidesFile{unicode-math-input.tex} [2024/01/18 v0.1.0 ]
+\ProvidesFile{unicode-math-input.tex} [2024/01/25 v0.1.1 ]
\PassOptionsToPackage{hyphens}{url}
\RequirePackage{fvextra}
\documentclass{l3doc}
@@ -234,7 +234,7 @@ Simply include the package.
\usepackage{unicode-math-input}
\end{verbatim}
-Because by default the \pkg{unicode-math} package will already allow entering Unicode symbols in math formulas, this package will raise an error if the other package is already loaded.
+Because by default the \pkg{unicode-math} package will already allow entering Unicode symbols in math formulas, this package will raise an error if \pkg{unicode-math} is already loaded.
\section{Advanced commands and options}