summaryrefslogtreecommitdiff
path: root/Master/texmf-dist
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2017-10-23 22:21:26 +0000
committerKarl Berry <karl@freefriends.org>2017-10-23 22:21:26 +0000
commit08541f1238259e89340cc52f9838c8591dbab1f5 (patch)
tree86e12059f2f30cfcafb83953d444b6e796df9870 /Master/texmf-dist
parent6a26d1aa8ad4cdce657ae0ae7c12b464b34b6bd1 (diff)
cooking-units (23oct17)
git-svn-id: svn://tug.org/texlive/trunk@45585 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist')
-rw-r--r--Master/texmf-dist/doc/latex/cooking-units/README.md27
-rw-r--r--Master/texmf-dist/doc/latex/cooking-units/cooking-units.pdfbin583125 -> 600842 bytes
-rw-r--r--Master/texmf-dist/source/latex/cooking-units/cooking-units.dtx4048
-rw-r--r--Master/texmf-dist/source/latex/cooking-units/cooking-units.ins9
-rw-r--r--Master/texmf-dist/tex/latex/cooking-units/cooking-units.sty1866
5 files changed, 4031 insertions, 1919 deletions
diff --git a/Master/texmf-dist/doc/latex/cooking-units/README.md b/Master/texmf-dist/doc/latex/cooking-units/README.md
index 801a5b1c0db..24087ef30d7 100644
--- a/Master/texmf-dist/doc/latex/cooking-units/README.md
+++ b/Master/texmf-dist/doc/latex/cooking-units/README.md
@@ -7,26 +7,26 @@ Overview
While writing a cookery book, units and their format can be quite
troublesome. This contains not only the question of how to print those
-units, but also the question of the conversion of units. A cookery book
-doesn't contain only SI units, it contains a much more colorful range
-of units (kg, dag, g, oz, ... for example) and it may cause some
-confusion if too many different units are used, but if you just write a
-cookery book for fun you don't think about this ... until someone
-(my mother in my case) tells you that it's too confusing.
+units, but also the question of the conversion of units. A cookery
+book doesn't contain only SI units, it contains a much more colorful
+range of units (kg, dag, g, oz, ... for example) and it may cause
+some confusion if too many different units are used, but if you just
+write a cookery book for fun you don't think about this ... until
+someone (my mother in my case) tells you that it's too confusing.
-This package solves both problems: It formats your input and
-you have the option to convert the units globally or locally using an
-easy to use key-value system.
+This package solves both problems: It formats your input and you have
+the option to convert the units globally or locally using an easy to
+use key-value system.
-Please note that this package is not intended to be used to
-print units (and numbers) physically correct. It should be used for
-more light-hearted stuff (like a cookery book for example).
+Please note that this package is not intended to be used to print
+units (and numbers) physically correct. It should be used for more
+light-hearted stuff (like a cookery book for example).
Requirements
------------
* expl3 & xparse
- * translator
+ * translations
* xfrac
* l3keys2e
* fmtcount (optional)
@@ -59,3 +59,4 @@ This material is subject to the LaTeX Project Public License. See
for the details of that license.
+%%
diff --git a/Master/texmf-dist/doc/latex/cooking-units/cooking-units.pdf b/Master/texmf-dist/doc/latex/cooking-units/cooking-units.pdf
index 5a754100cd6..0c964502b38 100644
--- a/Master/texmf-dist/doc/latex/cooking-units/cooking-units.pdf
+++ b/Master/texmf-dist/doc/latex/cooking-units/cooking-units.pdf
Binary files differ
diff --git a/Master/texmf-dist/source/latex/cooking-units/cooking-units.dtx b/Master/texmf-dist/source/latex/cooking-units/cooking-units.dtx
index 06a8db58f74..910c4776e48 100644
--- a/Master/texmf-dist/source/latex/cooking-units/cooking-units.dtx
+++ b/Master/texmf-dist/source/latex/cooking-units/cooking-units.dtx
@@ -3,8 +3,6 @@
% !TEX program = pdfLaTeX
%
%
-%
-%
%<*internal>
\iffalse
%</internal>
@@ -16,28 +14,28 @@ cooking-units
Overview
--------
-While writing a cookery book, units and their format can be quite
+While writing a cookery book, units and their format can be quite
troublesome. This contains not only the question of how to print those
-units, but also the question of the conversion of units. A cookery book
-doesn't contain only SI units, it contains a much more colorful range
-of units (kg, dag, g, oz, ... for example) and it may cause some
-confusion if too many different units are used, but if you just write a
-cookery book for fun you don't think about this ... until someone
-(my mother in my case) tells you that it's too confusing.
+units, but also the question of the conversion of units. A cookery
+book doesn't contain only SI units, it contains a much more colorful
+range of units (kg, dag, g, oz, ... for example) and it may cause
+some confusion if too many different units are used, but if you just
+write a cookery book for fun you don't think about this ... until
+someone (my mother in my case) tells you that it's too confusing.
-This package solves both problems: It formats your input and
-you have the option to convert the units globally or locally using an
-easy to use key-value system.
+This package solves both problems: It formats your input and you have
+the option to convert the units globally or locally using an easy to
+use key-value system.
-Please note that this package is not intended to be used to
-print units (and numbers) physically correct. It should be used for
-more light-hearted stuff (like a cookery book for example).
+Please note that this package is not intended to be used to print
+units (and numbers) physically correct. It should be used for more
+light-hearted stuff (like a cookery book for example).
Requirements
------------
* expl3 & xparse
- * translator
+ * translations
* xfrac
* l3keys2e
* fmtcount (optional)
@@ -84,7 +82,7 @@ for the details of that license.
%\keepsilent
\askforoverwritefalse
\preamble
-Copyright (C) 2016 by Ben Vitecek (current Maintainer)
+Copyright (C) 2016--2017 by Ben Vitecek (current Maintainer)
This file may be distributed and/or modified under the
conditions of the LaTeX Project Public License, either
@@ -93,7 +91,7 @@ version. The latest version of this license is in:
http://www.latex-project.org/lppl.txt
-and version 1.3c or later is part of all distributions of
+and version 1.3 or later is part of all distributions of
LaTeX version 2008-05-04 or later.
This work has the LPPL maintenance status `maintained'.
@@ -129,37 +127,44 @@ and the derived file cooking-units.sty.
\fi
%</internal>
%<*driver>
-\documentclass [
+\documentclass[
+ ngerman,
+ french,
english, %french, naustrian
onlydoc,
% check-declarations,
]{l3doc}
\usepackage[utf8]{inputenc}
-\usepackage{babel}
+\usepackage[main=english]{babel}
\usepackage[use-numerals=true]{cooking-units}
\usepackage{tikzsymbols}
\usepackage{listings}
\usepackage{environ}
\usepackage{nicefrac}
-\usepackage{varioref}
+\usepackage{cleveref}
\usepackage{mathtools}
\usepackage{siunitx}
+\babeltags{myde = ngerman}
+
\DeclareSIUnit{\ounce}{oz}
\DeclareSIUnit{\oz}{\ounce}
\DeclareSIUnit{\pound}{lb}
\DeclareSIUnit{\lb}{\pound}
\DeclareSIUnit{\stone}{st}
\DeclareSIUnit{\st}{\stone}
-\cusetup{use-numerals-below=0}
+\DeclareSIUnit{\stick}{st}
+\cusetup{print-numerals=false}
%\EnableCrossrefs
-\labelformat{table}{table~#1}
-\labelformat{section}{section~#1}
+
+%\newcommand\TODO[1]{\footnote{\textcolor{red}{#1}}}
\ExplSyntaxOn
+
+
\clist_new:N \l_cooking_units_list_of_defined_befehlen_clist
\clist_set:Nn \l_cooking_units_list_of_defined_befehlen_clist
{
@@ -192,19 +197,30 @@ and the derived file cooking-units.sty.
\newcommand\true{\opt{true}}
\newcommand\false{\opt{false}}
-\NewDocumentCommand \PrintUnit { m }
+%: \PrintUnit
+\NewDocumentCommand \PrintUnit { o m }
{
- \translate{ #1 (cu-unitname) } & #1 & \translate{ #1 ( cu-unit ) }
+ \SaveTranslation \l_tmpa_tl { #2 (cu-unitname) }
+ \tl_if_eq:NNF \l_tmpa_tl \q__cooking_units_no_translation
+ { \l_tmpa_tl }
+ \IfNoValueF {#1} {#1}
+ &
+ \texttt {#2}
+ &
+ \tl_use:c { l__cooking_units_default_unit_ #2 _tl }
}
-
\NewDocumentCommand \PrintUnitSymbol { m }
{
- #1 & \translate{ #1 ( cu-unit ) }
+ \texttt {#1} &
+ \tl_use:c { l__cooking_units_default_unit_ #1 _tl }
}
-
-\NewDocumentCommand \dothewhitespace { O{ 42 } }
+
+
+%% Allyourwhitespacearebelongtous (too long)
+%% 42
+\NewDocumentCommand \dothewhitespace { O{ Miep! } }
{
\textcolor{white} {#1} \\
}
@@ -214,7 +230,8 @@ and the derived file cooking-units.sty.
\begin{center}
\begin{minipage}{0.4\linewidth}
\tl_replace_all:Nnn \BODY { @ } { \dothewhitespace }
- \tl_replace_all:Nnn \BODY { ! } { }
+ \tl_replace_all:Nnn \BODY { \% } { \color{red} \% \ignorespaces }
+ \tl_replace_all:Nnn \BODY { \\ } { \\ \color{black} }
\tl_replace_all:Nnn \BODY { & } { \ignorespaces }
\BODY
\end{minipage}
@@ -229,7 +246,6 @@ and the derived file cooking-units.sty.
\char_set_catcode_other:N \} %
\char_set_catcode_other:N \_ %
\char_set_catcode_other:N \~ %
-% \char_set_catcode_other:N \# %
}
{ \BODY }
\tl_map_inline:Nn \l_tmpa_tl
@@ -249,14 +265,20 @@ and the derived file cooking-units.sty.
}
}
{
- \bool_if:nTF
- {
- \str_if_eq_p:nn {##1} { @ } ||
- \str_if_eq_p:nn {##1} { ! } ||
- \str_if_eq_p:nn {##1} { & }
+ \bool_lazy_any:nTF
+ {
+ { \str_if_eq_p:nn {##1} { @ } }
+ { \str_if_eq_p:nn {##1} { ! } }
+ { \str_if_eq_p:nn {##1} { & } }
}
{
- \str_if_eq:nnTF {##1} { & } { \space } { \\ }
+ \str_if_eq:nnTF {##1} { & }
+ { \space }
+ {
+ \str_if_eq:nnTF {##1} { ! }
+ { \ERROR }
+ { \\ }
+ }
}
{
\token_if_active:NTF ##1
@@ -279,16 +301,39 @@ and the derived file cooking-units.sty.
\end{minipage}
\end{center}
}
-
+\ProvideDocumentEnvironment{cuexamplecode}{}{}{}{}
\NewDocumentEnvironment { cuexample } { }
- { \paragraph{Example:} }
+ {
+ \paragraph{Example:}
+% \par \bigskip \noindent
+% \mbox{}
+% \marginpar{\raggedleft\textbf{Example}}\
+% \ignorespaces
+ }
{ }
+\NewDocumentEnvironment { cunote } { }
+ {
+ \paragraph{Note:}
+ }{ }
+
+
+\NewDocumentEnvironment { cuinterest } { m }
+ {
+ \par \bigskip
+ \clist_set:Nn \l_tmpa_clist {#1}
+ \mbox{}\marginpar{\raggedleft\opt{ \clist_use:Nn \l_tmpa_clist { \\ } }}
+ \ignorespaces
+ }
+ { }
+
+
%: table
\tl_new:N \l_translation_does_not_exist_tl
\tl_set:Nn \l_translation_does_not_exist_tl { --- }
+\tl_new:N \translationdoesnotexisttl
\tl_set_eq:NN \translationdoesnotexisttl \l_translation_does_not_exist_tl
\tl_new:N \mytablecolumns
\tl_set:Nn \mytablecolumns { l l l l l }
@@ -310,67 +355,123 @@ and the derived file cooking-units.sty.
l , dl , cl , ml , space ,
cal , kcal , J , kJ , eV , space ,
pn , EL , TL , csp , dsp , ssp , Msp , space ,
- \clist_use:Nn \l_list_of_textunits_clist { , }
+ \clist_use:Nn \l_list_of_textunits_clist { , } ,
+ THEEND
+ }
+
+\cs_new:Npn \__table_midrule:
+ {
+ \\ \midrule
+ \cs_gset:Npn \__table_midrule: { \\ }
}
+\cs_new_eq:NN \__table_default_midrule: \__table_midrule:
+\cs_new:Npn \_cook_use:n #1
+ { \cs_if_exist_use:cF { __cooking_units_#1 } {\ERROR} }
-\NewDocumentCommand \CreateTableForLanguages { s m }
+\NewDocumentCommand \CreateTableForLanguages { s >{\TrimSpaces} m }
{
\IfBooleanTF {#1}
{ \clist_gset_eq:NN \l_tmpa_clist \l_list_of_textunits_clist }
{ \clist_gset_eq:NN \l_tmpa_clist \l_list_of_units_clist }
- \CreateTableHeader {#2} \\ \midrule
+ \cs_gset_eq:NN \__table_midrule: \__table_default_midrule:
+ \CreateTableHeader {#2}
\CreateTableRow {#2}
}
\NewDocumentCommand \CreateTableHeader { m }
{
- \meta{unit-key} & \clist_map_inline:nn {#1} { printed \ unit & unit-name & (plural) & gender }
+ \meta{unit-key} &
+ printed \ unit & unit name & (plural) & gender
}
\NewDocumentCommand \CreateTableRow { m }
{
\clist_map_inline:Nn \l_tmpa_clist
{
- \str_if_eq:nnTF { space } {##1} { \addlinespace }
+ \str_case:nnF {##1}
{
+ { space } { \\ \addlinespace \cs_set:Npn \__table_midrule: {} }
+ { THEEND } { \\ \bottomrule }
+ }{
+ \__table_midrule:
##1
- \clist_map_inline:nn {#1}
- {
&
\clist_if_in:NnTF \l_list_of_textunits_clist {##1}
{ \l_translation_does_not_exist_tl }
{
- \translatelet[to=####1]\l_tmpa_tl{ ##1 (cu-unit) }
- \tl_if_in:NnTF \l_tmpa_tl { unit }
+ \_cook_use:n { translate_let:nNxx } {#1} \l_tmpa_tl {##1} \c__cooking_units_postfix_unit_tl
+ \tl_if_in:NnTF \l_tmpa_tl \q__cooking_units_no_translation
{ \l_translation_does_not_exist_tl }
{ \l_tmpa_tl }
}
&
- \translatelet[to=####1]\l_tmpa_tl{ ##1 (cu-unitname) }
- \tl_if_in:NnTF \l_tmpa_tl { unitname }
+ \_cook_use:n { translate_let:nNxx } {#1} \l_tmpa_tl {##1} \c__cooking_units_postfix_unitname_tl
+ \tl_if_in:NnTF \l_tmpa_tl \q__cooking_units_no_translation
{ \l_translation_does_not_exist_tl }
{ \l_tmpa_tl }
&
- \translatelet[to=####1]\l_tmpa_tl{ ##1 (cu-unitname) }
- \translatelet[to=####1]\l_tmpb_tl{ ##1 (cu-unitname pl) }
- \tl_if_eq:NNTF \l_tmpa_tl \l_tmpb_tl
- { }
+ \_cook_use:n { translate_let:nNxx } {#1} \l_tmpa_tl {##1} \c__cooking_units_postfix_unitname_tl
+ \_cook_use:n { translate_let:nNxx } {#1} \l_tmpb_tl {##1} \c__cooking_units_postfix_unitname_pl_tl
+ \tl_if_eq:NNF \l_tmpa_tl \l_tmpb_tl
{
- \tl_if_in:NnTF \l_tmpb_tl { unitname }
+ \tl_if_in:NnTF \l_tmpb_tl \q__cooking_units_no_translation
{ \l_translation_does_not_exist_tl }
{ (\l_tmpb_tl) }
}
&
- \translatelet[to=####1]\l_tmpa_tl{ ##1 (cu-unitgender) }
- \tl_if_in:NnTF \l_tmpa_tl { gender }
+ \_cook_use:n { translate_let:nNxx } {#1} \l_tmpa_tl {##1} \c__cooking_units_postfix_gender_tl
+ \tl_if_in:NnTF \l_tmpa_tl \q__cooking_units_no_translation
{ \l_translation_does_not_exist_tl }
{ \l_tmpa_tl }
- }
- \\
}
}
}
+\NewDocumentCommand \CreateTableForPhrases { >{\TrimSpaces} m }
+ {
+ \tl_set:Nn \l_tmpa_tl {#1}
+ \__cooking_units_phrase_list_get_for:NNTF \l_tmpa_prop \l_tmpa_tl
+ {
+ \__cooking_units_translate_let:VNxx \l_tmpa_tl \l_tmpa_clist
+ { phrase-list-list } \c__cooking_units_postfix_phrase_tl
+ }
+ { \ERROR }
+ \clist_gput_right:Nn \l_tmpa_clist { THEEND }
+ \cs_gset_eq:NN \__table_midrule: \__table_default_midrule:
+ \begin{tabular}{ l l l l l }
+ \toprule
+ \meta{Phrase-key} & phrase & (plural) & gender
+ \CreatePhraseTableRow {#1}
+ \end{tabular}
+ }
+
+\NewDocumentCommand \CreatePhraseTableRow { m }
+ {
+ \clist_map_inline:Nn \l_tmpa_clist
+ {
+ \str_case:nnF {##1}
+ {
+ { space } { \addlinespace \cs_set:Npn \__table_midrule: {} }
+ { THEEND } { \\ \bottomrule }
+ }{
+ \__table_midrule:
+ ##1
+ &
+ \prop_get:NnN \l__cooking_units_phrase_prop {##1} \l_tmpa_tl
+ \tl_gset:NV \l_tmpa_tl \l_tmpa_tl %% Damit global
+ \l_tmpa_tl
+ &
+ \prop_get:NnN \l__cooking_units_phrase_prop {##1-pl} \l_tmpb_tl
+ \tl_if_eq:NNF \l_tmpa_tl \l_tmpb_tl { \l_tmpb_tl }
+ &
+ \__cooking_units_translate_let:nNxx {#1}
+ \l_tmpa_tl { ##1 -phrase-gender } \c__cooking_units_postfix_gender_tl
+ \l_tmpa_tl
+ }
+ }
+ }
+
+
\ExplSyntaxOff
\newcommand\cCutext{\mycs{cutext} and \mycs{Cutext}}
@@ -402,6 +503,7 @@ and the derived file cooking-units.sty.
cuaddtokeys,
culabel,
curef,
+ cudefinephrase,
}
}
@@ -413,7 +515,7 @@ and the derived file cooking-units.sty.
}
-\newcookingunit [\ensuremath{ {} ^ { \circ } }\kern-\scriptspace R{\o}] {Ro}
+\newcookingunit [\ensuremath{ {} ^ { \circ } }\kern-\scriptspace R{\text{\o}}] {Ro}
\cuaddsinglekeys {C}
{
@@ -421,14 +523,14 @@ and the derived file cooking-units.sty.
}
\cusetup
{
- set-option-for-Ro = { round-to-int = true }
+ set-option-for-Ro = { round-to-int = true }
}
-
%: \cusetup
\cusetup
{
% convert-to-eV=true ,
+% cutext-range-sign = {as},
% erase-all-options,
% set-option-for-K= {},
% set-unknown-message = error ,
@@ -472,6 +574,7 @@ and the derived file cooking-units.sty.
% \iffalse
%: changes
% \fi
+%
% \changes {2016/06/11} {0.99} {Added the package option to load 'fmtcount'.}
% \changes {2016/08/31} {1.00} {Initial version}
% \changes {2016/08/31} {1.00a} {Fixed calculation: degree Reamur to eV}
@@ -511,13 +614,39 @@ and the derived file cooking-units.sty.
% \changes {2016/11/13} {1.10} {New options: \opt{cutext-to-cunum}, \opt{cutext-change-unit} and \opt{cutext-space}.}
% \changes {2016/11/13} {1.10} {New options: \opt{cuam-version} and \opt{cutext-version}}
% \changes {2016/11/13} {1.10} {New options: \opt{recalculate-amount} and \opt{set-number-of-persons}, \opt{label}, \opt{get-label}, \opt{ref}.}
+% \changes {2017/03/10} {1.10a} {\cs{curef} is now defined by \cs{NewExpandableDocumentCommand} instead of the Declare variant.}
+% \changes {2017/03/10} {1.11} {Removed \cs{translate} and others from code
+% and replaced them with wrapper-macros.}
+% \changes {2017/03/10} {1.11} {Removed things like 'cu-unit' from translate input
+% and placed them into separate tl's.}
%
+% \changes {2017/10/23} {1.2} {Replaced \pkg{translator} by \pkg{translations}.}
+% \changes {2017/10/23} {1.2} {Added \enquote{phrases}.}
+% \changes {2017/10/23} {1.2} {Added unit \enquote{stick} (of butter).}
+% \changes {2017/10/23} {1.2} {|<| is not allowed as a special sign anymore.}
+% \changes {2017/10/23} {1.2} {New option: \opt{set-cutext-translation-message}.}
+% \changes {2017/10/23} {1.2} {New option: \opt{print-numerals}.}
+% \changes {2017/10/23} {1.2} {New option: \opt{use-phrases}.}
+% \changes {2017/10/23} {1.2} {New option: \opt{phrase-space}.}
+% \changes {2017/10/23} {1.2} {New option: \opt{amount-unit-space}.}
+% \changes {2017/10/23} {1.2} {Now checks for ranges if both values can be printed as numerals (if activated) (bug fix).}
+% \changes {2017/10/23} {1.2} {Reworked quite a lot of code.}
+%
%
+%
+%
+%
+%
+%
+%
+%
+%%
% \GetFileInfo{\jobname.sty}
%
%\title{The \pkg{\jobname} package^^A
%\thanks{This document corresponds to \textsf{Benedikt Vitecek}~\fileversion, dated~\filedate.}}
%\author{Ben Vitecek \\ b.vitecek@gmx.at}%
+%\date{October 23, 2017}%
%
%
% \maketitle
@@ -531,58 +660,84 @@ and the derived file cooking-units.sty.
% It should be used for light-hearted things like
% cookery books (and not e.g. scientific texts).\footnote{I did hide some
% grammatical and spelling errors for easter egg hunters \Winkey.}
+%
+% Please read through the section \enquote{Important Changes}
% \end{abstract}
%
% \tableofcontents
%
+% \begin{comment}
+% \begin{myde}
+% \cusetup{print-numerals=true,use-phrases=true}
+% \cunum[convert-to-eV=true]{1}{m} \\
+% \cunum[convert-to-eV=true]{1}{m} \\
+% \cuam{6} Eier \\
+% \cuam{12} Eier \\
+% \cuam{18} Eier \\
+% \cuam{132--168} Eier \\
+% \cuam{12--24} Eier \\
+% \cuam{12--24.2} Eier \\
+% \cuam{24--12} Eier \\
+% \cuam{18--6} Eier \\
+% \cuam[recalculate-amount=true, set-number-of-persons=10, label=Hallo*4, ref=Hallo]{24} Eier \\
+% \cuam[recalculate-amount=true, set-number-of-persons=10, ref=Hallo, use-phrases=false]{24} Eier (phrase-false)\\
+% \cuam[recalculate-amount=true, set-number-of-persons=10, ref=Hallo, parse-number=false]{12--24} Eier (no parse)\\
+% \cuam{23} Eier \\
+% \cuam{60} Eier \\
+% \cuam{62} Eier \\
+% \cuam{12--60} Eier \\
+% \cuam{288} Eier \\
+% \end{myde}
+%
+% \begingroup
+% \cusetup{print-numerals=true}
+% \cutext[convert-to-eV=true]{1}{m} \\
+% \cunum[convert-to-eV=true]{1}{m} \\
+% \cuam{6} Eier \\
+% \cuam{12} Eier \\
+% \cuam{18} Eier \\
+% \cuam[recalculate-amount=true, set-number-of-persons=10, ref=Hallo]{24} Eier \\
+% \cuam[recalculate-amount=true, set-number-of-persons=10, ref=Hallo, use-phrases=false]{24} Eier \\
+% \cuam{23} Eier \\
+% \cuam{60} Eier \\
+% \cuam{62} Eier \\
+% \endgroup
+% \end{comment}
%
% \section{Introduction}
%
%
% While writing on a cookery book I used -- for reasons whatsoever --
% three different units for weight: kilogram (kg), gram (g) and
-% decagram (dag, or older: dkg). Later my mother told me that she doesn't like it if a
-% cookery book uses more than two different units (for weight in this case). Happily
-% I hardly used Decagram and therefore didn't have many problems
-% changing the units. But, well \dots\ I am using \LaTeX\ and changing
-% those units by hand seemed not very \LaTeX\-like, so I started
-% writing some code to convert units. I expanded the code, rewrote it
-% in \LaTeX3 (which is much more pleasant than \LaTeXe) and here it
-% is.
-%
-% \section{Important note}
-%
-% This package uses the \pkg{translator} package to be able to switch
-% between different languages (german, english and french by now).
-% To do that \pkg{translator} has to know
-% which languages are used. The (I think) easiest way is to specify
-% used languages using the optional argument of the documentclass (you
-% can do this for both \pkg{babel} and \pkg{polyglossia}\footnote{I
-% know that \pkg{polyglossia} doesn't support the \pkg{babel}-way of
-% setting the language by optional argument, but it doesn't harm.}):
-%
-% \begin{lstlisting}
-% \documentclass[english,french,ngerman]{class}
-% \usepackage[main=english]{babel}
-% \usepackage{cooking-units}
-% ...
-% \end{lstlisting}
+% decagram (dag, or older: dkg). Later my mother told me that she
+% doesn't like it if a cookery book uses more than two different units
+% (for weight in this case). Happily I hardly used Decagram and
+% therefore didn't have many problems changing the units. But, well
+% \dots\ I am using \LaTeX\ and changing those units by hand seemed
+% not very \LaTeX\-like, so I started writing some code to convert
+% units. I expanded the code, rewrote it in \LaTeX3 (which is much
+% more pleasant than \LaTeXe) and here it is.
+%
+%
+% \subsection{Important Changes}
+%
+% \begin{description}
+% \item[Language] I am now using the \pkg{translations} package
+% and I hope it makes things easier. As such, declaring the used language
+% through class options shouldn't be necessary anymore.
+% \item[Phrases] This package now supports the usage of \enquote{phrases}
+% (words used instead of certain integers) (which I think are called \enquote{counting
+% measures} in english, but I am not sure).
+% \item[\cCutext] If no translation is found for a specific language,
+% \cCutext\ are replaced by \mycs{cunum} with a warning is given.
+% \item[Commands] Currently, it seems that allowing \meta{label}
+% to be set by arrow-brackets was not the best idea as it leads to problems
+% if they are made active (e.g. \pkg{babel} and option \opt{spanish}). As such,
+% |<| is not allowed as a \enquote{special-sign} anymore as this package
+% tries to \enquote{fix} this idea (at least make it work). If any problems occur
+% (for this specific case or in general) please feel free to contact me.
+% \end{description}
%
-% or if you are using \pkg{polyglossia}
-%
-% \begin{lstlisting}
-% \documentclass[french,ngerman,english]{class}
-%
-% \usepackage{polyglossia}
-% \setmainlanguage{english}
-% \setotherlanguages{german,french}
-%
-% \usepackage{cooking-units}
-% ...
-% \end{lstlisting}
-%
-% At least I hope that this works, dealing with languages is a pain in
-% the ass\footnote{If you excuse me being blunt about this}.
%
% \subsection{Supported languages}
%
@@ -591,39 +746,42 @@ and the derived file cooking-units.sty.
% \item English
% \item French (currently suboptimal\footnote{You can only get limited information from the internet.})
% \end{itemize}
-% Have another language to add or a correction of an existing one?
-% See \vref{sec:bug-feed} for more details. Wanna just check the existing
-% translations? See \vref{sec:Translations}.
+% Have another language to add or a correction of an existing one?
+% See \cref{sec:bug-feed} for more details. Wanna just check the
+% existing translations? See \cref{sec:Translations}.
%
% \section {The Commands}
% \label{sec:commands}
%
-% This package offers the following commands for unit printing (and converting):
+%
+% This package offers the following commands for unit printing (and
+% converting):
%
% \begin{itemize}
% \item \mycs{cunum}\meta{label}\oarg{options}\marg{amount}\oarg{space}\marg{unit-key}
% \item \mycs{cutext}\meta{label}\oarg{options}\marg{amount}\marg{unit-key}
% \item \mycs{Cutext}\meta{label}\oarg{options}\marg{amount}\marg{unit-key}
% \item \mycs{cuam}\meta{label}\oarg{options} \marg{amount}
+% \item \mycs{cusetup}\marg{options}
% \end{itemize}
%
% Numbers and units are printed using \mycs{cunum}. The numerical part
% can interpret \verb|_| and \texttt{/} as (mixed) fractions and
% \verb|--| as a separator for ranges; to convert units use the option
% \texttt{\meta{old-unit}=\meta{new-unit}}\footnote{New keys can be
-% added and defined, see \vref{sec:pred-units} and
-% \vref{sec:def-units} for further information.}. It furthermore allows the
-% sign \texttt{?} to be used as a placeholder for not known amounts
-% and raises a warning
-% to remind that this amount needs a checkup\footnote{You can
-% customize this behavior, see \vref{sec:options}}. \oarg{space} adds
-% a space between the number and the unit using \lstinline|\phantom|.
+% added and defined, see \cref{sec:pred-units} and
+% \cref{sec:def-units} for further information.}. It furthermore
+% allows the sign \texttt{?} to be used as a placeholder for not known
+% amounts and raises a warning to remind that this amount needs a
+% check-up\footnote{You can customize this behavior, see
+% \cref{sec:options}}. \oarg{space} adds a space between the number
+% and the unit using \lstinline|\phantom|.
%
-% For a list of predefined units have a look at \vref{tab:def-units}.
+% For a list of predefined units have a look at \cref{tab:def-units}.
%
-% \meta{label} is explained in \vref{sec:labeletref}.
+% \meta{label} is explained in \cref{sec:labeletref}.
+%
%
-%
% \begin{cuexamplecode}
% \cunum{1}{kg} \\
% \cunum{2.3}{kg} \\
@@ -645,54 +803,55 @@ and the derived file cooking-units.sty.
% Decimal numbers are automatically rounded to 2 digits after the
% colon, temperatures (\texttt{C}, \texttt{F}, \texttt{K} and
% \texttt{Re}) are automatically rounded to integers.\footnote{You can
-% -- of course -- change this behavior, see \vref{sec:options}.}
+% -- of course -- change this behavior, see \cref{sec:options}.}
%
%
-% \cCutext\ print the number and the written name of the unit. Since v1.10
-% it works similar\footnote{One could also say \enquote{exactly like}.} to \mycs{cunum}: it allows the conversion between units
-% and interprets the numerical part (again |_| and |/|
-% are used for (mixed) fractions and |--| for ranges).
-% Furthermore, if the package option
-% \opt{use-numerals} is used, integers below a specific integer (by
-% default 13; see \opt{use-numerals-below}) are written out with
-% \lstinline|\Cutext| capitalizing the first letter (using package \pkg{fmtcount}).
+% \cCutext\ print the number and the written name of the unit. Since
+% v1.10 it works similar\footnote{One could also say \enquote{exactly
+% like}.} to \mycs{cunum}: it allows the conversion between units and
+% interprets the numerical part (again |_| and |/| are used for
+% (mixed) fractions and |--| for ranges). Furthermore, if the package
+% option \opt{use-numerals} is used, integers below a specific integer
+% (by default 13; see \opt{use-numerals-below}) are written out with
+% \lstinline|\Cutext| capitalizing the first letter (using package
+% \pkg{fmtcount}).
%
%
% \begin{cuexamplecode}
% \cutext{1}{l} \\
% \Cutext{1}{l} \\
+% \Cutext{1--2}{l} \\
% \cutext{12}{l} \\
% \Cutext{13}{l}
% \end{cuexamplecode}
% and using package option \opt{use-numerals=true}
-% \cusetup{use-numerals-below=13}
+% \cusetup{print-numerals=true}
% \begin{cuexamplecode}
-% \cutext{1--2}{l} \\
+% \cutext{1}{l} \\
% \Cutext{1}{l} \\
+% \cutext{1--2}{l} \\
% \cutext{12}{l} \\
% \Cutext{13}{l}
% \end{cuexamplecode}
-% \cusetup{use-numerals-below=0}
+% \cusetup{print-numerals=false}
% Furthermore,
-% since v1.10 \cCutext\ also allows their units to be changed (this behavior
+% since v1.10 \cCutext\ also allow their units to be changed (this behavior
% can be altered using \opt{cutext-change-unit}):
% \begin{cuexamplecode}
-% \cutext[l=ml]{1}{l} \\
-% \Cutext[l=ml]{1}{l} \\
-% \cutext[l=ml]{12}{l} \\
-% \Cutext[l=ml]{13}{l} \\
-% \Cutext[l=ml]{?}{l} \\
-% \Cutext[l=ml]{1/2}{l}
+% \cusetup{ l=ml } @
+% \cutext{1}{l} \\
+% \Cutext{1}{l} \\
+% \cutext{1--2}{l} \\
+% \cutext{12}{l} \\
+% \Cutext{13}{l} \\
+% \Cutext{?}{l} \\
+% \Cutext{1/2}{l} \\
% \end{cuexamplecode}
%
-%
+%
% \lstinline|\cuam| works like \mycs{cunum}, but without a unit, so
-% changing units doesn't affect it. Like \mycs{cunum} \texttt{\_} and \texttt{/}
-% are used to imply a (mixed) fraction and |--| is used to print ranges.
-%^^A works like a more primitive version \mycs{cunum}
-%^^A which doesn't need a unit, but doesn't check the input like \mycs{cunum}.
-%^^A Like in \lstinline|\cunum| \texttt{\_} and \texttt{/} are used to imply a (mixed) fraction and \texttt{-{}-} is
-%^^A used to print ranges\footnote{Note that since v1.02 \mycs{cufrac} is obsolete.}:
+% changing units doesn't affect it. Like \mycs{cunum} \texttt{\_} and
+% \texttt{/} are used to imply a (mixed) fraction and |--| is used for ranges.
%
% \begin{cuexamplecode}
% \cuam{3} \\
@@ -701,43 +860,47 @@ and the derived file cooking-units.sty.
% \cuam{1_2/3}
% \end{cuexamplecode}
%
+% Furthermore it allows the concept of \enquote{phrases} (replacing a positive integer
+% by a word, such as \enquote{12} becoming \enquote{dozen}\footnote{At least I think})
+% which can be activated by the option \opt{use-phrases}
+% (as I don't know any english phrases, I switched the language to german for the following examples)
+% \begin{myde}
+% \begin{cuexamplecode}
+% \cusetup{use-phrases=true} @
+% \cuam{12} \\
+% \cuam{13} \\
+% \cuam{24} \\
+% \cuam{12--24} \\
+% \cuam{12--13}\\
+% \cuam{18} \\
+% \cuam{60}
+% \end{cuexamplecode}
+% \end{myde}
+%
%
% \section{Label \& refs: Changing the amount of the recipe}
% \label{sec:labeletref}
%
-%^^A You may write or have a recipe for a specific number of persons
-%^^A (e.g. for 4), but you would like to have this recipe for another number
-%^^A (e.g. only for two). Using labels you can write your recipes and change
-%^^A the number of persons they are for. There are also two commands helping:
-%
-%^^A To change your recipe \emph{from} a specific number of persons (e.g. 4)
-%^^A \emph{to} another number of persons (e.g. 3) the following commands will
-%^^A prove helpfull:
%
% What if you don't want to change units, but the amounts of the recipe because
% you cook not for 4 persons, but for 2 and don't like to do the math?
% Simple, use the following commands:
%
% \begin{itemize}
-% \item \mycs{culabel} \marg{label} \marg{number of persons}
-% \item \mycs{curef} \marg{label}
+% \item \mycs{culabel}\marg{label}\marg{number of persons}
+% \item \mycs{curef}\marg{label}
% \end{itemize}
%
-%^^A The first one is the important one: With its help you can define a \meta{label}
-%^^A which tells this package that the recipe is originally for \meta{number of persons}
-%^^A persons. This \meta{label} is then available for the commands introduced in
-%^^A \vref{sec:commands} to be used.
%
% The first one is the important one: It defines a \meta{label} for a recipe
% which is initially for \meta{number of persons}. Afterwards \meta{label}
-% can be used to tell the commands from \vref{sec:commands} that the given
-% amounts are for \meta{number of persons} people.
+% can be used to tell the commands from \cref{sec:commands} that the given
+% amounts are for \meta{number of persons}.
% Each \meta{label} must be unique and an error is raised if a \meta{label}
% is already defined.
%
% If you would like to print the number of persons this recipe is for, use
-% \mycs{curef}.
-%^^A \mycs{curef} does print the number of people the recipe (\meta{label}) is for.
+% \mycs{curef}, which is fully expandable.
%
% The following example uses \mycs{culabel} to specify that the recipe is
% initially intended for 2 persons:
@@ -748,7 +911,7 @@ and the derived file cooking-units.sty.
% \cunum<recipe>{1/2}{l} & water, \\
% \cutext[ref=recipe]{10}{g} & nuts, \\
% \cuam<recipe>{2--3} & eggs, \\
-% \cunum{180}{C} & open & fire
+% \cunum{180}{C} & (\cunum[C=F]{180}{C}) & open & fire
% \end{cuexamplecode}
%
% Now with combination of the option \opt{set-number-of-persons}
@@ -768,7 +931,7 @@ and the derived file cooking-units.sty.
% \cunum<recipe>{1/2}{l} & water, \\
% \cutext[ref=recipe]{10}{g} & nuts, \\
% \cuam<recipe>{2--3} & eggs, \\
-% \cunum{180}{C} & open & fire
+% \cunum{180}{C} & & (\cunum[C=F]{180}{C}) & open & fire
% \end{cuexamplecode}
% \cusetup{recalculate-amount=false}
%
@@ -778,68 +941,124 @@ and the derived file cooking-units.sty.
%
%
%
+%
+% \section{Some Interesting options}
+%
+% This package has some options which might be of interest and to highlight them, this section exists. All options can be
+% found in \cref{sec:options}.
+%
+%
+%
+% \begin{cuinterest}{use-numerals, use-numerals-below, print-numerals}
+% As seen above, you can use the \emph{package}-option
+% \opt{use-numerals} to print integers used by \cCutext{} below
+% \opt{use-numerals-below} (13 by default) by \pkg{fmtcount}.
+% You can still decide if numerals should be printed or not with \opt{print-numerals}.
+%
+% \begin{cunote}
+% \opt{use-numerals} is a package option as it needs to load
+% \pkg{fmtcount} which is not loaded by default.
+% \end{cunote}
+%
+% \end{cuinterest}
+%
+% \begin{cuinterest}{use-phrases}
+% In (I presume) all languages there exist phrases for a given
+% amount or a number of things (think it is called \enquote{counting measurement}).
+% In German you may say instead of
+% \enquote{12}: \enquote{ein Dutzend}. Using this option you can tell this
+% package to replace predefined integers used in \mycs{cuam}
+% by phrases for the currently used language
+% (to define new ones, see \cref{sec:phrases})
+%
+% Using (for example) language \opt{ngerman} (or \opt{naustrian}, etc.) with
+% package option \opt{use-phrases=true} gives:
+% \begin{myde}
+% \begin{cuexamplecode}
+% \cusetup{use-phrases=true} @
+% \cuam{12} \\
+% \cuam{24} \\
+% \cuam{12--24} \\
+% \cuam{12--13} \\
+% \cuam{18} \\
+% \cuam{60}
+% \end{cuexamplecode}
+% \end{myde}
+% This of course also works with the \emph{package}-option \opt{use-numerals}:
+% \begin{myde}
+% \cusetup{print-numerals=true}
+% \begin{cuexamplecode}
+% \cusetup{use-phrases=true} @
+% \cuam{12} \\
+% \cuam{24} \\
+% \cuam{12--24} \\
+% \cuam{12--13} \\
+% \cuam{18} \\
+% \cuam{60}
+% \end{cuexamplecode}
+% \end{myde}
+%
+%
+% \begin{cunote}
+% Currently only the lower-case variant for \opt{use-numerals} is
+% supported. Furthermore this feature is only available for \mycs{cuam}.
+% \end{cunote}
+%
+%
+% \end{cuinterest}
+%
+%
% \section{Predefined units \& some notes}
% \label{sec:pred-units}
%
-% In \vref{tab:def-units} and \vref{tab:some-more-units} you can find all predefined units.
-% In \vref{sec:Translations} all available translations are listed.
-%
-% I now \emph{did} include a separate key for \enquote{Messerspitze} (Msp.)
-% and therefore separated \enquote{Pinch} (pn) and \enquote{Messerspitze} (Msp.).
-% My biggest problems with the units given in \vref{tab:some-more-units} is
-% that they may only exist in one language (or country)
-% and therefore do not exist in another language (I think for example that
-% knife point \enquote{Messerspitze} doesn't exist in english) so translating
-% them would be difficult. Therefore use units known to you and if there are
-% unsupported units or languages feel free to write (see \vref{sec:bug-feed}
-% for more details).
-%^^A I did not include a separate key for \enquote{Prise} (pinch), but you can use
-%^^A \texttt{Msp} (Messerspitze) and modify it to fit your
-%^^A purpose\footnote{See \vref{sec:language}.}.
-%^^A In other languages the nearest equivalent of \enquote{Messerspitze} is
-%^^A \enquote{pinch} which I used.
+% \begin{comment}
+% In \cref{tab:def-units} and \cref{tab:some-more-units} (and \cref{tab:strange-units})
+% you can find
+% all predefined units. In \cref{sec:Translations} all translations available
+% are listed.
+% \end{comment}
+%
+% In \cref{tab:def-units} and you can find all predefined units which can be
+% transformed into each other (sorted by group). Other predefined units
+% (which cannot be used for transformation) are shown in \cref{tab:some-more-units}.
+% \Cref{tab:strange-units} pretty much exists just for fun.
%
%
% \begin{table}[htbp]
% \centering
-% \caption{List of predefined unit-keys.
-% The \enquote{symbol} column is language dependent. Note that \enquote{electron
-% volt} exists just for fun.}
-% \begin{tabular}{ lll }
-% \toprule
-% unitname & unit-key & symbol \\ \midrule
-% \PrintUnit {kg} \\
-% \PrintUnit {dag} \\
-% \PrintUnit {g} \\
-% \PrintUnit {oz} \\
-% \PrintUnit {lb} \\ \addlinespace
-%
-% \PrintUnit {C} \\
-% \PrintUnit {F} \\
-% \PrintUnit {Re} \\
-% \PrintUnit {K} \\ \addlinespace
-%
-% \PrintUnit {d} \\
-% \PrintUnit {h} \\
-% \PrintUnit {min} \\
-% \PrintUnit {s} \\ \addlinespace
-%
-% \PrintUnit {m} \\
-% \PrintUnit {dm} \\
-% \PrintUnit {cm} \\
-% \PrintUnit {mm} \\
-% \PrintUnit {in} \\ \addlinespace
-%
-% \PrintUnit {l} \\
-% \PrintUnit {dl} \\
-% \PrintUnit {cl} \\
-% \PrintUnit {ml} \\ \addlinespace
-%
-% \PrintUnit {cal} \\
-% \PrintUnit {kcal} \\
-% \PrintUnit {J} \\
-% \PrintUnit {kJ} \\
-% \PrintUnit {eV}
+% \caption{^^A
+%^^A The first column shows a list of predefined unit-keys.
+%^^A The column \enquote{default} shows the abbreviation used if
+%^^A for given language no translation is defined. The translations used for \cCutext\
+%^^A are shown in \cref{sec:Translations}.
+%^^A Note that \enquote{electron volt} exists just for fun.
+%^^A
+% This table shows all units which can be transformed into each other, sorted
+% by group. The columns \enquote{default} show the abbreviations used if
+% for given language no translation is defined. The translations used for \cCutext\
+% are shown in \cref{sec:Translations}.
+% Note that \enquote{electron volt} exists just for fun.
+% }
+% \begin{tabular}{ lll @{\hspace{1cm}} lll }
+% \toprule
+% description & key & default & description & key & default \\ \midrule
+% \PrintUnit {kg} & \PrintUnit{m} \\
+% \PrintUnit {dag} & \PrintUnit{dm} \\
+% \PrintUnit {g} & \PrintUnit{cm} \\
+% \PrintUnit {oz} & \PrintUnit{mm} \\
+% \PrintUnit {lb} & \PrintUnit{in} \\
+% \PrintUnit [ (of butter)] {stick} \\ \addlinespace
+%
+% \PrintUnit {d} & \PrintUnit {l} \\
+% \PrintUnit {h} & \PrintUnit {dl} \\
+% \PrintUnit {min} & \PrintUnit {cl} \\
+% \PrintUnit {s} & \PrintUnit{ml} \\ \addlinespace
+%
+% \PrintUnit{cal} & \PrintUnit{C} \\
+% \PrintUnit{kcal} & \PrintUnit{F} \\
+% \PrintUnit{J} & \PrintUnit{Re} \\
+% \PrintUnit{kJ} & \PrintUnit{K} \\
+% \PrintUnit{eV}
%
% \\ \bottomrule
% \end{tabular}
@@ -848,20 +1067,22 @@ and the derived file cooking-units.sty.
%
% \begin{table}[htbp]
% \centering
-% \caption{A (not only) spoonful of (more or less) country and language dependent units.
-% Please note that sometimes a translation is nearly impossible as a unit
-% (e.g. \enquote{saltspoonful}) may not exist in another language
-% (like german; at least I never heard of it). So please only use units known to you.}
+% \caption{A (not only) spoonful of (more or less) country and
+% language dependent units. Please note that sometimes a
+% translation is nearly impossible as a unit
+% (e.g. \enquote{saltspoonful}) may not exist in another language
+% (like german; at least I never heard of it). So please only use
+% units known to you.}
% \begin{tabular}{ lll }
% \toprule
-% unitname & unit-key & symbol \\ \midrule
+% description & key & symbol \\ \midrule
% \PrintUnit {pn} \\ \addlinespace
% \PrintUnit {EL} \\
% \PrintUnit {TL} \\
% \PrintUnit {dsp} \\
% \PrintUnit {csp} \\
% \PrintUnit {ssp} \\ \addlinespace
-% \PrintUnit {Msp} \\
+% \PrintUnit [Messerpsitze (point of a knife)] {Msp} \\
% \bottomrule
% \end{tabular}
% \label{tab:some-more-units}
@@ -869,8 +1090,8 @@ and the derived file cooking-units.sty.
%
% \begin{table}[htbp]
% \centering
-% \caption{List of nonsense units (exist just for fun, there will
-% be no support for those units). }
+% \caption{List of (not really) nonsense units (exist just for fun, there will be
+% no support for those units; unless -- of course -- you really want it).}
% \begin{tabular}{ ll }
% \toprule
% unit-key & symbol \\ \midrule
@@ -880,7 +1101,7 @@ and the derived file cooking-units.sty.
% \PrintUnitSymbol {(chbareV-1)3} \\
% \bottomrule
% \end{tabular}
-% \label{tab:def-units}
+% \label{tab:strange-units}
% \end{table}
%
%
@@ -888,52 +1109,58 @@ and the derived file cooking-units.sty.
% \section{Defining units}
% \label{sec:def-units}
%
-% New units can be defined using \lstinline|\declarecookingunit|,
-% \lstinline|\newcookingunit| and \lstinline|\providecookingunit|:
+% New units can be defined using \mycs{declarecookingunit},
+% \mycs{newcookingunit} and \mycs{providecookingunit}:
%
% \begin{function}{\declarecookingunit,\newcookingunit,\providecookingunit}
% \begin{syntax}
-% \lstinline|\declarecookingunit|\oarg{symbol}\marg{unit-key}
-% \lstinline|\newcookingunit|\oarg{symbol}\marg{new-unit-key}
-% \lstinline|\providecookingunit|\oarg{symbol}\marg{new-unit-key}
+% \mycs{declarecookingunit}\oarg{symbol}\marg{unit-key}
+% \mycs{newcookingunit}\oarg{symbol}\marg{new-unit-key}
+% \mycs{providecookingunit}\oarg{symbol}\marg{new-unit-key}
% \end{syntax}
% These commands define the unit \meta{unit-key}. If the
% key is not the same as the printed symbol use \oarg{symbol}.
+% Note that \meta{unit-key} should neither contain |/| nor |,|.
%
% \mycs{newcookingunit} raises an error if the unit is already defined,
-% \mycs{declarecookingunit} overwrites \meta{symbol} (if given)
+% \mycs{declarecookingunit} creates or (if given) overwrites \meta{symbol}
% and \mycs{providecookingunit} does nothing if the unit is already
-% defined.
+% defined.
%
-% Some examples (note: the definition of the printed degree Celsius is
-% directly copied \& pasted from [a maybe older version of] \pkg{siunitx}):
+% All units have male gender |m| by default.
+%
+% Some examples:
+%
+% \begin{lstlisting}
+% \declarecookingunit{kg}
+% \declarecookingunit{g}
+% \declarecookingunit[Msp.] {Msp}
+% \declarecookingunit[\ensuremath{{}^{\circ}}\kern-\scriptspace C] {C}
+% \end{lstlisting}
+%
+% \begin{cunote}
+% The definition of the printed degree Celsius is
+% directly copied and pasted from (a maybe older version of) \pkg{siunitx}
+% \end{cunote}
%
-% \begin{center}
-% \begin{tabular}{ll}
-% \lstinline|\declarecookingunit{kg}| \\
-% \lstinline|\declarecookingunit{g}| \\
-% \lstinline|\declarecookingunit[Msp.] {Msp}| \\
-% \lstinline|\declarecookingunit[\ensuremath{{}^{\circ}}\kern-\scriptspace C] {C} |
-% \end{tabular}
-% \end{center}
%
% \end{function}
%
%
-% \section{Defining options}
+% \section{Defining options to change units}
% \label{sec:defining-opt}
%
-% Options (to change units) can be newly defined or added to already existing keys
+% Options (to change units) can be newly defined or added to already existing keys (units)
% using
% \begin{itemize}
-% \item \lstinline|\cudefinekeys|
-% \item \lstinline|\cudefinesinglekey|
-% \item \lstinline|\cuaddkeys|
-% \item \lstinline|\cuaddsinglekeys|
-% \item \lstinline|\cuaddtokeys|
+% \item \mycs{cudefinekeys}
+% \item \mycs{cudefinesinglekey}
+% \item \mycs{cuaddkeys}
+% \item \mycs{cuaddsinglekeys}
+% \item \mycs{cuaddtokeys}
% \end{itemize}
-% I apologize for the inconsistency between \lstinline|\cudefinekeys| and
-% \lstinline|\cudefinesinglekey|.
+% I apologize for the (name) inconsistency between \mycs{cudefinekeys} and
+% \mycs{cudefinesinglekey} (although they are named similarly they work different).
%
% \begin{function}{\cudefinekeys,\cudefinesinglekey}
% \begin{syntax}
@@ -953,24 +1180,27 @@ and the derived file cooking-units.sty.
% \ \ \}
% \end{syntax}
%
-% If you define new units (see \vref{sec:def-units}) and cannot add
-% them to already existing keys you can use \lstinline|\cudefinekeys| bzw.
-% \lstinline|\cudefinesinglekey| to define new keys.
-%
-% \lstinline|\cudefinekeys| takes the \marg{unit-key-1} as a \enquote{basis},
-% defines a key with the name \meta{unit-key-1} and adds the values
-% \meta{unit-key-1}, \meta{unit-key-2}, \meta{unit-key-3}, etc. Furthermore
-% this command also defines the keys \meta{unit-key-2}, \meta{unit-key-3}, etc.
-% with the same values as \meta{unit-key-1}. Please note that \meta{\dots} has to
-% be a number. ^^A Those keys are linked to each other.
+% If you define new units (see \cref{sec:def-units}) and cannot add
+% them to already existing keys you can use
+% \lstinline|\cudefinekeys| bzw. \lstinline|\cudefinesinglekey| to
+% define new keys.
+%
+% \lstinline|\cudefinekeys| takes \marg{unit-key-1} as a
+% \enquote{basis}, defines a key with the name \meta{unit-key-1} and
+% adds the values \meta{unit-key-1}, \meta{unit-key-2},
+% \meta{unit-key-3}, etc. Furthermore this command also defines the
+% keys \meta{unit-key-2}, \meta{unit-key-3}, etc. with the same
+% values as \meta{unit-key-1}. Please note that \meta{\dots} has to
+% be a number.
%
-% Sometimes it is not that easy and the conversion of one unit into another
-% needs are more complicated formula (see for example temperatures).
-% If that is the case use \lstinline|\cudefinesinglekey|. As the name says it
-% defines \emph{only} the key \meta{unit-key-1} with the values \meta{unit-key-1},
-% \meta{unit-key-2}, etc. The advantage of this command is that now
-% \meta{\dots} can be a formula and the numerical input can be placed explicitly
-% using \texttt{\#1}.
+% Sometimes it is not that easy and the conversion of one unit into
+% another needs are more complicated formula (see for example
+% temperatures). If that is the case use
+% \lstinline|\cudefinesinglekey|. As the name says it defines
+% \emph{only} the key \meta{unit-key-1} with the values
+% \meta{unit-key-1}, \meta{unit-key-2}, etc. The advantage of this
+% command is that now \meta{\dots} can be a formula and the
+% numerical input can be placed explicitly using \texttt{\#1}.
%
%
% \end{function}
@@ -979,12 +1209,17 @@ and the derived file cooking-units.sty.
%
% This example defines following keys with their respective value:
% \begin{itemize}
-% \item the key \texttt{kg} with the values \texttt{kg}, \texttt{dag}, \texttt{g} and \texttt{oz}
-% \item the key \texttt{dag} with the values \texttt{kg}, \texttt{dag}, \texttt{g} and \texttt{oz}
-% \item the key \texttt{g} with the values \texttt{kg}, \texttt{dag}, \texttt{g} and \texttt{oz}
-% \item the key \texttt{oz} with the values \texttt{kg}, \texttt{dag}, \texttt{g} and \texttt{oz}
-% \item the key \texttt{d} with the values \texttt{d}, \texttt{h}, \texttt{min} and \texttt{s}
-% \item \dots
+% \item the key \texttt{kg} with the values \texttt{kg}, \texttt{dag},
+% \texttt{g} and \texttt{oz}
+% \item the key \texttt{dag} with the values \texttt{kg},
+% \texttt{dag}, \texttt{g} and \texttt{oz}
+% \item the key \texttt{g} with the values \texttt{kg}, \texttt{dag},
+% \texttt{g} and \texttt{oz}
+% \item the key \texttt{oz} with the values \texttt{kg}, \texttt{dag},
+% \texttt{g} and \texttt{oz}
+% \item the key \texttt{d} with the values \texttt{d}, \texttt{h},
+% \texttt{min} and \texttt{s}
+% \item \dots
% \end{itemize}
%
%
@@ -1014,16 +1249,16 @@ and the derived file cooking-units.sty.
% \end{lstlisting}
%
% To convert degree Fahrenheit to degree Celsius, kelvin and degree R\'eamur one
-% needs the formulas
+% needs the formulas\footnote{See Wikipedia.}
% \begin{align*}
% T_C &= ( T_F - 32 ) \cdot \frac{5}{9} \\
% T_K &= ( T_F - 459.67 ) \cdot \frac{5}{9} \\
% T_{Re} &= ( T_F - 32 ) \cdot \frac{4}{9}
% \end{align*}
-% with $T_F$ being the input temperature in degree Fahrenheit and
-% $T_C$ being the same temperature in degree Celsius, etc. Using
-% \lstinline|\cudefinesinglekey| the key \texttt{F} and the values \texttt{C}, \texttt{K} and \texttt{Re}
-% are defined:
+% with $T_F$ being the input temperature in degree Fahrenheit and
+% $T_C$ being the same temperature in degree Celsius, etc. Using
+% \lstinline|\cudefinesinglekey| the key \texttt{F} with values
+% \texttt{C}, \texttt{K} and \texttt{Re} is defined:
%
% \begin{lstlisting}
% \cudefinesinglekey {F}
@@ -1083,16 +1318,17 @@ and the derived file cooking-units.sty.
%
%
% \begin{cuexample}
-% Suppose you are British (I am sorry, I can't think of another
-% reason to use those units) and you want to implement 'stone' (yes, I
-% was surprised myself that such a unit exists, but it even appears in
-% a Sherlock-Holmes story). You exactly know that \SI{1}{\st} equals
-% \SI{14}{\lb}, well \dots\ now you have two
-% choices. \lstinline|\cuaddkeys| or \lstinline|\cuaddtokeys| (use the
-% one best fitting). This example uses the first, the next the latter one.
+% Suppose you are British (I am sorry, I can't think of another
+% reason to use those units) and you want to implement 'stone' (yes,
+% I was surprised myself that such a unit exists, but it even
+% appears in a Sherlock Holmes story). You exactly know that
+% \SI{1}{\st} equals \SI{14}{\lb}, well \dots\ now you have two
+% choices. \lstinline|\cuaddkeys| or \lstinline|\cuaddtokeys| (use
+% the one best fitting). This example uses the first, the next the
+% latter one.
% \begin{lstlisting}
-% \newcookingunit {st} %% defining new unit 'stone'
-% \cuaddkeys {lb} %% adding st to lb (could also add to kg, dag and oz)
+% \newcookingunit{st} %% defining new unit 'stone'
+% \cuaddkeys{lb} %% adding st to lb (could also add to kg, dag and oz)
% {
% {st} { 1/14 } %% 1 lb are 1/14 st as 14 lb are 1 st
% }
@@ -1109,10 +1345,10 @@ and the derived file cooking-units.sty.
%
%
% \begin{cuexample}
-% Now you want to add degree R{\o}mer and convert
-% Celsius to degree R{\o}mer:
+% Now you want to add degree R{\o}mer and convert Celsius to degree
+% R{\o}mer:
% \begin{equation*}
-% T_{R\o} = T_C * \frac{21}{40} + 7.5
+% T_{R\text\o} = T_C * \frac{21}{40} + 7.5
% \end{equation*}
%
% \begin{lstlisting}
@@ -1153,7 +1389,7 @@ and the derived file cooking-units.sty.
% \begin{cuexample}
% Continuing the example from before, this time with \lstinline|\cuaddtokeys|:
% \begin{lstlisting}
-% \newcookingunit {st} %% defining (again) new unit 'stone'
+% \newcookingunit{st} %% defining (again) new unit 'stone'
% \cuaddtokeys {lb} {st} { 14 } %% 1 st are 14 lb
% \end{lstlisting}
% \begin{cuexamplecode}
@@ -1166,30 +1402,59 @@ and the derived file cooking-units.sty.
% \end{cuexamplecode}
% \end{cuexample}
%
+% \begin{comment}
+% \begin{cuexample}
+% Implementation of \texttt{stick}. From https://cooking.stackexchange.com/questions/784/translating-cooking-terms-between-us-uk-au-ca-nz
+% we know that
+% \[ \SI{1}{\stick} = \SI{0.25}{\lb} \]
+%
+% There are two ways to implement \texttt{stick}:
+% either use \mycs{cuaddkeys} or \mycs{cuaddtokeys}.
+%
+% The easier way (in this case) is \mycs{cuaddtokeys} which is pretty straight forward:
+% \begin{lstlisting}
+% \cuaddtokeys { lb } { st } { 0.25 }
+% \end{lstlisting}
+% \dots\ and finished
+%
+% \end{cuexample}
+% \end{comment}
+%
+%
+%
+%
+%
+%
+%
+%
+%
+%
+%
+%
%
%
% \section{Language support}
% \label{sec:language}
%
-% The unit-names and symbols depend on the language. To change the
+% Unit names and symbols depend on the language. To change the
% name depending on the language you can use \lstinline|\cudefinename|
% and to only change symbols use \lstinline|\cudefinesymbol|.
%
% \begin{function}{decimal-mark, one(m),one(f),one(n)}
% Those are special keys (as they cannot be used as units). Not only
-% are printed units language depending, but as is the decimal
-% mark (\enquote{.} or \enquote{,}). To set the decimal mark use
+% are printed units language depending, but as is the decimal mark
+% (\enquote{.} or \enquote{,}). To set the decimal mark use
% \opt{decimal-mark} (see examples below).
%
-% Furthermore if you are using the package-option \opt{use-numerals} you may
-% also use the keys \opt{one(m)}, \opt{one(f)} and \opt{one(n)}. If
-% you use this option, integers below a certain value (see option
-% \opt{use-numerals-below}) are written-out. The only problem is
-% the written-out \enquote{1} mostly depends on the gender of the
-% following word (e.g. \enquote{ein Baum} (m),
+% Furthermore if you are using the package-option \opt{use-numerals}
+% you may also use the keys \opt{one(m)}, \opt{one(f)} and
+% \opt{one(n)}. If you use this option, integers below a certain
+% value (see option \opt{use-numerals-below}) are written-out. The
+% only problem is the written-out \enquote{1} mostly depends on the
+% gender of the following word (e.g. \enquote{ein Baum} (m),
% \enquote{eine Pflanze} (f) and \enquote{ein Auto} (n)). To set the
% written-out 1 to be correct with the gender of the used unit, use
-% this key (see also examples below)
+% these keys (see also examples below)
% \end{function}
%
% \begin{function}{\cudefinename}
@@ -1203,14 +1468,14 @@ and the derived file cooking-units.sty.
% \end{syntax}
%
% This command defines the names (and optionally the symbol) of the
-% commands printed in \lstinline|\cutext| and \lstinline|\Cutext|
+% units printed in \lstinline|\cutext| and \lstinline|\Cutext|
% (and \lstinline|\cunum| regarding the symbol) for the specific
% \meta{Language}. For details regarding \meta{language} see the
-% \pkg{translator}-documentation.
+% \pkg{translations} documentation.
%
% If the plural form of the name differs from the singular form use
% \oarg{plural} to specify the plural form, if no \oarg{plural} is
-% given the plural will be set equal to its singular. The singular
+% given the plural will be set equal to its singular. The singular form
% is only used if the number in \lstinline|\cutext| and
% \lstinline|\Cutext| is equal to 1.
%
@@ -1224,7 +1489,7 @@ and the derived file cooking-units.sty.
% {kg} {kilogramme}
% {oz} {ounce}
% {h} {hour} [hours]
-% {C} {degree \space Celsius} [degrees \space Celsius]
+% {C} {degree\space Celsius} [degrees\space Celsius]
% {decimal-marker} {.}
% {one(m)} {one}
% {one(f)} {one}
@@ -1262,10 +1527,8 @@ and the derived file cooking-units.sty.
% \lstinline|\cunum| for the specific \meta{language}. It works
% similar as \lstinline|\cudefinename|, but only the symbols (and no
% names) can be set. For details regarding \meta{language} see
-% the \pkg{translator}-documentation.
+% the \pkg{translations} documentation.
%
-%^^A A special key is the \texttt{decimal-mark}. It defines the symbol
-%^^A printed for the decimal-marker.
% \end{function}
%
%
@@ -1297,6 +1560,111 @@ and the derived file cooking-units.sty.
% }
% \end{lstlisting}
%
+% \begin{cuexample}
+% Imagine that instead of the abbreviation \enquote{dag} for \enquote{decagramme}
+% you want to use \enquote{ducks} (because \dots\ I don't know). You can easily
+% do this via
+% \begin{lstlisting}
+% \cudefinesymbol {English}
+% {
+% {dag} {ducks}
+% }
+% \end{lstlisting}
+% \cudefinesymbol {English}
+% {
+% {dag} {ducks}
+% }
+% As you can see it may be a bit suboptimal as there is no plural version allowed.
+% You do it anyway and end up with:
+% \begin{cuexamplecode}
+% \cunum{12}{dag} & weed\\
+% \cunum{3}{dag} & nuts\\
+% \cunum{10}{dag} & duckmeat
+% \end{cuexamplecode}
+%
+%
+% \end{cuexample}
+%
+%
+%
+%
+%
+%
+% \subsection{Phrases}
+% \label{sec:phrases}
+%
+% Each language has synonyms for certain (integer) numbers. This package
+% supports those phrases and they can be implemented with the following
+% command and used by \mycs{cuam}:
+%
+% \begin{function}{\cudefinephrase}
+% \begin{syntax}
+% \mycs{cudefinesymbol}\marg{Language}
+% \ \ \{
+% \ \marg{integer-1} \marg{phrase-1} \oarg{phrase-1-plural} \meta{gender-1}
+% \ \marg{integer-2} * \marg{phrase-2} \oarg{phrase-2-plural} \meta{gender-2}
+% \ \dots
+% \ \ \}
+% \end{syntax}
+%
+% This command pairs for a given \marg{Language} the number \marg{integer-1}
+% with \marg{phrase-1} (plural and gender). The package then checks if the amount
+% given in \mycs{cuam} is either this number or a \emph{multiple} of it.
+%
+% If the behavior of checking for a multiple is not wanted, you can use the optional
+% star \texttt{*} for a given \marg{integer}
+%
+% \meta{gender} can be \opt{m}, \opt{f} or \opt{n}. It is \opt{m} by default.
+%
+% Afterwards the numbers are ordered from highest to lowest so that
+% the phrase with the highest number is used (if used at all).
+%
+% Furthermore, it chooses star (|*|) phrases over non-star phrases.
+%
+% \begin{cunote}
+% Numbers with the optional star |*| are stored as negative numbers.
+% \end{cunote}
+% \end{function}
+%
+% \begin{cuexample}
+% The following example creates some phrases for the language
+% \enquote{German}:
+%
+% \cudefinephrase {German}
+% {
+% { 60 } {Schock} <n>
+% { 6 }* {halbes\ Dutzend} <n>
+% }
+%
+%
+% \begin{lstlisting}
+% \cudefinephrase {German}
+% {
+% { 12 } {Dutzend} <n> %% implemented by default
+% { 60 } {Schock} <n>
+% { 6 }* {halbes\ Dutzend} <n>
+% }
+% \end{lstlisting}
+% Let's just use them (activating the german language):
+% \begin{myde}
+% \begin{cuexamplecode}
+% \cusetup{use-phrases=true} @
+% \cuam{12} \\
+% \cuam{24} \\
+% \cuam{60} \\
+% \cuam{120} \\
+% \cuam{6} \\
+% \cuam{18}
+% \end{cuexamplecode}
+% \end{myde}
+%
+% As you can see, \enquote{Schock} ($60$) is preferred over \enquote{Dutzend} ($12$)
+% as it linked to the higher number. Furthermore, for $6$ the phrase \enquote{halbes
+% Dutzend} (half a dozen) is used, but because it is a star version it is \emph{not}
+% used for $18$.
+%
+% \end{cuexample}
+%
%
% \section{Options}
% \label{sec:options}
@@ -1304,7 +1672,7 @@ and the derived file cooking-units.sty.
% Options in \pkg{cooking-units} can mostly be set globally using
% \lstinline|\cusetup| or locally using the optional argument of the
% respective command (but \emph{not} as a package option). The only
-% exception is the option given in \vref{sec:load-time-options} which
+% exception is the option given in \cref{sec:load-time-options} which
% needs to be used as a package option.
%
% \subsection{Load time options}
@@ -1316,33 +1684,47 @@ and the derived file cooking-units.sty.
% \end{syntax}
% If set to \true\ loads package \pkg{fmtcount} and uses
% \cs{numberstringnum} for \mycs{cutext}
-% and \cs{Numberstringnum} for \mycs{Cutext} to write-out numbers below
+% and \cs{Numberstringnum} for \mycs{Cutext} to write-out numbers below
% \opt{use-numerals-below} (13 by default), integers above are
-% printed as numbers. Please note the keys \opt{one(m)}, \opt{one(f)}
+% printed as numbers.
+% You can decide to not print any numerals by setting \opt{print-numerals}
+% to \false.
+%
+% \begin{cunote}
+% \opt{use-numerals} is a package option as it needs to load
+% \pkg{fmtcount} which is not loaded by default.
+% \end{cunote}
+%
+% \begin{cunote}
+% Please note the keys \opt{one(m)}, \opt{one(f)}
% and \opt{one(n)} to change the printed \enquote{one} (as
% \enquote{one} is in many languages dependent on the gender of the
% following word. E.g in German: Masculine: ein Baum,
% Feminin: eine Pflanze, Neutrum: ein Auto).
+% \end{cunote}
+%
% \end{function}
%
-% \cusetup{use-numerals-below=13}
+% \cusetup{print-numerals=true}
% \begin{cuexamplecode}
% \cutext{1}{kg} \\
% \Cutext{1}{kg} \\
% \cutext{2}{kg} \\
% \Cutext{2}{kg} \\
+% \cutext{12}{kg} \\
+% \cutext{13}{kg} \\
% \cutext{13}{kg} \\
% \Cutext{14}{kg}
% \end{cuexamplecode}
-% \cusetup{use-numerals-below=0}
+% \cusetup{print-numerals=false}
%
% \subsection{Normal options}
%
-% This option can only be set as local options or using
+% Options in this subsection can only be set as local options or using
% \lstinline|\cusetup|, but \emph{not} as load time options.
%
% \begin{function}{\cusetup}
-% Options can be set globally using \lstinline|\cusetup|.
+% Options can be set using \mycs{cusetup}\Arg{options}.
% \end{function}
%
% \subsubsection{Unit Specific options}
@@ -1351,8 +1733,8 @@ and the derived file cooking-units.sty.
% \begin{syntax}
% \meta{unit-key-1} = \meta{unit-key-2}
% \end{syntax}
-% Convert units from \meta{unit-key-1} to \meta{unit-key-2} (see
-% \vref{sec:defining-opt} to define new options).
+% Change unit \meta{unit-key-1} to \meta{unit-key-2} (see
+% \cref{sec:defining-opt} to define new options).
% \end{function}
%
% \begin{function}{set-option-for-<unit-key>,add-option-for-<unit-key>,erase-all-options}
@@ -1361,10 +1743,8 @@ and the derived file cooking-units.sty.
% add-option-for-\meta{unit-key} = \meta{key1=value1,\dots}
% erase-all-options
% \end{syntax}
-% Sets and adds \meta{key1=value1,\dots}, for a specific
-% \meta{unit-key}
-% ^^A with
-% ^^A options being a comma-separated list of \texttt{key=value}.
+% Sets and adds \meta{key1=value1,\dots} to a specific
+% \meta{unit-key},
% \texttt{erase-all-options} is used to erase all options for all
% \meta{unit-key}s.
%
@@ -1416,23 +1796,13 @@ and the derived file cooking-units.sty.
% \cutext[kg=g]{1--2}{kg}
% \end{cuexamplecode}
%
-% \begin{function}{cuam-version,cutext-version}
-% \begin{syntax}
-% cuam-version = \meta{old/new}
-% cutext-version = \meta{old/new}
-% \end{syntax}
-% Since v1.10 this package also parses and checks the input of \cCutext\ and
-% \mycs{cuam}. If you want to restore the old behavior, set this option to \opt{old},
-% but note that then you can neither change the amounts for a given number of persons
-% nor change the unit of \cCutext. Both of them are set to \opt{new} by default.
-% \end{function}
%
% \begin{function}{cutext-change-unit}
% \begin{syntax}
% cutext-change-unit = \meta{true/false}
% \end{syntax}
% Set this option to \opt{true} if you do \emph{not} want the units of \cCutext\
-% to be changed.
+% to be changed. Set to \true\ by default
% \end{function}
% \begin{cuexamplecode}
% \cutext[kg=g]{1}{kg} \\
@@ -1444,8 +1814,20 @@ and the derived file cooking-units.sty.
% \cutext[kg=g]{1--2}{kg}
% \end{cuexamplecode}
%
+% \begin{function}{cuam-version,cutext-version}
+% \begin{syntax}
+% cuam-version = \meta{old/new}
+% cutext-version = \meta{old/new}
+% \end{syntax}
+% Since v1.10 this package also parses and checks the input of
+% \cCutext\ and \mycs{cuam}. If you want to restore the old
+% behavior, set this option to \opt{old}, but note that then you can
+% neither change the amounts for a given number of persons nor
+% change the unit of \cCutext. Both of them are set to \opt{new} by
+% default.
+% \end{function}
%
-% \subsubsection{Input and signs}
+% \subsubsection{Input and Outputs}
%
% \begin{function}{set-special-sign,add-special-sign}
% \begin{syntax}
@@ -1453,8 +1835,9 @@ and the derived file cooking-units.sty.
% add-special-sign = \meta{character(s)}
% \end{syntax}
% Allows \meta{character(s)} to be used in the first mandatory argument of
-% \lstinline!\cunum! without raising an error (you can customize this
-% behavior, see \opt{set-unknown-message}). By default it is set to \texttt{?}.
+% \mycs{cunum}, \mycs{cuam}, \cCutext{} without raising an error (you can customize this
+% behavior, see \opt{set-unknown-message}). By default it is set to |?|.
+% Please note that the sign |<| is not allowed as a special sign.
% \end{function}
%
% \begin{cuexamplecode}
@@ -1473,22 +1856,56 @@ and the derived file cooking-units.sty.
% set-unknown-message = \meta{error/warning/none}
% \end{syntax}
% Using a special sign (\texttt{?} by default) causes a warning to
-% be raised. Set this option to \opt{error} if you want an error
-% (as an extra emphasis), \opt{warning} if you want a warning
-% (default) and \opt{none} if you don't want to know anything about it.
+% be raised. Set this option to \opt{error} if you want an error (as
+% an extra emphasis), \opt{warning} if you want a warning (default)
+% and \opt{none} if you don't want to know anything about it.
% \end{function}
%
+% \begin{function}{set-cutext-translation-message}
+% \begin{syntax}
+% set-cutext-translation-message = \meta{error/warning/none}
+% \end{syntax}
+% If a translation for \cCutext\ is not available the commands are replaced
+% by \mycs{cunum}. Currently -- if this is happening -- a warning is shown,
+% you may change the behavior of the message (error, warning or not showing at all)
+% using this option.
+% \end{function}
+%
+% \begin{function}{print-numerals}
+% \begin{syntax}
+% print-numerals = \meta{true/false}
+% \end{syntax}
+% If the package option \opt{use-numerals} is set to \true\ you can
+% deactivate the printing of numerals by setting \opt{print-numerals} to
+% \false\ and activate them by setting it to \true.
+%
+% Note that this option is automatically set to \opt{true} if \opt{use-numerals} is used.
+% \end{function}
+% \cusetup{ print-numerals=true }
+% \begin{cuexamplecode}
+% \cutext{1}{kg} \\
+% \cutext{2}{kg} \\
+% \cutext{12}{kg} \\
+% \cutext{13}{kg} \\
+% \cusetup{ print-numerals=false } @
+% \cutext{1}{kg} \\
+% \cutext{2}{kg} \\
+% \cutext{12}{kg} \\
+% \cutext{13}{kg} \\
+% \end{cuexamplecode}
+% \cusetup{ print-numerals=false }
%
% \begin{function}{use-numerals-below}
% \begin{syntax}
% use-numerals-below = \meta{integer}
% \end{syntax}
-% Only usable if the package option \opt{use-numerals} is active. Prints the name of
-% the numbers for integers used in \mycs{cutext} and \mycs{Cutext}
-% smaller than \meta{integer}. \meta{integer} is by default
-% 13. Package pkg{fmtcount} is used for this purpose.
+% Only usable if the package option \opt{use-numerals} is
+% active. Prints the name of the numbers for integers used in
+% \mycs{cutext} and \mycs{Cutext} smaller than
+% \meta{integer}. \meta{integer} is by default 13. Package
+% \pkg{fmtcount} is used for this purpose.
% \end{function}
-% \cusetup{ use-numerals-below=13 }
+% \cusetup{ print-numerals=true }
% \begin{cuexamplecode}
% \cutext{1}{kg} \\
% \cutext{2}{kg} \\
@@ -1508,18 +1925,19 @@ and the derived file cooking-units.sty.
% \cutext[kg=g]{1}{kg} \\
% \cutext[kg=g]{2}{kg} \\
% \cutext[kg=g]{12}{kg} \\
-% \cutext[kg=g]{13}{kg}
+% \cutext[kg=g]{13}{kg} \\
% \end{cuexamplecode}
-% \cusetup{ use-numerals-below=0 }
+% \cusetup{ print-numerals=false }
%
%
% \begin{function}{parse-number}
% \begin{syntax}
% parse-number = \meta{true/false}
% \end{syntax}
-% If set to \texttt{false} prints the number of \lstinline!\cunum!,
-% \lstinline!\cutext!, \lstinline!\Cutext! and \mycs{cuam}
-% as they are (after some \dots\ well \dots\ parsing due to \enquote{\lstinline|_|}). It is \texttt{true} by default.
+% If set to \texttt{false} prints the number of \lstinline!\cunum!,
+% \lstinline!\cutext!, \lstinline!\Cutext! and \mycs{cuam} as they
+% are (after some \dots\ well \dots\ parsing due to
+% \enquote{\lstinline|_|}). Is set to \texttt{true} by default.
% \end{function}
%
% \begin{cuexamplecode}
@@ -1536,6 +1954,7 @@ and the derived file cooking-units.sty.
% \cutext{1}{kg} \\
% \cutext{100}{kg} \\
% \cutext{gjfak}{kg} \\
+% \cutext[kg=g]{12}{kg} \\
% \cuam{1----------2} \\
% \cuam{1,2} \\
% \cuam{1_1/2} \\
@@ -1550,16 +1969,12 @@ and the derived file cooking-units.sty.
% cunum-range-sign = \meta{string}
% cutext-range-sign = \meta{string}
% \end{syntax}
-%^^A Sets the \emph{printed} range-sign equal to \meta{string}.
-% The second sets the \emph{printed} range-sign used in \mycs{cunum}
-% (and \mycs{cuam}) to
-% \meta{string}, the third sets the printed range-sign used in
-% \mycs{cutext}/\mycs{Cutext} to \meta{string}.
-%
-%^^A If you want to change to the same range-sign for all commands
-%^^A use the first option.
-% Use \opt{range-sign} to set the printed range-signs for both
-% \mycs{cunum} (and \mycs{cuam}) and \mycs{cutext}/\mycs{Cutext} to \meta{string}.
+% The second sets the \emph{printed} range sign used in \mycs{cunum}
+% (and \mycs{cuam}) to \meta{string}, the third sets the printed
+% range sign used in \cCutext{} to \meta{string}.
+% Using the first option sets the
+% range signs for both \mycs{cunum} (and \mycs{cuam}) and
+% \mycs{cutext}/\mycs{Cutext} to \meta{string}.
%
% The default for \meta{string} is \texttt{-{}-} (for both).
% \end{function}
@@ -1586,15 +2001,38 @@ and the derived file cooking-units.sty.
% \Cutext{1--2}{kg}
% \end{cuexamplecode}
%
+% \begin{function} {use-phrases}
+% \begin{syntax}
+% use-phrases = \meta{true/false}
+% \end{syntax}
+% Setting this option to \true\ replaces certain integers (see \cref{sec:phrases} for
+% more information) with their phrase counterpart. This option is set to \false\ by default.
+% \end{function}
+%
+% \begin{myde}
+% For the German langauge:
+% \begin{cuexamplecode}
+% \cuam{12} \\
+% \cuam{12--24} \\
+% \cuam{36} \\
+% \cusetup{use-phrases=true} @
+% \cuam{12} \\
+% \cuam{12--24} \\
+% \cuam{36} \\
+% \end{cuexamplecode}
+% \end{myde}
+%
+%
% \subsubsection{Rounding options}
%
% \begin{function}{round-precision}
% \begin{syntax}
% round-precision = \meta{integer}
% \end{syntax}
-% Rounds the amount automatically to \meta{integer} digits after the colon.
-% Note that units like \texttt{C}, \texttt{F}, \texttt{K} and \texttt{Re} are still rounded
-% to integers due to \texttt{set-option-for-<unit-key>}.
+% Rounds the amount automatically to \meta{integer} digits after the
+% colon. Note that units like \texttt{C}, \texttt{F}, \texttt{K} and
+% \texttt{Re} are still rounded to integers due to
+% \texttt{set-option-for-<unit-key>}.
% \end{function}
%
%
@@ -1613,7 +2051,18 @@ and the derived file cooking-units.sty.
% \cunum[K=C]{0.0012}{K}
% \end{cuexamplecode}
%
-%
+% \begin{comment}
+% \begin{cunote}
+% \begin{cuexamplecode}
+% \cusetup{erase-all-options} @
+% \cusetup{set-option-for-C={round-precision=-1}} @
+% \cusetup{set-option-for-kg={round-precision=-2}} @
+% \cunum{185}{kg} \\
+% \cunum[K=C]{0.0012}{K} \\
+% \cunum{185}{C}
+% \end{cuexamplecode}
+% \end{cunote}
+% \end{comment}
%
% \begin{function}{round-to-int}
% \begin{syntax}
@@ -1635,17 +2084,19 @@ and the derived file cooking-units.sty.
% \begin{syntax}
% round-half = \meta{default/commercial}
% \end{syntax}
-% This option is only important for half-way numbers (e.g. $0.005$). By setting
-% it to \opt{default} the value will be rounded to the nearest even number is chosen
-% (which is the default rounding for \pkg{expl3}, hence the name).
-% Setting it to \opt{commercial} rounds the value away from zero.
+% This option is only important for half-way numbers
+% (e.g. $0.005$). By setting it to \opt{default} the value will be
+% rounded to the nearest even number. Setting it to
+% \opt{commercial} rounds the value away from zero.
%
% It is set to \opt{default} by \dots\ default.
-%^^A This option decides to round a value which half-way (e.g. $0.005$) between two numbers.
-%^^A \meta{choice} can be either \opt{default} or \opt{commercial}.
-%^^A First rounds the half-way number to the even multiple (\enquote{default} because
-%^^A it is the default rounding option specified by \pkg{expl3}).
-%^^A \meta{commercial} rounds up. It is set to \opt{default} by \dots\ well, default.
+%
+% \begin{cunote}
+% \opt{default} actually refers to the fact that it is the default
+% rounding algorithm used by \cs{fp\_eval:n \{ round( ) \}}
+% without a third argument.
+% \end{cunote}
+%
% \end{function}
%
%
@@ -1679,7 +2130,8 @@ and the derived file cooking-units.sty.
% \cunum{1/2}{kg} \\
% \cunum[kg=g]{1/2}{kg} \\
% \cunum{1_1/2}{kg} \\
-% \cunum[kg=g]{1_1/2}{kg}
+% \cunum[kg=g]{1_1/2}{kg} \\
+% \cunum[kg=g]{-1_1/2}{kg} \\
% \end{cuexamplecode}
%
% \begin{function}{fraction-command}
@@ -1688,7 +2140,7 @@ and the derived file cooking-units.sty.
% \end{syntax}
% Sets the command used for printing fractions equal to \meta{\cs{command}}.
% \meta{\cs{command}} has to take two arguments. By default
-% it is equal to \lstinline!\sfrac! from \pkg{xfrac}.
+% it is equal to |\sfrac| from \pkg{xfrac}.
%
% Please note that the amount is \emph{not} printed inside a math
% environment by default.
@@ -1729,14 +2181,15 @@ and the derived file cooking-units.sty.
% \cunum{1_2/3}{kg}
% \end{cuexamplecode}
%
-% \subsubsection{spaces}
+% \subsubsection{Spaces}
%
% \begin{function}{mixed-fraction-space}
% \begin{syntax}
% mixed-fraction-space = \meta{length}
% \end{syntax}
% Sets the length between the fraction and the number in a mixed-fraction,
-% default is \texttt{0.1em} (because I said so).
+% default is \texttt{0.1em} (because I said so; if someone has some literature
+% or sources to look up the space, please let me know).
% \end{function}
% \begin{cuexamplecode}
% \cuam{1_2/3} \\
@@ -1758,7 +2211,7 @@ and the derived file cooking-units.sty.
% \end{syntax}
% \meta{string} is inserted between the numeral part and the unit part
% when using \cCutext. By default it is set to \cs{space}. Use this option
-% if you want to e.g. insert an unbreakable space.
+% if you want to e.g.\ insert an unbreakable space.
% \end{function}
% \begin{cuexamplecode}
% \cutext{1}{kg}\\
@@ -1775,8 +2228,61 @@ and the derived file cooking-units.sty.
% \end{cuexamplecode}
%
%
+% \begin{function}{phrase-space}
+% \begin{syntax}
+% phrase-space = \meta{string}
+% \end{syntax}
+% \meta{string} is inserted between the numeral part and the phrase part
+% while using \mycs{cuam}. By default it is set to \cs{space}. Use this option
+% if you want to e.g.\ insert an unbreakable space.
+% \end{function}
+% \cusetup{use-phrases=true}
+% \begin{myde}
+% (Switching to german)
+% \begin{cuexamplecode}
+% \cuam{12}\\
+% \cuam{144}\\
+% \cusetup { phrase-space = ~ } @
+% \cuam{12}\\
+% \cuam{144}\\
+% \cusetup { phrase-space = {} } @
+% \cuam{12}\\
+% \cuam{144}\\
+% \cusetup { phrase-space = {qwe} } @
+% \cuam{12}\\
+% \cuam{144}\\
+% \end{cuexamplecode}
+% \end{myde}
+% \cusetup{use-phrases=false}
+%
+% \begin{function}{amount-unit-space}
+% \begin{syntax}
+% amount-unit-space = \meta{string}
+% \end{syntax}
+% Change the spacing for \mycs{cunum} between the printed amount(s) and
+% the unit. The default value is |\thinspace|.
+% \end{function}
+%
+% \begin{cuexamplecode}
+% \selectlanguage{ngerman} @
+% \cunum{1}{kg}\\
+% \cunum{1/2}{kg}\\
+% \cunum{1--2}{kg}\\
+% \cusetup { amount-unit-space = {\hspace{1em}} } @
+% \cunum{1}{kg}\\
+% \cunum{1/2}{kg}\\
+% \cunum{1--2}{kg}\\
+% \cusetup { amount-unit-space = {} } @
+% \cunum{1}{kg}\\
+% \cunum{1/2}{kg}\\
+% \cunum{1--2}{kg}\\
+% \cusetup { amount-unit-space = {qwe} } @
+% \cunum{1}{kg}\\
+% \cunum{1/2}{kg}\\
+% \cunum{1--2}{kg}\\
+% \end{cuexamplecode}
%
-% \subsubsection{label \& refs for People}
+% \subsubsection{label \& refs}
%
% \begin{function}{recalculate-amount}
% \begin{syntax}
@@ -1797,6 +2303,10 @@ and the derived file cooking-units.sty.
% \end{function}
% \begin{cuexamplecode}
% \culabel{anotherrecipe}{2} @
+% \curef{anotherrecipe}~persons \\
+% \cunum<anotherrecipe>{1}{kg}\\
+% \cuam<anotherrecipe>{1}\\
+% \cutext<anotherrecipe>{1}{kg}\\
% \curef{anotherrecipe}~persons \\ @
% \cusetup{ recalculate-amount = true } @
% \curef{anotherrecipe}~persons \\
@@ -1867,7 +2377,7 @@ and the derived file cooking-units.sty.
% \begin{syntax}
% ref = \meta{label}
% \end{syntax}
-% Instead of using the first optional arguments of the commands in \vref{sec:commands}
+% Instead of using the first optional arguments of the commands in \cref{sec:commands}
% you may use this option. It requires a valid value and throws an error if \meta{label}
% is not defined.
% \end{function}
@@ -1886,7 +2396,7 @@ and the derived file cooking-units.sty.
% \begin{syntax}
% check-temperature = \meta{true/false}
% \end{syntax}
-% Checks if the used temperature is below the absolute zero point.
+% Checks if the used temperature is below absolute zero.
% Currently \texttt{C}, \texttt{F}, \texttt{K} and \texttt{Re} are supported.
% While \lstinline|\cunum{0}{K}| is ok, \lstinline!\cunum{-1}{K}! raises an error,
% same for the others. Is set to \texttt{false} by default. To add new units
@@ -1935,11 +2445,6 @@ and the derived file cooking-units.sty.
% \end{lstlisting}
%
%
-% ^^A \begin{cuexamplecode}
-% ^^A \cusetup{check-temperature=true} @
-% ^^A \cunum{0}{K} \\
-% ^^A \cunum[K=C]{0--1}{K} \\
-% ^^A \end{cuexamplecode}
%
%
%
@@ -1947,13 +2452,15 @@ and the derived file cooking-units.sty.
% \begin{syntax}
% convert-to-eV = \meta{true/false}
% \end{syntax}
-% Converts (nearly) every unit in \vref{tab:def-units}
+% Converts (nearly) every unit in \cref{tab:def-units}
% to electron volt or the respective derivative. Note that this
% option is:
% a) experimental and probably will forever be and b) just a joke, you are not
% supposed to use this units in a cookery book (and as you see this package
% doesn't support the arrangement of such huge numbers). Also you may
-% want to check the values if you really want to use them, just to be sure.
+% want to check the values if you really want to use them, just to be sure
+% (I've checked them several times and hope they are finally correct, but mistakes
+% happen).
%
% \end{function}
%
@@ -1968,36 +2475,35 @@ and the derived file cooking-units.sty.
% \end{cuexamplecode}
%
%
-%
+%
+%
+%
%
% \section{Bugs \& Feedback}
% \label{sec:bug-feed}
%
-% Bug reports are always welcome. If you are sending a bug report
+% Bug reports are always welcome. If you are sending a bug report
% please include a minimal working example showing the bug and a short
-% description. Furthermore please add \enquote{cooking-units}
+% description. If you use mail please add \pkg{cooking-units}
% to the e-mail header. GMX has the habit of putting e-mails into the
-% spam account and adding \enquote{cooking-units} to the header makes
+% spam account and adding \pkg{cooking-units} to the header makes
% it easier to recognize those e-mails.
%
-% Feedback and requests (commands, units) are most welcome.
-% Please also add (if possible) an example of the
-% desired output into the minimal example (and also add \enquote{cooking-units}
-% to the header).
-%
-% Furthermore, as you can see I am not able to speak too many languages (german and
-% english to be precise; I managed to add french with the help of the internet,
-% which is not optimal) so if you are able to speak a language not yet implemented
-% and would like to help you can send me a list of the translations of the units given in
-% \vref{sec:pred-units} or (for better overview) \vref{sec:Translations}. I would need
-% \begin{itemize}
-% \item their singular (and plural) form,
-% \item the gender,
-% \item the printed symbol (if different),
-% \item \texttt{decimal-mark} and \texttt{one(m)}, \texttt{one(f)}, \texttt{one(n)}
-% \end{itemize}
+% Feedback and requests (commands, units, etc.) are also welcome. Please
+% also add (if possible) an example of the desired output into the
+% minimal example (and -- if by mail -- add \pkg{cooking-units} to the
+% header).
+%
+% Furthermore, as you can see I am not able to speak too many
+% languages (german and english to be precise; I managed to add french
+% with the help of the internet, which is not optimal) so if you are
+% able to speak a language not yet implemented and would like to help
+% you can send me the translations known to you. A list of all units
+% (and their current translations) is given in \cref{sec:Translations}.
+%
+%
+%
%
-% Oh yeah, if someone has a better idea of how to deal with languages I am happy to know.
%
%
%
@@ -2007,54 +2513,72 @@ and the derived file cooking-units.sty.
% \section{Translations}
% \label{sec:Translations}
% This section contains the list of available translations. Each table
-% shows the available translations for the printed unit, the unit-name
+% shows the available translations regarding the unit symbol, the unit name
% (printed if \mycs{cutext} or \mycs{Cutext} is used) and
-% the plural form (if different from the singular form).
+% the plural form (if different from the singular form). A second table
+% shows the translations used for phrases (if given).
%
% If a translation is not available a \enquote{\translationdoesnotexisttl} is
% shown.
%
% \small
%
-%
-% \begin{function}{English}
+% \newpage
+% \subsection{English}
% \begin{tabular}{ l l l l l }
% \toprule
% \CreateTableForLanguages{ English }
-% \\\bottomrule
% \end{tabular}
-% \end{function}
%
-% \begin{function}{AmericanEnglish}
-% Only differences from \enquote{English} are defined.
+%
+% \newpage
+% \subsection{american}
+%^^A Only differences from \enquote{English} are defined.
%
% \begin{tabular}{ l l l l l }
% \toprule
-% \CreateTableForLanguages{ AmericanEnglish }
-% \\\bottomrule
+% \CreateTableForLanguages{ american }
% \end{tabular}
-% \end{function}
%
-% \begin{function}{German}
+% \newpage
+% \subsection{German}
% \begin{tabular}{ l l l l l }
% \toprule
-% \CreateTableForLanguages{ German }
-% \\\bottomrule
+% \CreateTableForLanguages{ German }
% \end{tabular}
-% \end{function}
%
-% \begin{function}{French}
+% \bigskip
+%
+% \CreateTableForPhrases { German }
+%
+% \bigskip
+% \begin{minipage}{\textwidth}
+% Some further phrases, just to write them down (they are not implemented,
+% as they are barely used).
+%
+% \begin{tabular} { l l @{\space} l l l l }
+% \toprule
+% \meta{number} & name & \multicolumn{2}{c}{Note} & (plural) & gender \\ \midrule
+% 60 & Schock & (5 Dutzend, & $12*5$) & & n \\
+% 144 & Gros & (12 Dutzend, & $12*12$) && n \\
+% 1728 & Gro{\ss}gros &(12 Gro{\ss}, & $12*144$) && n \\
+% \bottomrule
+% \end{tabular}
+% \end{minipage}
+%
+% Note that Gro{\ss}gros has other (probably more common) synonyms.
+%
+% \newpage
+% \subsection{French}
% \begin{tabular}{ l l l l l }
% \toprule
% \CreateTableForLanguages{ French }
-% \\\bottomrule
% \end{tabular}
-% \end{function}
%
%
% \clearpage
%
-%
+% \begin{comment}
%^^A \section{Notes and other stuff}
%^^A This section contains stuff which might or might not be interesting.
%^^A
@@ -2148,7 +2672,7 @@ and the derived file cooking-units.sty.
%^^A \sqrt{ \frac{1}{(\SI{299792458}{\m\per\s} )^2} * (\SI{0.0000000098e-19}{\J})^2 } \\
%^^A &=
%^^A \end{align}
-%
+% \end{comment}
%
%
%
@@ -2179,8 +2703,6 @@ and the derived file cooking-units.sty.
%
% Na dann, auf gehts!
%
-% PS. The whole code-section needs more attention. Not the code itself, but
-% the written text which never saw a spell-checker and has partly become obsolete.
% \begin{macrocode}
\@ifpackageloaded {xparse}
{ }
@@ -2194,13 +2716,14 @@ and the derived file cooking-units.sty.
% \begin{macrocode}
\ProvidesExplPackage
{cooking-units}
- {2016/11/13}
- {1.10}
+ {2017/10/23}
+ {1.2}
{Ein Paket fuer Kocheinheiten}
% \end{macrocode}
-% Checking if \pkg{expl3} is uptodate, otherwise abort the loading of the package.
+%
+% Checking if \pkg{expl3} is up-to-date, otherwise abort the loading of the package.
% \begin{macrocode}
-\@ifpackagelater { expl3 } { 2016/05/18 }
+\@ifpackagelater { expl3 } { 2017/09/18 }
{ }
{
\PackageError { cooking-units } { Support~package~expl3~too~old }
@@ -2212,31 +2735,50 @@ and the derived file cooking-units.sty.
\tex_endinput:D
}
% \end{macrocode}
-% Loading the packages needed.
+% Loading some needed packages.
% \begin{macrocode}
-\@ifpackageloaded { translator } { } { \RequirePackage { translator } }
+\@ifpackageloaded { translations } { } { \RequirePackage { translations } }
\@ifpackageloaded { xfrac } { } { \RequirePackage { xfrac } }
\@ifpackageloaded { l3keys2e } { } { \RequirePackage { l3keys2e } }
% \end{macrocode}
%
+% Checking if \pkg{translations} is up-to-date, otherwise abort the loading of the package.
+% \begin{macrocode}
+\@ifpackagelater { translations } { 2017/08/31 }
+ { }
+ {
+ \PackageError { cooking-units } { Support~package~translations~too~old }
+ {
+ You~need~to~update~your~installation~of~the~package~'translations'.\MessageBreak
+ Loading~cooking-units~will~abort!
+ }
+ \tex_endinput:D
+ }
+% \end{macrocode}
+%
% Define the only load-time option for this package. If it is set,
-% load package \pkg{fmtcount} and redefine the option so that it
-% displays an error message if used.
+% load package \pkg{fmtcount}.
% \begin{macrocode}
-\bool_new:N \g_@@_load_if_opt_numeral_bool
+\bool_new:N \g_@@_opt_numeral_bool
\keys_define:nn { cooking-units }
{
- use-numerals .bool_gset:N = \g_@@_load_if_opt_numeral_bool ,
+ use-numerals .bool_gset:N = \g_@@_opt_numeral_bool ,
use-numerals .default:n = { false },
}
+% \end{macrocode}
+% Now process the package options \dots
+% \begin{macrocode}
\ProcessKeysOptions { cooking-units }
-\bool_if:NT \g_@@_load_if_opt_numeral_bool
+\bool_if:NT \g_@@_opt_numeral_bool
{
\@ifpackageloaded { fmtcount } { } { \RequirePackage { fmtcount } }
}
+% \end{macrocode}
+% \dots\ and redefine the package option such that it cannot be used elsewhere.
+% \begin{macrocode}
\keys_define:nn { cooking-units }
{
- use-numerals .code:n = \msg_error:nnn { cooking-units } { load-time-option } { fmtcount } ,
+ use-numerals .code:n = { \msg_error:nnn { cooking-units } { load-time-option } { fmtcount } } ,
}
% \end{macrocode}
%
@@ -2247,26 +2789,27 @@ and the derived file cooking-units.sty.
% \begin{macro}
% {
% \tl_replace_all:NVn,
-% \tl_replace_once:NnV ,
-% \tl_replace_once:NVn ,
+% \tl_replace_once:NnV , \tl_replace_once:NVn ,
% \tl_if_in:nVTF ,
+% \tl_if_in:NVTF ,
% \tl_if_in:NVT ,
-% \fp_compare:vNnT ,
-% \fp_eval:c,
+% \fp_compare:cNnT ,
+% \fp_eval:c ,
+% \prop_get:cVc ,
+% \int_abs:c ,
% }
-% Some commands we will need later.
+% Some variations of commands we will need later.
% \begin{macrocode}
\cs_generate_variant:Nn \tl_replace_all:Nnn { NVn }
\cs_generate_variant:Nn \tl_replace_once:Nnn { NnV, NVn }
\cs_generate_variant:Nn \tl_if_in:nnTF { nVTF }
-\cs_generate_variant:Nn \tl_if_in:NnTF { NVTF }
+\cs_generate_variant:Nn \tl_if_in:NnTF { NVTF }
\cs_generate_variant:Nn \tl_if_in:NnT { NVT }
\cs_generate_variant:Nn \fp_compare:nNnT { cNnT }
\cs_generate_variant:Nn \fp_eval:n { c }
\cs_generate_variant:Nn \prop_get:cVN { cVc }
\cs_generate_variant:Nn \int_abs:n { c }
-\cs_generate_variant:Nn \tl_show:n { f , x }
-\cs_generate_variant:Nn \fp_compare:nNnTF { v }
+\cs_generate_variant:Nn \tl_show:n { x , f }
% \end{macrocode}
% \end{macro}
%
@@ -2278,6 +2821,22 @@ and the derived file cooking-units.sty.
% \end{macrocode}
% \end{macro}
%
+%
+% \begin{macro}{\@@_print_numeral:n , \@@_print_Numeral:n}
+% This command is used to print the fractions and can be changed
+% accordingly.
+% \begin{macrocode}
+\cs_new:Npn \@@_print_numeral:n #1 {}
+\cs_new:Npn \@@_print_Numeral:n #1 {}
+\bool_if:NT \g_@@_opt_numeral_bool
+ {
+ \cs_set_eq:NN \@@_print_numeral:n \numberstringnum
+ \cs_set_eq:NN \@@_print_Numeral:n \Numberstringnum
+ }
+% \end{macrocode}
+% \end{macro}
+%
+%
% \begin{macro}{ \l_@@_change_unit_prop }
% Conversions of units are stored within this property list.
% If someone requests that \texttt{kg} should be changed into \texttt{g},
@@ -2290,53 +2849,59 @@ and the derived file cooking-units.sty.
% \end{macro}
%
%
-%\begin{macro}
+% \begin{macro}
% {
-% \l_@@_tmpa_tl ,
-% \l_@@_tmpb_tl ,
-% \l_@@_mixed_fraction_tl ,
-% \l_@@_tmp_unit_tl ,
-% \l_@@_option_unit_tl ,
-% \l_@@_language_tl ,
-% \l_@@_cunum_range_sign_tl ,
-% \l_@@_cutext_range_sign_tl ,
-% \l_@@_value_unit_space_tl ,
-% \l_@@_input_digits_tl ,
-% \l_@@_decimal_mark_tl,
-% \l_@@_value_signs_tl,
-% \c_@@_str_hash_one_tl ,
-% \l_@@_allowed_special_signs_tl ,
+% \l_@@_number_tmpa_tl,
+% \l_@@_number_tmpb_tl,
+% \l_@@_tmpa_tl,
+% \l_@@_tmpb_tl,
+% \l_@@_mixed_fraction_tl,
+% \l_@@_given_unit_tl,
+% \l_@@_option_unit_tl,
+% \l_@@_language_tl,
+% \l_@@_cunum_range_sign_tl,
+% \l_@@_cutext_range_sign_tl,
+% \l_@@_value_unit_space_tl,
+% \l_@@_input_digits_tl ,
+% \l_@@_input_decimal_mark_tl,
+% \l_@@_input_value_signs_tl,
+% \l_@@_input_allowed_special_signs_tl ,
+% \c_@@_input_str_hash_one_tl ,
+% \l_@@_input_range_sign_tl,
+% \l_@@_input_times_persons_sign,
+% \l_@@_cutext_space_tl,
+% \l_@@_cuphrase_space_tl,
+% \l_@@_translation_tmpa_tl,
+% \l_@@_cutext_last_value_tl,
+% \l_@@_phrase_phrase_tl ,
% }
-% Some token lists needed later. The first two are just basic
-% temporary safe tokens which are used everywhere. The third
-% is used to store the numerical input of the mixed-fraction part.
-%
-% \verb|tmp_unit_tl| stores the unit-key given in \lstinline|\cunum|, etc,
-% whereas \verb|option_unit_tl| stores the unit which the former unit
-% is converted into.
-%
-% The others are needed for printing and checking.
+% Quite a lot of tl's.
% \begin{macrocode}
+\tl_new:N \l_@@_number_tmpa_tl
+\tl_new:N \l_@@_number_tmpb_tl
\tl_new:N \l_@@_tmpa_tl
\tl_new:N \l_@@_tmpb_tl
\tl_new:N \l_@@_mixed_fraction_tl
-\tl_new:N \l_@@_tmp_unit_tl
+\tl_new:N \l_@@_given_unit_tl
\tl_new:N \l_@@_option_unit_tl
\tl_new:N \l_@@_language_tl
\tl_new:N \l_@@_cunum_range_sign_tl
\tl_new:N \l_@@_cutext_range_sign_tl
\tl_new:N \l_@@_value_unit_space_tl
\tl_new:N \l_@@_input_digits_tl
-\tl_new:N \l_@@_decimal_mark_tl
-\tl_new:N \l_@@_value_signs_tl
-\tl_new:N \l_@@_allowed_special_signs_tl
-\tl_new:N \c_@@_str_hash_one_tl
+\tl_new:N \l_@@_input_decimal_mark_tl
+\tl_new:N \l_@@_input_value_signs_tl
+\tl_new:N \l_@@_input_allowed_special_signs_tl
+\tl_new:N \c_@@_input_str_hash_one_tl
\tl_new:N \l_@@_input_range_sign_tl
-\tl_new:N \l_@@_input_for_persons_sign
\tl_new:N \l_@@_input_times_persons_sign
\tl_new:N \l_@@_cutext_space_tl
+\tl_new:N \l_@@_cuphrase_space_tl
\tl_new:N \l_@@_translation_tmpa_tl
-\tl_new:N \l_@@_cutext_tmp_tl
+\tl_new:N \l_@@_cutext_last_value_tl
+\tl_new:N \l_@@_phantom_tl
+\tl_new:N \l_@@_phrase_phrase_tl
+\tl_new:N \l_@@_unit_key_not_allowed_tl
% \end{macrocode}
% \end{macro}
%
@@ -2345,19 +2910,22 @@ and the derived file cooking-units.sty.
% \lstinline|str_hash_one_tl| is used for defining single keys.
% (You will see, I didn't have a better idea)
% \begin{macrocode}
-\tl_set:Nn \l_@@_cunum_range_sign_tl { -- }
-\tl_set:Nn \l_@@_cutext_range_sign_tl { -- }
-\tl_set:Nn \l_@@_value_unit_space_tl { \thinspace }
\tl_set:Nn \l_@@_input_digits_tl { 0123456789 }
-\tl_set:Nn \l_@@_input_for_persons_sign { @ }
\tl_set:Nn \l_@@_input_times_persons_sign { * }
-\tl_set:Nn \l_@@_decimal_mark_tl { . , }
-\tl_set:Nn \l_@@_value_signs_tl { + - }
\tl_set:Nn \l_@@_input_range_sign_tl { -- }
-\tl_set:Nn \l_@@_allowed_special_signs_tl { ? }
-\tl_set_rescan:Nnn \c_@@_str_hash_one_tl
+\tl_set:Nn \l_@@_input_decimal_mark_tl { . , }
+\tl_set:Nn \l_@@_input_value_signs_tl { + - }
+\tl_set:Nn \l_@@_input_allowed_special_signs_tl { ? }
+\tl_set_rescan:Nnn \c_@@_input_str_hash_one_tl
{ \char_set_catcode_letter:N \# } {#1}
+% \end{macrocode}
+% \begin{macrocode}
+\tl_set:Nn \l_@@_cunum_range_sign_tl { -- }
+\tl_set:Nn \l_@@_cutext_range_sign_tl { -- }
+\tl_set:Nn \l_@@_value_unit_space_tl { \thinspace }
\tl_set:Nn \l_@@_cutext_space_tl { \space }
+\tl_set:Nn \l_@@_cuphrase_space_tl { \space }
+\tl_set:Nn \l_@@_unit_key_not_allowed_tl { , / }
% \end{macrocode}
%
% Flat out stolen from \pkg{siunitx}
@@ -2401,12 +2969,6 @@ and the derived file cooking-units.sty.
% \end{macro}
%
%
-% \begin{macro}{ \l_@@_persons_tmp_int }
-% \begin{macrocode}
-\int_new:N \l_@@_persons_tmp_int
-% \end{macrocode}
-% \end{macro}
-%
% \begin{macro}{ \l_@@_significant_figures_plus_one_int }
% Stores the round-precision inside. Not sure if 'significant
% figures' is the correct therm for this. Also computes the number
@@ -2424,27 +2986,46 @@ and the derived file cooking-units.sty.
%
% \begin{macro}{ \l_@@_print_numerals_below_int }
% Used if option 'use-numerals' is active. Uses numerals for
-% integers smaller than this number.
+% integers smaller than this number. I learned this number
+% at school.
% \begin{macrocode}
\int_new:N \l_@@_print_numerals_below_int
\int_set:Nn \l_@@_print_numerals_below_int { 13 }
% \end{macrocode}
% \end{macro}
%
+%
+% \begin{macro}{ \l_@@_number_of_persons_tmpa_int }
+% Each recipe defined by \cs{culabel} defines a counter to
+% store the number of persons the recipe is for. For calculation
+% the value is retrived and stored inside this temporal counter.
+% \begin{macrocode}
+\int_new:N \l_@@_number_of_persons_tmpa_int
+% \end{macrocode}
+% \end{macro}
+%
% \begin{macro}{ \l_@@_calc_for_number_of_persons_int }
+% Not only the number of persons are recipe is for is needed
+% for calculation, but also the number of persons you want
+% the recipe to be. This information is stored here.
% \begin{macrocode}
\int_new:N \l_@@_calc_for_number_of_persons_int
\int_set:Nn \l_@@_calc_for_number_of_persons_int { 4 }
% \end{macrocode}
% \end{macro}
%
+% \begin{macrocode}
+\int_new:N \l_@@_phrase_number_tl
+% \end{macrocode}
%
%
% \begin{macro}{ \l_@@_list_of_defined_keys_clist , \g_@@_list_of_defined_units_clist }
-% List of defined units and keys.
+% Sequence of defined units and keys. Units are defined
+% globally as they create new commands, keys do not do that
+% (I think). Could be my mistake.
% \begin{macrocode}
-\clist_new:N \l_@@_list_of_defined_keys_clist
-\clist_new:N \g_@@_list_of_defined_units_clist
+\seq_new:N \l_@@_list_of_defined_keys_seq
+\seq_new:N \g_@@_list_of_defined_units_seq
% \end{macrocode}
%\end{macro}
%
@@ -2455,65 +3036,106 @@ and the derived file cooking-units.sty.
% which cannot be used as units, but are processed by the commands in
% the language section as such.
% \begin{macrocode}
-\clist_new:N \g_@@_allowed_unit_phrases_clist
+\clist_new:N \g_@@_allowed_special_keys_clist
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro} { \l_@@_phrase_numbers_clist }
+% Inside this list the numbers for which a phrase is defined
+% is stored in. As this is language specific, the list is stored
+% inside a language-sensitive command and retrived when needed.
+% \begin{macrocode}
+\clist_new:N \l_@@_phrase_numbers_clist
% \end{macrocode}
% \end{macro}
%
-% \begin{macro} { \l_@@_temperatures_to_check_clist }
+% \begin{macro} { \l_@@_temperatures_to_check_seq }
% \changes {1.02h} {New.}
% Stores units which should be tested if \opt{check-temperature} equals true.
% \begin{macrocode}
-\clist_new:N \l_@@_temperatures_to_check_clist
+\seq_new:N \l_@@_temperatures_to_check_seq
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro} { \l_@@_phrase_prop }
+% Stores the number and he respective phrase. For example
+% if \enquote{12} has the phrase \enquote{Dutzend}, this
+% key-value pair is stored inside.
+% \begin{macrocode}
+\prop_new:N \l_@@_phrase_prop
% \end{macrocode}
% \end{macro}
%
% \begin{macro}
% {
-% \l_@@_error_bool ,
-% \l_@@_eval_fractions_bool,
-% \l_@@_parse_input_bool,
-% \l_@@_round_to_int_bool,
-% \l_@@_special_sign_bool,
-% \l_@@_decimal_in_input_bool,
-% \l_@@_single_key_bool,
-% \l_@@_fraction_in_input_bool,
-% \l_@@_check_temperature_bool,
-% \l_@@_convert_to_eV_bool,
-% \l_@@_cutext_uppercase_word_bool,
-% \l_@@_error_for_unknown_value_bool,
-% \l_@@_parse_range_bool,
+% \l_@@_minus_bool,
+% \l_@@_round_decimal_part_bool,
+% \l_@@_error_bool,
+% \l_@@_eval_fractions_bool,
+% \l_@@_parse_input_bool,
+% \l_@@_round_to_int_bool,
+% \l_@@_special_sign_bool,
+% \l_@@_single_key_bool,
+% \l_@@_check_temperature_bool,
+% \l_@@_convert_to_eV_bool,
+% \l_@@_cutext_uppercase_word_bool,
+% \l_@@_error_for_unknown_value_bool,
+% \l_@@_using_cutext_bool,
+% \l_@@_cuam_old_bool,
+% \l_@@_calc_for_persons_bool,
+% \l_@@_calc_because_ref_was_given_bool,
+% \l_@@_calc_persons_bool,
+% \l_@@_cutext_to_cunum_bool,
+% \l_@@_cutext_old_bool,
+% \l_@@_cutext_change_unit_bool,
+% \l_@@_round_commercial_bool,
+% \l_@@_use_phrases_bool,
+% \l_@@_check_if_phrase_used_bool
% }
% Some booleans we need later.
% \begin{macrocode}
+\bool_new:N \l_@@_minus_bool
+\bool_new:N \l_@@_round_decimal_part_bool
\bool_new:N \l_@@_error_bool
\bool_new:N \l_@@_eval_fractions_bool
\bool_new:N \l_@@_parse_input_bool
\bool_new:N \l_@@_round_to_int_bool
\bool_new:N \l_@@_special_sign_bool
-\bool_new:N \l_@@_decimal_in_input_bool
\bool_new:N \l_@@_single_key_bool
-\bool_new:N \l_@@_fraction_in_input_bool
\bool_new:N \l_@@_check_temperature_bool
\bool_new:N \l_@@_convert_to_eV_bool
\bool_new:N \l_@@_cutext_uppercase_word_bool
\bool_new:N \l_@@_error_for_unknown_value_bool
-\bool_new:N \l_@@_parse_range_bool
\bool_new:N \l_@@_using_cutext_bool
\bool_new:N \l_@@_cuam_old_bool
\bool_new:N \l_@@_calc_for_persons_bool
\bool_new:N \l_@@_calc_because_ref_was_given_bool
-\bool_new:N \l_@@_calc_persons_tmp_bool
+\bool_new:N \l_@@_calc_persons_bool
\bool_new:N \l_@@_cutext_to_cunum_bool
\bool_new:N \l_@@_cutext_old_bool
\bool_new:N \l_@@_cutext_change_unit_bool
\bool_new:N \l_@@_round_commercial_bool
+\bool_new:N \l_@@_use_phrases_bool
+\bool_new:N \l_@@_check_if_phrase_used_bool
+\bool_new:N \l_@@_local_numeral_bool
+% \end{macrocode}
+%
+% While rewriting the code I searched for those
+% booleans a lot.
+% \begin{macrocode}
+\bool_new:N \l_@@_range_in_input_bool
+\bool_new:N \l_@@_fraction_in_input_bool
+\bool_new:N \l_@@_decimal_in_input_bool
% \end{macrocode}
% \end{macro}
%
-% Setting some of them to \texttt{true}.
+%
+%
+% Setting some of them to \texttt{true} or another boolean respectively.
% \begin{macrocode}
\bool_set_true:N \l_@@_parse_input_bool
\bool_set_true:N \l_@@_cutext_change_unit_bool
+\bool_set_eq:NN \l_@@_local_numeral_bool \g_@@_opt_numeral_bool
% \end{macrocode}
%
%
@@ -2524,33 +3146,32 @@ and the derived file cooking-units.sty.
% \end{macrocode}
%\end{macro}
%
-%
-%
-% \begin{macro}{ decimal-mark, one(m), one(f), one(n) }
-% Defining the translation for the decimal-mark. Note that those
-% 'phrases' are stored inside
-% \verb|\g_@@_allowed_unit_phrases_clist|.
-% Furthermore some translations are defined.
+% \begin{macro}{ \q_@@_no_translation }
+% Note the spelling mistake in \enquote{available}.
% \begin{macrocode}
-\clist_gset:Nn \g_@@_allowed_unit_phrases_clist
- {
- decimal-mark ,
- one (m) ,
- one (f) ,
- one (n)
- }
-\newtranslation { decimal-mark (cu-unitname) } { . }
-\newtranslation [ to=German ] { decimal-mark (cu-unitname) } { , }
-\newtranslation { one (m) (cu-unitname) } { one }
-\newtranslation { one (f) (cu-unitname) } { one }
-\newtranslation { one (n) (cu-unitname) } { one }
-\newtranslation [ to=German ] { one (m) (cu-unitname) } { ein }
-\newtranslation [ to=German ] { one (f) (cu-unitname) } { eine }
-\newtranslation [ to=German ] { one (n) (cu-unitname) } { ein }
+\quark_new:N \q_@@_no_translation
% \end{macrocode}
-% \end{macro}
+%\end{macro}
%
%
+% \begin{macro}{
+% \l_@@_tmpa_fp ,
+% \l_@@_tmpa_clist ,
+% \l_@@_tmpa_prop ,
+% \l_@@_tmpb_prop ,
+% \l_@@_tmpa_seq ,
+% }
+% Some temporal stores which are used thoughout the code.
+% \begin{macrocode}
+\fp_new:N \l_@@_tmpa_fp
+\clist_new:N \l_@@_tmpa_clist
+\prop_new:N \l_@@_tmpa_prop
+\prop_new:N \l_@@_tmpb_prop
+\seq_new:N \l_@@_tmpa_seq
+\int_new:N \l_@@_tmpa_int
+\int_new:N \l_@@_tmpb_int
+% \end{macrocode}
+%\end{macro}
%
%
%
@@ -2608,11 +3229,11 @@ and the derived file cooking-units.sty.
% \end{macrocode}
%\end{macro}
%
-%\begin{macro}{ value-unit-space }
+%\begin{macro}{ amount-unit-space }
% Setting the space between the value and the printed unit.
% \begin{macrocode}
- value-unit-space .tl_set:N = \l_@@_value_unit_space_tl ,
- value-unit-space .default:n = { \thinspace } ,
+ amount-unit-space .tl_set:N = \l_@@_value_unit_space_tl ,
+ amount-unit-space .default:n = { \thinspace } ,
% \end{macrocode}
%\end{macro}
%
@@ -2628,7 +3249,7 @@ and the derived file cooking-units.sty.
% Setting the code inline.
% \begin{macrocode}
fraction-inline .code:n = { \cs_set:Npn \@@_frac:nn ##1##2 {#1} } ,
- fraction-inline .default:n = { \sfrac {#1}{#2} } ,
+ fraction-inline .default:n = { \sfrac {#1} {#2} } ,
% \end{macrocode}
%\end{macro}
%
@@ -2651,7 +3272,12 @@ and the derived file cooking-units.sty.
%\begin{macro}{ add-special-sign }
% Adding a (some) special sign(s) which is (are) allowed in the input.
% \begin{macrocode}
- add-special-sign .code:n = { \tl_put_right:Nn \l_@@_allowed_special_signs_tl {#1} } ,
+ add-special-sign .code:n =
+ {
+ \str_if_eq:nnTF {#1} { < }
+ { \msg_error:nn { cooking-units } { <-not-allowed-as-special-sign } }
+ { \tl_put_right:Nn \l_@@_input_allowed_special_signs_tl {#1} }
+ } ,
add-special-sign .default:n = { } ,
% \end{macrocode}
%\end{macro}
@@ -2659,7 +3285,12 @@ and the derived file cooking-units.sty.
%\begin{macro}{ set-special-sign }
% Doing the same as above but also overrides the old signs.
% \begin{macrocode}
- set-special-sign .tl_set:N = \l_@@_allowed_special_signs_tl ,
+ set-special-sign .code:n =
+ {
+ \str_if_eq:nnTF {#1} { < }
+ { \msg_error:nn { cooking-units } { <-not-allowed-as-special-sign } }
+ { \tl_set:Nn \l_@@_input_allowed_special_signs_tl {#1} }
+ } ,
% \end{macrocode}
%\end{macro}
%
@@ -2684,6 +3315,8 @@ and the derived file cooking-units.sty.
%
%\begin{macro}{ add-temperature-to-check }
% Adds a temperature to check for \texttt{check-temperature}.
+% It uses the \cs{keyval\_parse:NNn} command as this
+% macro is used to parse keys (which is what I need).
% \begin{macrocode}
add-temperature-to-check .code:n =
{
@@ -2699,6 +3332,8 @@ and the derived file cooking-units.sty.
%\begin{macro}{ convert-to-eV }
% Another weird option, converts pretty much any unit defined by this
% package to electron volt or the respective derivative.
+% As this is a unit transfrmation, it needs to be inside the
+% group.
% \begin{macrocode}
convert-to-eV .bool_set:N = \l_@@_convert_to_eV_bool ,
convert-to-eV .default:n = { true } ,
@@ -2728,13 +3363,26 @@ and the derived file cooking-units.sty.
% \end{macrocode}
%\end{macro}
%
+% \begin{macro}{ set-unknown-message }
+% Sets the message for a special-sign to error, warning or none.
+% \begin{macrocode}
+ set-cutext-translation-message .choices:nn =
+ { error , warning , none }
+ {
+ \msg_redirect_name:nnn { cooking-units } { cutext-no-translation-available }
+ { \l_keys_choice_tl }
+ } ,
+ set-cutext-translation-message .default:n = { warning } ,
+% \end{macrocode}
+%\end{macro}
+%
%
%\begin{macro}{ erase-all-options }
% Erasing all preset options.
% \begin{macrocode}
erase-all-options .code:n =
{
- \clist_map_inline:Nn \g_@@_list_of_defined_units_clist
+ \seq_map_inline:Nn \g_@@_list_of_defined_units_seq
{
\clist_clear:c { l_@@_predefined_option_##1_clist }
}
@@ -2743,9 +3391,7 @@ and the derived file cooking-units.sty.
% \end{macro}
%
% \begin{macro}{ round-half }
-% Choosing between \enquote{normal} rounding to even and commercial rounding.
-% If 'default' is chosen nothing is added, if 'commercial' is used it adds a comma
-% for the rounding option.
+% Choosing between \enquote{normal} rounding to even and commercial rounding and sets the boolean accordingly.
% \begin{macrocode}
round-half .choices:nn =
{ default , commercial }
@@ -2761,6 +3407,7 @@ and the derived file cooking-units.sty.
% \end{macro}
%
% \begin{macro}{ set-number-of-persons }
+% Setting the number of persons the recipe should be for.
% \begin{macrocode}
set-number-of-persons .int_set:N = \l_@@_calc_for_number_of_persons_int ,
set-number-of-persons .default:n = { 4 } ,
@@ -2768,6 +3415,7 @@ and the derived file cooking-units.sty.
% \end{macro}
%
% \begin{macro}{ label }
+% Defines a label \dots\ is \mycs{culabel} as a key.
% \begin{macrocode}
label .code:n =
{
@@ -2778,6 +3426,7 @@ and the derived file cooking-units.sty.
% \end{macro}
%
% \begin{macro}{ get-label }
+% \mycs{curef} as a key.
% \begin{macrocode}
get-label .code:n =
{
@@ -2788,6 +3437,7 @@ and the derived file cooking-units.sty.
% \end{macro}
%
% \begin{macro}{ ref }
+% The <> option for keys.
% \begin{macrocode}
ref .code:n =
{
@@ -2798,6 +3448,8 @@ and the derived file cooking-units.sty.
% \end{macro}
%
% \begin{macro}{ cuam-version , cutext-version}
+% Some keys with horrible option names. Reverts
+% the respective command back to its older state (pre v1.10).
% \begin{macrocode}
cuam-version .choices:nn =
{ new , old }
@@ -2823,13 +3475,18 @@ and the derived file cooking-units.sty.
% \end{macro}
%
% \begin{macro}{ recalculate-amount }
+% Setting the number of persons your recipes should be for
+% is not enough; it is also needed to tell the package to
+% recalculate the amounts.
% \begin{macrocode}
recalculate-amount .bool_set:N = \l_@@_calc_for_persons_bool ,
recalculate-amount .default:n = { false } ,
% \end{macrocode}
% \end{macro}
%
-% \begin{macro}{ recalculate-amount }
+% \begin{macro}{ cutext-to-cunum }
+% Don't want any \mycs{cutext} (or \mycs{Cutext}) in your
+% document? Use this option!
% \begin{macrocode}
cutext-to-cunum .bool_set:N = \l_@@_cutext_to_cunum_bool ,
cutext-to-cunum .default:n = { false } ,
@@ -2837,25 +3494,66 @@ and the derived file cooking-units.sty.
% \end{macro}
%
% \begin{macro}{ cutext-space }
+% The space used in \mycs{cutext} between the number (or numeral)
+% and unit.
% \begin{macrocode}
cutext-space .tl_set:N = \l_@@_cutext_space_tl ,
cutext-space .default:n = { \space } ,
% \end{macrocode}
% \end{macro}
%
+% \begin{macro}{ phrase-space }
+% Same as before, but for phrases
+% \begin{macrocode}
+ phrase-space .tl_set:N = \l_@@_cuphrase_space_tl ,
+ phrase-space .default:n = { \space } ,
+% \end{macrocode}
+% \end{macro}
+%
% \begin{macro}{ cutext-change-unit }
+% Do not wanna change units in \mycs{cutext}? Use this option.
% \begin{macrocode}
cutext-change-unit .bool_set:N = \l_@@_cutext_change_unit_bool ,
cutext-change-unit .default:n = { true } ,
% \end{macrocode}
% \end{macro}
%
+%
+% \begin{macro}{ use-phrases }
+% Do not wanna use phrases in \mycs{cuam}? Use this option!
+% \begin{macrocode}
+ use-phrases .bool_set:N = \l_@@_use_phrases_bool ,
+ use-phrases .default:n = { true } ,
+% \end{macrocode}
+% \end{macro}
+%
+%
+%
+% \begin{macro}{ print-numerals }
+% A not very good name, but I couldn't think of a better name.
+% \begin{macrocode}
+ print-numerals .bool_set:N = \l_@@_local_numeral_bool ,
+ print-numerals .default:n = { true } ,
+% \end{macrocode}
+% \end{macro}
+%
+%
+% \begin{macro}{ numeral-function , Numeral-function }
+%
+% \begin{macrocode}
+ numeral-function .code:n = { \cs_set_eq:NN \@@_print_numeral:n #1 } ,
+ Numeral-function .code:n = { \cs_set_eq:NN \@@_print_Numeral:n #1 } ,
+% \end{macrocode}
+% \end{macro}
+%
+%
+%
% Ending the definition of keys.
% \begin{macrocode}
}
% \end{macrocode}
% \end{macro}
-%
+%
%
%
% \subsection {Messages}
@@ -2890,7 +3588,7 @@ and the derived file cooking-units.sty.
% \end{macrocode}
% Error message if unit is not known to this package.
% \begin{macrocode}
-\msg_new:nnnn { cooking-units } { unknown - unit }
+\msg_new:nnnn { cooking-units } { unknown-unit }
{
The \ unit \ '#1' \ is \ not \ defined. \ Use \
\newcookingunit \ to \ define \ new \ units.
@@ -2937,7 +3635,7 @@ and the derived file cooking-units.sty.
% \end{macrocode}
% A second decimal sign is not allowed (No na net).
% \begin{macrocode}
-\msg_new:nnnn { cooking-units } { Second - decimal -sign - not - allowed }
+\msg_new:nnnn { cooking-units } { Second-decimal-sign-not-allowed }
{ A \ second \ decimal \ sign \ is \ not \ allowed. }
{
Perhaps \ you \ didn't \ type \ it \ correctly.
@@ -2946,7 +3644,7 @@ and the derived file cooking-units.sty.
% \end{macrocode}
% Error message for an undefined key.
% \begin{macrocode}
-\msg_new:nnnn { cooking-units } { Key - not -defined }
+\msg_new:nnnn { cooking-units } { Key-not-defined }
{
The \ key \ '#1' \ is \ not \ defined. \ Use \ \cudefinekeys or \
\cudefinesinglekey to \ define \ keys.
@@ -2956,13 +3654,17 @@ and the derived file cooking-units.sty.
\msg_see_documentation_text:n {cooking-units}
}
% \end{macrocode}
+%
% If the temperature is too low print this error message.
+% Now prints all units for which a zero-point is defined.
% \begin{macrocode}
-\msg_new:nnnn { cooking-units } { Temperature-to-low }
+\msg_new:nnnn { cooking-units } { Temperature-too-low }
{
- The \ temperature \ '#1' \ is \ to \ low.\ It \ cannot \ be \
+ The \ temperature \ '#1' \ is \ too \ low.\ It \ cannot \ be \
below \ the \ absolute \ zero - point \ of \ '#2'. \ Note \ that \
- by \ default \ the \ temperatures \ 'C', \ 'F' , \ 'K' \ and \ 'Re' \
+ the \ temperatures \
+ '\seq_use:Nnnn \l_@@_temperatures_to_check_seq
+ { ', ~ ' } { ', ~ ' } { ' ~ and ~ ' }' \
are \ rounded \ to \ integers.
\\\\
You \ can \ disable \ the \ option \ 'check-temperature' \ to \
@@ -2980,14 +3682,14 @@ and the derived file cooking-units.sty.
{
The \ key \ accepts \ accepts\ only \ a \ fixed \ set \ of \ choices. \
You \ can \ add \ new \ choices \ via \ \cuaddkeys, \ \cuaddsinglekeys \
- and \ \cuaddtokeys.
+ and \ \cuaddtokeys{}.
\msg_see_documentation_text:n {cooking-units}
}
% \end{macrocode}
%
%\changes {v0.98a} {2016/06/11} {New option: 'value-not-known'.}
%\changes {v0.99} {2016/06/12} {Renamed option: 'amount-not-known'.}
-% An info message that there are unknown values.
+% An info message for unknown messages.
% \begin{macrocode}
\msg_new:nnnn { cooking-units } { amount-not-known }
{
@@ -3002,7 +3704,7 @@ and the derived file cooking-units.sty.
}
% \end{macrocode}
%
-% If a load time option not used as a package option, but later, this
+% If a load time option is not used as a package option, this
% message is shown.
% \begin{macrocode}
\msg_new:nnnn { cooking-units } { load-time-option }
@@ -3017,8 +3719,7 @@ and the derived file cooking-units.sty.
}
% \end{macrocode}
%
-% If a load time option not used as a package option, but later, this
-% message is shown.
+% Messages for obsolete commands.
% \begin{macrocode}
\msg_new:nnnn { cooking-units } { obsolete-command }
{
@@ -3045,7 +3746,7 @@ and the derived file cooking-units.sty.
}
% \end{macrocode}
%
-%
+% Error message if a zero-point temperature is already defined.
% \begin{macrocode}
\msg_new:nnnn { cooking-units } { Minimum-already-defined }
{
@@ -3057,6 +3758,8 @@ and the derived file cooking-units.sty.
}
% \end{macrocode}
%
+% Using the key version of \mycs{culabel} one needs to give the number of
+% people the recipe is for after a \enquote{*}.
% \begin{macrocode}
\msg_new:nnnn { cooking-units } { Number-of-persons-missing }
{
@@ -3070,11 +3773,12 @@ and the derived file cooking-units.sty.
}
% \end{macrocode}
%
+% The number of persons, must be an integer \dots\
% \begin{macrocode}
\msg_new:nnnn { cooking-units } { Number-of-persons-is-not-an-integer }
{
The \ number \ of \ persons \ the \ recipe \ is \ for \ must \ be \ an \
- integer.
+ integer. \ '#1' \ is \ not \ allowed.
}
{
The \ number \ '#1' \ is \ not \ allowed.
@@ -3082,6 +3786,7 @@ and the derived file cooking-units.sty.
}
% \end{macrocode}
%
+% Each label defined by \mycs{culabel} needs to be new.
% \begin{macrocode}
\msg_new:nnnn { cooking-units } { label-already-defined }
{
@@ -3093,6 +3798,7 @@ and the derived file cooking-units.sty.
}
% \end{macrocode}
%
+% Message if a label is not defined.
% \begin{macrocode}
\msg_new:nnnn { cooking-units } { label-not-defined }
{
@@ -3105,6 +3811,7 @@ and the derived file cooking-units.sty.
}
% \end{macrocode}
%
+% If an unit is already defined and redefined by an \mycs{declarecookingunit}.
% \begin{macrocode}
\msg_new:nnnn { cooking-units } { redefine-unit }
{
@@ -3114,6 +3821,74 @@ and the derived file cooking-units.sty.
\msg_see_documentation_text:n { cooking-units }
}
% \end{macrocode}
+%
+% A \enquote{phrase} must be an integer.
+% \begin{macrocode}
+\msg_new:nnnn { cooking-units } { phrase-unit-not-an-integer }
+ {
+ A \ phrase \ must \ be \ an \ integer, \ '#1' \ is \ not \ allowed.
+ }
+ {
+ You \ can \ only \ use \ integers.
+ \msg_see_documentation_text:n { cooking-units }
+ }
+% \end{macrocode}
+%
+% A translation for \cs{cutext} or \cs{Cutext} is not available. For this case
+% -- instead of printing the keyname (see \pkg{translations}) -- we fall back
+% to \cs{cunum}.
+% \begin{macrocode}
+\msg_new:nnnn { cooking-units } { cutext-no-translation-available } %% ToDo
+ {
+ For \ the \ unit \ '#1' \ there \ exists \ no \ translation \ to \ be \ used \
+ for \ \cutext and \ \Cutext{}. \
+ You \ can \ define \ new \ translations \ for \ a \ given \ language \ using \
+ \cudefinename{}.
+ }
+ {
+ \cunum \ is \ used \ instead.
+ \msg_see_documentation_text:n { cooking-units }
+ }
+% \end{macrocode}
+%
+%
+% \begin{macrocode}
+\msg_new:nnnn { cooking-units } { Translation-not-available } %% ToDo
+ {
+ The \ translation \ for \ #1 \ does \ not \ exist.
+ Please \ define \ it \ using \ \cudefinename{}.
+ }
+ {
+ And \ you \ may \ send \ me \ the \ translation \ as \ it \ is \
+ not \ available \ yet.
+ \msg_see_documentation_text:n { cooking-units }
+ }
+% \end{macrocode}
+%
+%
+% \begin{macrocode}
+\msg_new:nnnn { cooking-units } { <-not-allowed-as-special-sign }
+ {
+ Currently \ (and \ probably \ forever) \ the \ sign \ '<' \
+ is \ not \ allowed \ to \ be \ used \ as \ a \ special \ sign.
+ }
+ {
+ I \ apologize \ for \ the \ inconvenience.
+ \msg_see_documentation_text:n { cooking-units }
+ }
+% \end{macrocode}
+%
+%
+% \begin{macrocode}
+\msg_new:nnnn { cooking-units } { unknown-gender }
+ {
+ '#1' \ is \ not \ allowed \ to \ be \ used \ as \ a \ gender-specification.
+ Only \ 'm', \ 'f' \ or \ 'n' \ are \ allowed
+ }{
+ Please \ remove \ spaces \ if \ there \ are \ some.
+ \msg_see_documentation_text:n { cooking-units }
+ }
+% \end{macrocode}
% \end{macro}
%
% \section {Helper Macros}
@@ -3129,7 +3904,7 @@ and the derived file cooking-units.sty.
% \begin{macrocode}
\cs_new:Npn \@@_error_if_unit_not_defined:n #1
{
- \clist_if_in:NnF \g_@@_list_of_defined_units_clist {#1}
+ \seq_if_in:NnF \g_@@_list_of_defined_units_seq {#1}
{ \msg_error:nnn { cooking-units } { unknown-unit } {#1} }
}
\cs_generate_variant:Nn \@@_error_if_unit_not_defined:n { V }
@@ -3141,13 +3916,11 @@ and the derived file cooking-units.sty.
%
%
%
-% \begin{macro}{ \@@_if_integer:n , \@@_if_integer_and_parse:n}
+% \begin{macro}{ \@@_if_integer:n , \@@_if_parse_and_integer:n}
% Checking if the input consists only of numbers. Furthermore tests if
% the input should be parsed at all.
-%
% \begin{macrocode}
-%\cs_new:Npn \@@_if_number_and_parse_aux: { }
-\prg_new_protected_conditional:Npnn \@@_if_integer:n #1 { TF }
+\prg_new_protected_conditional:Npnn \@@_if_integer:n #1 { TF , F , T }
{
\tl_map_inline:nn {#1}
{
@@ -3158,8 +3931,10 @@ and the derived file cooking-units.sty.
}
\use_i:nn \prg_return_true: \prg_return_false:
}
-%
-\prg_new_protected_conditional:Npnn \@@_if_integer_and_parse:n #1 { TF }
+\cs_generate_variant:Nn \@@_if_integer:nTF { V }
+\cs_generate_variant:Nn \@@_if_integer:nT { V }
+\cs_generate_variant:Nn \@@_if_integer:nF { V }
+\prg_new_protected_conditional:Npnn \@@_if_parse_and_integer:n #1 { TF }
{
\bool_if:NTF \l_@@_parse_input_bool
{
@@ -3169,73 +3944,110 @@ and the derived file cooking-units.sty.
}
{ \prg_return_false: }
}
-\cs_generate_variant:Nn \@@_if_integer_and_parse:nTF { V }
+\cs_generate_variant:Nn \@@_if_parse_and_integer:nTF { V }
% \end{macrocode}
% \end{macro}
%
+%
+%
+% \begin{macro}[TF]{ \@@_fp_if_equal_one:n}
+% \begin{macro}[TF]{ \@@_int_if_equal_one:n}
+% \begin{macrocode}
+\prg_new_conditional:Npnn \@@_fp_if_equal_one:n #1 { TF }
+ {
+ \fp_compare:nNnTF {#1} = { \c_one_fp }
+ { \prg_return_true: }
+ { \prg_return_false: }
+ }
+\prg_new_conditional:Npnn \@@_int_if_equal_one:n #1 { TF }
+ {
+ \int_compare:nNnTF {#1} = { \c_one }
+ { \prg_return_true: }
+ { \prg_return_false: }
+ }
+% \end{macrocode}
+% \end{macro} \end{macro}
+%
+%
+%
+% \begin{macro}{ \@@_check_if_correct_gender_input:n }
+% \begin{macrocode}
+\cs_new:Npn \@@_check_if_correct_gender_input:n #1
+ {
+ \str_case:nnF {#1}
+ {
+ { m } {}
+ { f } {}
+ { n } {}
+ } { \msg_error:nnn { cooking-units } { unknown-gender } {#1} }
+ }
+% \end{macrocode}
+% \end{macro}
+%
+%
+%
% \begin{macro}{\@@_convert_to_eV:}
% Still work in progress. Will probably forever be. Changes all
% predefined units into natural units (except for those who cannot
-% be changed, like Msp. for example). Is the same construct I use
-% later in \mycs{cunum}.
+% be changed, like Msp. for example).
+%
% \begin{macrocode}
+\seq_new:N \g_@@_natural_units_seq
+\prop_new:N \g_@@_convert_to_eV_remember_prop
+\seq_set_split:Nnn \g_@@_natural_units_seq { , }
+ {
+ eV ,
+ eVc-2 ,
+ hbareV-1 ,
+ chbareV-1 ,
+ (chbareV-1)3 ,
+ }
+\cs_new:Npn \@@_keys_set:nnn #1#2#3
+ {
+ \keys_set:nn {#1} { #2 = #3 }
+ }
+\cs_generate_variant:Nn \@@_keys_set:nnn { nVV , nVn }
\cs_new:Npn \@@_convert_to_eV:
{
- \keys_set:nn { cooking-units }
+ \prop_if_exist:cT { l_@@_cukeys_ \l_@@_given_unit_tl _prop }
{
- m= chbareV-1,
- cm= chbareV-1,
- dm= chbareV-1,
- mm= chbareV-1,
- in= chbareV-1,
- kg= eVc-2,
- dag= eVc-2,
- g= eVc-2,
- oz= eVc-2,
- lb= eVc-2,
- d= hbareV-1,
- h= hbareV-1,
- min= hbareV-1,
- s= hbareV-1,
- cal= eV,
- kcal= eV,
- J= eV,
- kJ= eV,
- F= eV,
- K= eV,
- C= eV,
- Re= eV,
- l= (chbareV-1)3 ,
- dl= (chbareV-1)3 ,
- cl= (chbareV-1)3 ,
- ml= (chbareV-1)3 ,
+ \prop_get:NVNTF \g_@@_convert_to_eV_remember_prop
+ \l_@@_given_unit_tl \l_@@_tmpa_tl
+ {
+ \@@_keys_set:nVV { cooking-units } \l_@@_given_unit_tl \l_@@_tmpa_tl
+ }{
+ \prop_get:cnNT { l_@@_cukeys_ \l_@@_given_unit_tl _prop } { Liste } \l_@@_tmpa_seq
+ {
+ \seq_map_inline:Nn \g_@@_natural_units_seq
+ {
+ \seq_if_in:NnT \l_@@_tmpa_seq {##1}
+ {
+ \prop_gput:NVn \g_@@_convert_to_eV_remember_prop
+ \l_@@_given_unit_tl {##1}
+ \@@_keys_set:nVn { cooking-units } \l_@@_given_unit_tl {##1}
+ \seq_map_break:
+ }
+ }
+ }
+ }
}
}
% \end{macrocode}
%\end{macro}
%
-% \begin{macro}{\@@_deftranslation:Nnn}
-% \begin{macrocode}
-\cs_new:Npn \@@_deftranslation:Nnn #1#2#3
- {
- \deftranslation [ to=#1 ] {#2} {#3}
- }
-\cs_generate_variant:Nn \@@_deftranslation:Nnn { Vnn , Vnv }
-% \end{macrocode}
-% \end{macro}
+%
+%
%
% \begin{macro}{\@@_tl_set_fp_and_eval:Nn}
% I am using this construction often enough, so \dots\ yeah.
% \begin{macrocode}
\cs_new:Npn \@@_tl_set_fp_and_eval:Nn #1#2
- {
- \tl_set:Nf #1 { \fp_eval:n {#2} }
- }
+ { \tl_set:Nx #1 { \fp_eval:n {#2} } }
\cs_generate_variant:Nn \@@_tl_set_fp_and_eval:Nn { Nc }
% \end{macrocode}
% \end{macro}
%
-% \begin{macro}{\@@_deftranslation:Nnn}
+% \begin{macro}{\@@_temperature_to_check_print_error:n,\@@_temperatures_to_check_define:nn}
% Commands used in the option \texttt{temperature-to-check}.
% If no value is given (first command) it raises an error. If a value
% is given the unit is added to a check-list and a new
@@ -3251,7 +4063,7 @@ and the derived file cooking-units.sty.
\fp_if_exist:cTF { c_@@_ #1 _min_fp }
{ \msg_warning:nnn { cooking-units } { Minimum-already-defined } {#1} }
{
- \clist_put_right:Nn \l_@@_temperatures_to_check_clist {#1}
+ \seq_put_right:Nn \l_@@_temperatures_to_check_seq {#1}
\fp_const:cn { c_@@_ #1 _min_fp } {#2}
}
}
@@ -3259,15 +4071,17 @@ and the derived file cooking-units.sty.
% \end{macro}
%
% \begin{macro}{\@@_rounding_function:n}
+% I think this definition is somewhat stupid, but I don't have a better idea.
% \begin{macrocode}
\cs_new:Npn \@@_rounding_function:n #1
- {
+ {
#1
\bool_if:NTF \l_@@_round_commercial_bool
{
+ ,
\bool_if:NTF \l_@@_round_to_int_bool
- { , \c_zero_fp }
- { , \l_@@_significant_figures_int }
+ { \c_zero_fp }
+ { \l_@@_significant_figures_int }
, #1
}
{ \bool_if:NF \l_@@_round_to_int_bool { , \l_@@_significant_figures_int } }
@@ -3279,86 +4093,84 @@ and the derived file cooking-units.sty.
% \begin{macrocode}
\cs_new:Npn \@@_label_and_persons:n #1
{
- \tl_if_in:nnTF {#1} { @ }
+ \tl_if_in:nnTF {#1} { * }
{
- \@@_label_and_persons_for_persons:ww #1 \q_stop
+ \@@_label_and_persons_times_persons:ww #1 \q_stop
}{
- \tl_if_in:nnTF {#1} { * }
- {
- \@@_label_and_persons_times_persons:ww #1 \q_stop
- }{
- \msg_error:nnn { cooking-units} { Number-of-persons-missing } {#1}
- }
+ \msg_error:nnn { cooking-units} { Number-of-persons-missing } {#1}
}
}
% \end{macrocode}
% \end{macro}
%
% \begin{macrocode}
-\cs_new:Npn \@@_label_and_persons_for_persons:ww #1 @ #2 \q_stop
+\cs_new:Npn \@@_label_and_persons_times_persons:ww #1 * #2 \q_stop
{
- \@@_culabel:nnn {#1} {#2} { }
+ \@@_culabel:nn {#1} {#2}
}
% \end{macrocode}
+%
+% \begin{macro}{ \@@_culabel:nn , \@@_curef:n }
% \begin{macrocode}
-\cs_new:Npn \@@_label_and_persons_times_persons:ww #1 * #2 \q_stop
+\cs_new:Npn \@@_culabel:nn #1#2
{
- \@@_culabel:nnn {#1} {#2} { - }
+ \int_if_exist:cTF { l_@@_number_of_persons_ #1 _int }
+ {
+ \msg_error:nnn { cooking-units } { label-already-defined } {#1}
+ }{
+ \@@_if_integer:nTF {#2}
+ {
+ \int_new:c { l_@@_number_of_persons_ #1 _int }
+ \int_gset:cn { l_@@_number_of_persons_ #1 _int } {#2}
+ }
+ { \msg_error:nnn { cooking-units } { Number-of-persons-is-not-an-integer } {#2} }
+ }
}
% \end{macrocode}
+% \end{macro}
%
% \begin{macro}{ \@@_reference_label_and_persons:n }
% \begin{macrocode}
\cs_new:Npn \@@_reference_label_and_persons:n #1
{
- \int_if_exist:cTF { l_@@_persons_ #1 _int }
+ \int_if_exist:cTF { l_@@_number_of_persons_ #1 _int }
{
\bool_set_true:N \l_@@_calc_because_ref_was_given_bool
- \int_set:Nn \l_@@_persons_tmp_int
- {
- \int_abs:c { l_@@_persons_ #1 _int }
- }
+ \int_set_eq:Nc \l_@@_number_of_persons_tmpa_int
+ { l_@@_number_of_persons_ #1 _int }
}
{ \msg_error:nnn { cooking-units } { label-not-defined } {#1} }
}
% \end{macrocode}
% \end{macro}
%
-% \begin{macro}{ \@@_culabel:nn , \@@_curef:n }
+% \begin{macro}{ \@@_curef:n }
% \begin{macrocode}
-\cs_new:Npn \@@_culabel:nnn #1#2#3
- {
- \int_if_exist:cTF { l_@@_persons_ #1 _int }
- {
- \msg_error:nnn { cooking-units } { label-already-defined } {#1}
- }{
- \@@_if_integer:nTF {#2}
- {
- \int_new:c { l_@@_persons_ #1 _int }
- \int_gset:cn { l_@@_persons_ #1 _int } { #3 #2 }
- }
- { \msg_error:nnn { cooking-units } { Number-of-persons-is-not-an-integer } {#2} }
- }
- }
\cs_new:Npn \@@_curef:n #1
{
- \int_if_exist:cTF { l_@@_persons_ #1 _int }
+ \int_if_exist:cTF { l_@@_number_of_persons_ #1 _int }
{
\bool_if:NTF \l_@@_calc_for_persons_bool
{ \int_use:N \l_@@_calc_for_number_of_persons_int }
- { \int_abs:c { l_@@_persons_ #1 _int } }
+ { \int_use:c { l_@@_number_of_persons_ #1 _int } }
}{ \msg_error:nnn { cooking-units } { label-not-defined } {#1} }
}
-\NewDocumentCommand \culabel { m m } { \@@_culabel:nnn {#1} {#2} {} }
-\DeclareExpandableDocumentCommand \curef { m } { \@@_curef:n {#1} }
% \end{macrocode}
% \end{macro}
%
+% \begin{macro}{ \culabel , \curef }
+% \begin{macrocode}
+\NewDocumentCommand \culabel { m m } { \@@_culabel:nn {#1} {#2} }
+\NewExpandableDocumentCommand \curef { m } { \@@_curef:n {#1} }
+% \end{macrocode}
+% \end{macro}
%
%
%
%
% \begin{macro}{ \@@_tl_if_in_remove_and_set_bool:NnN }
+% Can probably optimize this as the sign is always at the first place
+% (this is done after cheking the input, so the asumption is safe), but yeah \dots
% \begin{macrocode}
\cs_new:Npn \@@_tl_if_in_remove_and_set_bool:NnN #1#2#3
{
@@ -3366,9 +4178,8 @@ and the derived file cooking-units.sty.
{
\bool_set_true:N #3
\tl_remove_once:Nn #1 {#2}
- }{
- \bool_set_false:N #3
}
+ { \bool_set_false:N #3 }
}
% \end{macrocode}
% \end{macro}
@@ -3390,6 +4201,143 @@ and the derived file cooking-units.sty.
%
%
%
+% \subsection{Language Macros}
+%
+% \begin{macrocode}
+\tl_const:Nn \c_@@_postfix_unit_tl { ( cu-unit ) }
+\tl_const:Nn \c_@@_postfix_unit_pl_tl { ( cu-unit-pl ) }
+\tl_const:Nn \c_@@_postfix_unitname_tl { ( cu-unitname ) }
+\tl_const:Nn \c_@@_postfix_unitname_pl_tl { ( cu-unitname-pl ) }
+\tl_const:Nn \c_@@_postfix_gender_tl { ( cu-unitgender ) }
+\tl_const:Nn \c_@@_postfix_phrase_tl { ( cu-unitphrase ) }
+% \end{macrocode}
+%
+% \begin{macro}{ \@@_deftranslation:nn }
+% \begin{macro}{ \@@_deftranslation:xxn , \@@_deftranslation:Vnv}
+% \begin{macrocode}
+\cs_new:Npn \@@_deftranslation_base:nnn #1#2#3
+ {
+ \declaretranslationfallback { #1 #2 } {#3}
+ }
+\cs_new:Npn \@@_deftranslation_to:nnnn #1#2#3#4
+ {
+ \declaretranslation {#1} { #2 #3 } {#4}
+ }
+\cs_generate_variant:Nn \@@_deftranslation_base:nnn { xx , xxV }
+\cs_generate_variant:Nn \@@_deftranslation_to:nnnn { Vxxv, VxxV , Vxxn, Vxxx,Vxxo,Vxxf }
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
+%
+%
+% \begin{macro}{\@@_newtranslation:xxn }
+% \begin{macro}{\@@_newtranslation:nxxn }
+% \begin{macrocode}
+\cs_new:Npn \@@_newtranslation_base:nnn #1#2#3
+ {
+ \definetranslationfallback { #1 #2 } {#3}
+ }
+\cs_new:Npn \@@_newtranslation_to:nnnn #1#2#3#4
+ {
+ \definetranslation {#1} { #2 #3 } {#4}
+ }
+\cs_generate_variant:Nn \@@_newtranslation_base:nnn { nVn }
+\cs_generate_variant:Nn \@@_newtranslation_to:nnnn { nnVn }
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
+%
+% \begin{macro}{\@@_translate:nn , \@@_translate:xx }
+% \begin{macro}{\@@_translate_let:Nxx , \@@_translate_let:Nxx }
+% \begin{macrocode}
+\cs_new:Npn \@@_translate:nn #1#2
+ {
+ \GetTranslation { #1 #2 }
+ }
+\cs_new:Npn \@@_translate_let:Nnn #1#2#3
+ {
+ \SaveTranslation {#1} { #2 #3 }
+ }
+\cs_new:Npn \@@_translate_let:nNnn #1#2#3#4
+ {
+ \SaveTranslationFor {#2} {#1} { #3 #4 }
+ }
+\cs_generate_variant:Nn \@@_translate:nn { xx }
+\cs_generate_variant:Nn \@@_translate_let:Nnn { Nxx }
+\cs_generate_variant:Nn \@@_translate_let:nNnn { VNxx, nNxx }
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}[TF]{\@@_unitname_get:Nn,\@@_unitname_get:Nx }
+% \begin{macrocode}
+\prg_new_conditional:Npnn \@@_unitname_get:Nn #1#2 { F }
+ {
+ \@@_translate_let:Nxx #1 {#2} \c_@@_postfix_unitname_tl
+ \tl_if_eq:NNTF #1 \q_@@_no_translation
+ { \prg_return_false: }
+ { \prg_return_true: }
+ }
+\cs_generate_variant:Nn \@@_unitname_get:NnF { Nx }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\@@_translate_one_to_and_check_existance:Nx }
+% \begin{macrocode}
+\cs_new:Npn \@@_translate_one_to_and_check_existance:Nx #1#2
+ {
+ \@@_translate_let:Nxx #1 {#2} \c_@@_postfix_gender_tl
+ \@@_unitname_get:NxF #1 { one (#1) }
+ {
+ \@@_translate_let:Nxx #1 {#2} \c_@@_postfix_gender_tl
+ \msg_error:nnn { cooking-units } { Translation-not-available } { one (#1) }
+ }
+ }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{ decimal-mark, one(m), one(f), one(n) }
+% Defining the translation for the decimal-mark. Note that those
+% 'phrases' are stored inside
+% \verb|\g_@@_allowed_special_keys_clist|.
+% Furthermore some translations are defined.
+% \begin{macrocode}
+\clist_gset:Nn \g_@@_allowed_special_keys_clist
+ {
+ decimal-mark ,
+ one (m) ,
+ one (f) ,
+ one (n)
+ }
+% \end{macrocode}
+% \end{macro}
+% \begin{macrocode}
+\@@_newtranslation_base:nVn { decimal-mark } \c_@@_postfix_unitname_tl { . }
+\@@_newtranslation_base:nVn { decimal-mark } \c_@@_postfix_unitname_pl_tl { \q_@@_no_translation }
+\@@_newtranslation_to:nnVn { German } { decimal-mark } \c_@@_postfix_unitname_tl { , }
+% \end{macrocode}
+% Note that the plural versions just exist for completing the set.
+% \begin{macrocode}
+\@@_newtranslation_base:nVn { one (m) } \c_@@_postfix_unitname_tl { \q_@@_no_translation }
+\@@_newtranslation_base:nVn { one (f) } \c_@@_postfix_unitname_tl { \q_@@_no_translation }
+\@@_newtranslation_base:nVn { one (n) } \c_@@_postfix_unitname_tl { \q_@@_no_translation }
+\@@_newtranslation_base:nVn { one (m) } \c_@@_postfix_unitname_pl_tl { \q_@@_no_translation }
+\@@_newtranslation_base:nVn { one (f) } \c_@@_postfix_unitname_pl_tl { \q_@@_no_translation }
+\@@_newtranslation_base:nVn { one (n) } \c_@@_postfix_unitname_pl_tl { \q_@@_no_translation }
+% \end{macrocode}
+% \begin{macrocode}
+\@@_newtranslation_to:nnVn { English } { one (m) } \c_@@_postfix_unitname_tl { one }
+\@@_newtranslation_to:nnVn { English } { one (f) } \c_@@_postfix_unitname_tl { one }
+\@@_newtranslation_to:nnVn { English } { one (n) } \c_@@_postfix_unitname_tl { one }
+% \end{macrocode}
+% \begin{macrocode}
+\@@_newtranslation_to:nnVn { German } { one (m) } \c_@@_postfix_unitname_tl { ein }
+\@@_newtranslation_to:nnVn { German } { one (f) } \c_@@_postfix_unitname_tl { eine }
+\@@_newtranslation_to:nnVn { German } { one (n) } \c_@@_postfix_unitname_tl { ein }
+% \end{macrocode}
+%
%
%
%
@@ -3397,17 +4345,21 @@ and the derived file cooking-units.sty.
%
% This section contains macros helping an checking the input.
%
-% \begin{macro}{ \@@_cunum_parse_input:N, \@@_cunum_parse_input:V }
+% \begin{macro}{ \@@_parse_input:N, \@@_parse_input:V }
% Splits the input into fractions or ranges (\lstinline|q_@@_range|).
% Depending on the input on of the four macros are used.
% \begin{macrocode}
-\cs_new:Npn \@@_cunum_parse_input:N #1
+\cs_new:Npn \@@_parse_input:N #1
{
- \bool_if:NTF \l_@@_parse_range_bool
+ \bool_if:NTF \l_@@_range_in_input_bool
{ \@@_parse_range_in_input:ww #1 \q_stop }
{
\tl_if_in:nnTF {#1} { / }
- {
+ {
+ \bool_lazy_or:nnTF
+ { \l_@@_calc_persons_bool }{ \l_@@_eval_fractions_bool }
+ { \bool_set_false:N \l_@@_fraction_in_input_bool }
+ { \bool_set_true:N \l_@@_fraction_in_input_bool }
\tl_if_in:nnTF {#1} { _ }
{ \@@_parse_mixed_fraction_in_input:www #1 \q_stop }
{ \@@_parse_fraction_in_input:ww #1 \q_stop }
@@ -3415,7 +4367,7 @@ and the derived file cooking-units.sty.
{ \@@_parse_number_in_input:n {#1} }
}
}
-\cs_generate_variant:Nn \@@_cunum_parse_input:N { V }
+\cs_generate_variant:Nn \@@_parse_input:N { V }
% \end{macrocode}
% \end{macro}
%
@@ -3427,8 +4379,15 @@ and the derived file cooking-units.sty.
% \begin{macrocode}
\cs_new:Npn \@@_parse_number_in_input:n #1
{
- \@@_parse_input_and_safe_in:nN {#1} \l_@@_tmpa_tl
- \@@_calculate_and_print_input:N \l_@@_tmpa_tl
+ \@@_parse_input_and_safe_in:nN {#1} \l_@@_number_tmpa_tl
+ \@@_process_and_print_number_in_input:N \l_@@_number_tmpa_tl
+ }
+\cs_new:Npn \@@_process_and_print_number_in_input:N #1
+ {
+ \@@_pre_process_input:NN #1 \q_no_value
+ \@@_calculate_and_store_in:N #1
+ \@@_post_process_input:NN #1 \q_no_value
+ \@@_print_input:N #1
}
% \end{macrocode}
% \end{macro}
@@ -3441,13 +4400,17 @@ and the derived file cooking-units.sty.
% \begin{macrocode}
\cs_new:Npn \@@_parse_range_in_input:ww #1 \q_@@_range #2 \q_stop
{
- \@@_parse_input_and_safe_in:nN {#1} \l_@@_tmpa_tl
- \@@_parse_input_and_safe_in:nN {#2} \l_@@_tmpb_tl
- \@@_calculate_and_print_input:N \l_@@_tmpa_tl
+ \@@_parse_input_and_safe_in:nN {#1} \l_@@_number_tmpa_tl
+ \@@_parse_input_and_safe_in:nN {#2} \l_@@_number_tmpb_tl
+ \@@_pre_process_input:NN \l_@@_number_tmpa_tl \l_@@_number_tmpb_tl
+ \@@_calculate_and_store_in:N \l_@@_number_tmpa_tl
+ \@@_calculate_and_store_in:N \l_@@_number_tmpb_tl
+ \@@_post_process_input:NN \l_@@_number_tmpa_tl \l_@@_number_tmpb_tl
+ \@@_print_input:N \l_@@_number_tmpa_tl
\bool_if:NTF \l_@@_using_cutext_bool
{ \tl_use:N \l_@@_cutext_range_sign_tl }
{ \tl_use:N \l_@@_cunum_range_sign_tl }
- \@@_calculate_and_print_input:N \l_@@_tmpb_tl
+ \@@_print_input:N \l_@@_number_tmpb_tl
}
% \end{macrocode}
% \end{macro}
@@ -3458,28 +4421,28 @@ and the derived file cooking-units.sty.
% If fractions should be evaluated the input is \dots\ well,
% evaluated and printed. Otherwise the input is given to
% another function which prints the fractions. Note that the empty
-% argument in \lstinline|\@@_formatiere_fractions:nNN| indicates a
+% argument in \lstinline|\@@_formatiere_fractions:nnn| indicates a
% \enquote{normal} fraction.
% \begin{macrocode}
\cs_new:Npn \@@_parse_fraction_in_input:ww #1/#2 \q_stop
{
- \@@_parse_input_and_safe_in:nN {#1} \l_@@_tmpa_tl
- \@@_parse_input_and_safe_in:nN {#2} \l_@@_tmpb_tl
- \bool_if:nTF
- {
- \l_@@_calc_persons_tmp_bool ||
- \l_@@_eval_fractions_bool
- }
+ \@@_parse_input_and_safe_in:nN {#1} \l_@@_number_tmpa_tl
+ \@@_parse_input_and_safe_in:nN {#2} \l_@@_number_tmpb_tl
+% \bool_if:NTF \l_@@_fraction_in_input_bool
+ \bool_lazy_or:nnTF
+ { \l_@@_fraction_in_input_bool }
+ { \l_@@_special_sign_bool }
{
- \@@_calculate_and_print_input:n
- { \l_@@_tmpa_tl / \l_@@_tmpb_tl }
- }{
- \@@_tl_if_in_remove_and_set_bool:NnN \l_@@_tmpa_tl { - } \l_tmpb_bool
- \@@_tl_if_in_remove_and_reverse_bool:NnN \l_@@_tmpb_tl { - } \l_tmpb_bool
- \@@_formatiere_fractions:nNN
+ \@@_tl_if_in_remove_and_set_bool:NnN \l_@@_number_tmpa_tl { - } \l_@@_minus_bool
+ \@@_tl_if_in_remove_and_reverse_bool:NnN \l_@@_number_tmpb_tl { - } \l_@@_minus_bool
+ \@@_formatiere_fractions:nnn
{ }
- { \l_@@_tmpa_tl }
- { \l_@@_tmpb_tl }
+ { \l_@@_number_tmpa_tl }
+ { \l_@@_number_tmpb_tl }
+ }{
+ \@@_tl_set_fp_and_eval:Nn \l_@@_number_tmpa_tl
+ { \l_@@_number_tmpa_tl / \l_@@_number_tmpb_tl }
+ \@@_process_and_print_number_in_input:N \l_@@_number_tmpa_tl
}
}
% \end{macrocode}
@@ -3490,7 +4453,8 @@ and the derived file cooking-units.sty.
% function!
%
% If it should be evaluated it is important to check if the mixed-fraction
-% part is positive or negative.
+% part is positive or negative. That's why the minuses are removed \emph{before}
+% checking if there is a fraction (in opposite to the command before).
%
% \begin{align}
% \cuam{1_2/3} &= 1 + 2/3 \\
@@ -3501,49 +4465,50 @@ and the derived file cooking-units.sty.
\cs_new:Npn \@@_parse_mixed_fraction_in_input:www #1_#2/#3 \q_stop
{
\@@_parse_input_and_safe_in:nN {#1} \l_@@_mixed_fraction_tl
- \@@_parse_input_and_safe_in:nN {#2} \l_@@_tmpa_tl
- \@@_parse_input_and_safe_in:nN {#3} \l_@@_tmpb_tl
- \@@_tl_if_in_remove_and_set_bool:NnN \l_@@_mixed_fraction_tl { - } \l_tmpb_bool
- \@@_tl_if_in_remove_and_reverse_bool:NnN \l_@@_tmpa_tl { - } \l_tmpb_bool
- \@@_tl_if_in_remove_and_reverse_bool:NnN \l_@@_tmpb_tl { - } \l_tmpb_bool
- \bool_if:nTF
+ \@@_parse_input_and_safe_in:nN {#2} \l_@@_number_tmpa_tl
+ \@@_parse_input_and_safe_in:nN {#3} \l_@@_number_tmpb_tl
+ \@@_tl_if_in_remove_and_set_bool:NnN \l_@@_mixed_fraction_tl { - } \l_@@_minus_bool
+ \@@_tl_if_in_remove_and_reverse_bool:NnN \l_@@_number_tmpa_tl { - } \l_@@_minus_bool
+ \@@_tl_if_in_remove_and_reverse_bool:NnN \l_@@_number_tmpb_tl { - } \l_@@_minus_bool
+ \bool_lazy_or:nnTF
+ { \l_@@_fraction_in_input_bool }
+ { \l_@@_special_sign_bool }
{
- \l_@@_calc_persons_tmp_bool ||
- \l_@@_eval_fractions_bool
+ \@@_formatiere_fractions:nnn
+ { \l_@@_mixed_fraction_tl }
+ { \l_@@_number_tmpa_tl }
+ { \l_@@_number_tmpb_tl }
}{
- \@@_calculate_and_print_input:n
- {
- \bool_if:NTF \l_tmpb_bool
-% \l_@@_mixed_fraction_tl
-% \fp_compare:nNnTF
-% { \l_@@_mixed_fraction_tl } < { \c_zero_fp }
+ \@@_tl_set_fp_and_eval:Nn \l_@@_number_tmpa_tl
+ {
+ \bool_if:NTF \l_@@_minus_bool
{ - \l_@@_mixed_fraction_tl - }
{ \l_@@_mixed_fraction_tl + }
- \l_@@_tmpa_tl / \l_@@_tmpb_tl
+ \l_@@_number_tmpa_tl / \l_@@_number_tmpb_tl
}
- }{
- \@@_formatiere_fractions:nNN
- { \l_@@_mixed_fraction_tl }
- { \l_@@_tmpa_tl }
- { \l_@@_tmpb_tl }
+ \@@_process_and_print_number_in_input:N \l_@@_number_tmpa_tl
}
}
% \end{macrocode}
% \end{macro}
%
+%
+%
+%
+%
% \begin{macro}{ \@@_parse_input_and_safe_in:nN }
-% Used to check the input. \lstinline|\l_tmpa_tl| is cleared
+% Used to check the input. \lstinline|\l_@@_tmpa_tl| is cleared
% at the beginning. At first it checks if the first token
-% is a sign or not. The parsed input is stored into \lstinline|\l_tmpa_tl|.
+% is a sign or not. The parsed input is stored into \lstinline|\l_@@_tmpa_tl|.
% \begin{macrocode}
\cs_new:Npn \@@_parse_input_and_safe_in:nN #1 #2
{
- \tl_clear:N \l_tmpa_tl
+ \tl_clear:N \l_@@_tmpa_tl
\bool_set_false:N \l_@@_decimal_in_input_bool
\@@_parse_vorzeichen_and_rest:Nw #1 \q_stop
\bool_if:NTF \l_@@_error_bool
{ \tl_set:Nn #2 {#1} }
- { \tl_set_eq:NN #2 \l_tmpa_tl }
+ { \tl_set_eq:NN #2 \l_@@_tmpa_tl }
}
% \end{macrocode}
% \end{macro}
@@ -3552,7 +4517,7 @@ and the derived file cooking-units.sty.
% This function seperates the input into two parts with the first
% part being the first token. This token is checked whetever or not
% it is a sign. If it is a sign it is put into
-% \lstinline|\l_tmpa_tl|, if not it is checked normally by
+% \lstinline|\l_@@_tmpa_tl|, if not it is checked normally by
% \lstinline|\@@_parse_input_for_safety_aux:N|. \#2 (the other
% tokens) is then given to \lstinline|\tl_map_function:nN|. This
% also works if the input only conists of one token with \#2 being
@@ -3560,8 +4525,8 @@ and the derived file cooking-units.sty.
% \begin{macrocode}
\cs_new:Npn \@@_parse_vorzeichen_and_rest:Nw #1#2 \q_stop
{
- \tl_if_in:NnTF \l_@@_value_signs_tl {#1}
- { \tl_put_right:Nn \l_tmpa_tl {#1} }
+ \tl_if_in:NnTF \l_@@_input_value_signs_tl {#1}
+ { \tl_put_right:Nn \l_@@_tmpa_tl {#1} }
{
\tl_map_function:nN {#1} \@@_parse_input_for_safety_aux:N
}
@@ -3581,24 +4546,24 @@ and the derived file cooking-units.sty.
\cs_new:Npn \@@_parse_input_for_safety_aux:N #1
{
\tl_if_in:NnTF \l_@@_input_digits_tl {#1}
- { \tl_put_right:Nn \l_tmpa_tl {#1} }
+ { \tl_put_right:Nn \l_@@_tmpa_tl {#1} }
{
- \tl_if_in:NnTF \l_@@_decimal_mark_tl {#1}
+ \tl_if_in:NnTF \l_@@_input_decimal_mark_tl {#1}
{
\bool_if:NT \l_@@_decimal_in_input_bool
{
\msg_error:nn { cooking-units }
- { Second - decimal -sign - not - allowed }
+ { Second-decimal-sign-not-allowed }
}
\bool_set_true:N \l_@@_decimal_in_input_bool
- \tl_put_right:Nn \l_tmpa_tl { . }
+ \tl_put_right:Nn \l_@@_tmpa_tl { . }
}{
- \tl_if_in:NnTF \l_@@_allowed_special_signs_tl {#1}
+ \tl_if_in:NnTF \l_@@_input_allowed_special_signs_tl {#1}
{
\bool_set_true:N \l_@@_special_sign_bool
- \tl_put_right:Nn \l_tmpa_tl {#1}
+ \tl_put_right:Nn \l_@@_tmpa_tl {#1}
}{
- \bool_if:NTF \l_@@_parse_range_bool
+ \bool_if:NTF \l_@@_range_in_input_bool
{
\tl_if_in:nnTF { / _ } {#1}
{ \msg_error:nnn { cooking-units } { fraction-not-allowed-with-range } {#1} }
@@ -3619,41 +4584,38 @@ and the derived file cooking-units.sty.
%
% \subsection {Formatiere \& Calculiere}
%
-% \begin{macro}{ \@@_calculate_and_print_input:n , \@@_calculate_and_print_input:N }
+% \begin{macro}{ \@@_calculate_and_store_in:N }
%
% \changes {v0.98a} {2016/06/11} {Added warning to show if an unknown value is used.}
%
% After parsing the input, it is given to this function. If a not
% allowed token is found (and \lstinline|\l_@@_error_bool| is set to
% true) it just prints the input. Otherwise it checks if a allowed sign was
-% found. If so it is just stored inside \lstinline|\l_tmpa_tl|,
-% otherwise it is calulcated and stored in \lstinline|\l_tmpa_tl|. The input
+% found. If so it is just stored inside \lstinline|\l_@@_tmpa_tl|,
+% otherwise it is calulcated and stored in \lstinline|\l_@@_tmpa_tl|. The input
% \#1 can be either a token or a number.
% \begin{macrocode}
-\cs_new:Npn \@@_calculate_and_print_input:n #1
+\cs_new:Npn \@@_calculate_and_store_in:N #1
{
- \bool_if:NTF \l_@@_error_bool
- {#1}
+ \bool_if:NF \l_@@_error_bool
{
\bool_if:NTF \l_@@_special_sign_bool
{
- \tl_set:Nf \l_tmpa_tl {#1}
- \msg_warning:nnx { cooking-units } { amount-not-known } \l_tmpa_tl
- }
- {
- \bool_if:nTF
- { \l_@@_using_cutext_bool && ! \l_@@_cutext_change_unit_bool }
- { \tl_set:Nf \l_tmpa_tl {#1} }
- { \@@_calculate_input_and_store_in:nN {#1} \l_tmpa_tl }
- \bool_if:NT \l_@@_calc_persons_tmp_bool
- { \@@_calc_for_number_of_persons_and_store_in:NN \l_tmpa_tl \l_tmpa_tl }
- \@@_round_calculated_input:NV \l_tmpa_tl \l_tmpa_tl
- \@@_check_temperature_limit:N \l_tmpa_tl
+ \tl_set_eq:NN \l_@@_tmpa_tl #1
+ \msg_warning:nnx { cooking-units } { amount-not-known } \l_@@_tmpa_tl
+ }{
+ \bool_lazy_and:nnTF
+ { \l_@@_using_cutext_bool } { ! \l_@@_cutext_change_unit_bool }
+ { \tl_set_eq:NN \l_@@_tmpa_tl #1 }
+ { \@@_calculate_input_and_store_in:nN {#1} \l_@@_tmpa_tl }
+ \bool_if:NT \l_@@_calc_persons_bool
+ { \@@_calc_for_number_of_persons_and_store_in:NN \l_@@_tmpa_tl \l_@@_tmpa_tl }
+ \@@_round_calculated_input:NV \l_@@_tmpa_tl \l_@@_tmpa_tl
+ \@@_check_temperature_limit:N \l_@@_tmpa_tl
}
- \@@_print_output:N \l_tmpa_tl
+ \tl_set_eq:NN #1 \l_@@_tmpa_tl
}
}
-\cs_generate_variant:Nn \@@_calculate_and_print_input:n { N }
% \end{macrocode}
% \end{macro}
%
@@ -3662,26 +4624,20 @@ and the derived file cooking-units.sty.
% \@@_calculate_input_and_store_in:nN ,
% }
% Well \dots\ this function calculates the input. First checks if the
-% wanted conversion contains a \lstinline|\l_tmpa_fp| (ergo a \#1 in
+% wanted conversion contains a \lstinline|\l_@@_tmpa_fp| (ergo a \#1 in
% the key definition). If true the conversion token (which already has
-% \lstinline|\l_tmpa_fp| in its input) is executed, else the input
+% \lstinline|\l_@@_tmpa_fp| in its input) is executed, else the input
% number is multiplicated with the conversion token.
% \begin{macrocode}
\cs_new:Npn \@@_calculate_input_and_store_in:nN #1#2
{
- \fp_set:Nn \l_tmpa_fp {#1}
- \tl_if_in:cnTF { l_@@_tmpa_ \l_@@_tmp_unit_tl _ tl } { \l_tmpa_fp }
+ \fp_set:Nn \l_@@_tmpa_fp {#1}
+ \tl_if_in:cnTF { l_@@_tmpa_ \l_@@_given_unit_tl _ tl } { \l_@@_tmpa_fp }
{
- \@@_tl_set_fp_and_eval:Nc #2 { l_@@_tmpa_ \l_@@_tmp_unit_tl _ tl }
+ \@@_tl_set_fp_and_eval:Nc #2 { l_@@_tmpa_ \l_@@_given_unit_tl _ tl }
}{
\@@_tl_set_fp_and_eval:Nn #2
- { \l_tmpa_fp * \tl_use:c { l_@@_tmpa_ \l_@@_tmp_unit_tl _ tl } }
-% \tl_set:Nf #2
-% {
-% \fp_compare:vNnTF { l_@@_tmpa_ \l_@@_tmp_unit_tl _ tl } = { \c_one_fp }
-% {#1}
-% \fp_eval:n { \l_tmpa_fp * \tl_use:c { l_@@_tmpa_ \l_@@_tmp_unit_tl _ tl } }
-% }
+ { \l_@@_tmpa_fp * \tl_use:c { l_@@_tmpa_ \l_@@_given_unit_tl _ tl } }
}
}
% \end{macrocode}
@@ -3694,12 +4650,12 @@ and the derived file cooking-units.sty.
\int_compare:nNnF
{ \l_@@_calc_for_number_of_persons_int }
=
- { \l_@@_persons_tmp_int }
+ { \l_@@_number_of_persons_tmpa_int }
{
\@@_tl_set_fp_and_eval:Nn #1
{
\l_@@_calc_for_number_of_persons_int /
- \l_@@_persons_tmp_int *
+ \l_@@_number_of_persons_tmpa_int *
#2
}
}
@@ -3707,7 +4663,7 @@ and the derived file cooking-units.sty.
% \end{macrocode}
%
%
-% \begin{macro}{\@@_check_number_after_dot:n,\@@_check_number_after_dot_aux:w}
+% \begin{macro}{\@@_check_number_for_rounding:n,\@@_check_number_after_dot_aux:w}
% Getting the number after the decimal point. If it doesn't exist
% the boolean is set to false, otherwise it checks how many tokens
% are within the number after the decimal point. If the number of
@@ -3715,8 +4671,9 @@ and the derived file cooking-units.sty.
% set to true (which tells the package later that the number should
% be rounded). This should be safe as the input was already checked.
% \begin{macrocode}
-\cs_new:Npn \@@_check_number_after_dot:n #1
+\cs_new:Npn \@@_check_number_for_rounding:n #1
{
+ \bool_set_false:N \l_@@_round_decimal_part_bool
\@@_check_number_after_dot_aux:w #1 . \q_recursion_tail .
\q_recursion_stop
}
@@ -3726,10 +4683,9 @@ and the derived file cooking-units.sty.
\bool_if:NTF \l_@@_round_to_int_bool
{ \int_zero:N \l_tmpa_int }
{ \int_set_eq:NN \l_tmpa_int \l_@@_significant_figures_plus_one_int }
- \int_compare:nNnTF
+ \int_compare:nNnF
{ \tl_count:n {#2} } < { \l_tmpa_int }
- { \bool_set_false:N \l_tmpa_bool }
- { \bool_set_true:N \l_tmpa_bool }
+ { \bool_set_true:N \l_@@_round_decimal_part_bool }
\use_none_delimit_by_q_recursion_stop:w
}
% \end{macrocode}
@@ -3744,10 +4700,10 @@ and the derived file cooking-units.sty.
% \begin{macrocode}
\cs_new:Npn \@@_round_calculated_input:NN #1#2
{
- \@@_check_number_after_dot:n {#2}
- \tl_set:Nf #1
+ \@@_check_number_for_rounding:n {#2}
+ \tl_set:Nx #1
{
- \bool_if:NTF \l_tmpa_bool
+ \bool_if:NTF \l_@@_round_decimal_part_bool
{ \fp_eval:n { round ( \@@_rounding_function:n {#2} ) } }
{#2}
}
@@ -3759,41 +4715,80 @@ and the derived file cooking-units.sty.
%
%
%
-% \begin{macro}{ \@@_print_output:N }
+% \begin{macro}
+% { \@@_print_input:N , \@@_print_correct_unit: , \@@_post_process_input:NN , \@@_pre_process_input:NN}
% Wrapper macro for printing the (not)calculated output. Note that if no
% calculation happens in \mycs{cutext} (and \mycs{Cutext}) \cs{l_@@_option_unit_tl}
-% is set to \cs{l_@@_tmp_unit_tl} (the unit given in the second argument of
+% is set to \cs{l_@@_given_unit_tl} (the unit given in the second argument of
% \mycs{cutext} or \mycs{Cutext}) by default.
% \begin{macrocode}
-\cs_new_protected:Npn \@@_print_output:N #1
- {
- \bool_if:NTF \l_@@_using_cutext_bool
- {
- \tl_set_eq:NN \l_@@_cutext_tmp_tl #1
- \@@_cutext_print_output:NV #1 \l_@@_option_unit_tl
- }
- { \@@_print_nummerical_output:N #1 }
+\cs_new_protected:Npn \@@_print_input:N #1 { }
+\cs_new_protected:Npn \@@_print_correct_unit: { }
+\cs_new_protected:Npn \@@_do_not_process_input:NN #1#2 { }
+\cs_new_eq:NN \@@_pre_process_input:NN \@@_do_not_process_input:NN
+\cs_new_eq:NN \@@_post_process_input:NN \@@_do_not_process_input:NN
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}
+% {
+% \@@_set_process_and_print_for_cunum: ,
+% \@@_set_process_and_print_for_cutext: ,
+% \@@_set_process_and_print_for_cuam:
+% }
+% It is handy to set the \enquote{print} and \enquote{process}
+% command all in one go. It's also less to use messy.
+% \begin{macrocode}
+\cs_new_protected:Npn \@@_set_process_and_print_for_cunum:
+ {
+ \cs_set_eq:NN \@@_print_input:N \@@_print_numerical_input:N
+ \cs_set_eq:NN \@@_print_correct_unit: \@@_cunum_print_correct_unit:
+ \cs_set_eq:NN \@@_pre_process_input:NN \@@_do_not_process_input:NN
+ \cs_set_eq:NN \@@_post_process_input:NN \@@_do_not_process_input:NN
+ }
+\cs_new_protected:Npn \@@_set_process_and_print_for_cutext:
+ {
+ \cs_set_eq:NN \@@_print_input:N \@@_cutext_print_input:N
+ \cs_set_eq:NN \@@_print_correct_unit: \@@_cutext_print_correct_unitname:
+ \cs_set_eq:NN \@@_pre_process_input:NN \@@_cutext_pre_process_input:NN
+ \cs_set_eq:NN \@@_post_process_input:NN \@@_cutext_post_process_input:NN
+ }
+\cs_new_protected:Npn \@@_set_process_and_print_for_cuam:
+ {
+ \cs_set_eq:NN \@@_print_input:N \@@_cuam_print_numerical_input:N
+ \cs_set_eq:NN \@@_print_correct_unit: \@@_cuam_print_correct_unitphrase:
+ \cs_set_eq:NN \@@_pre_process_input:NN \@@_do_not_process_input:NN
+ \cs_set_eq:NN \@@_post_process_input:NN \@@_cuam_post_process_input:NN
}
% \end{macrocode}
% \end{macro}
%
-% \begin{macro}{ \@@_print_nummerical_output:N }
+%
+%
+%
+%
+% \begin{macro}{ \@@_print_numerical_input:N }
% Prints the nummerical output (if it is not a fraction).
%
% Changed \lstinline|\l_@@_tmpa_tl| by |\l_@@_translation_tmpa_tl|, it's better that way.
% \begin{macrocode}
-\cs_new_protected:Npn \@@_print_nummerical_output:N #1
+\cs_new_protected:Npn \@@_print_numerical_input:N #1
{
- \translatelet \l_@@_translation_tmpa_tl { decimal-mark ( cu-unitname ) }
- \tl_replace_once:NnV #1 { . } \l_@@_translation_tmpa_tl
- \tl_replace_once:NnV #1 { - } \c_@@_minus_tl
+ \tl_if_in:NnT #1 { . }
+ {
+ \@@_translate_let:Nxx \l_@@_translation_tmpa_tl
+ { decimal-mark } \c_@@_postfix_unitname_tl
+ \tl_replace_once:Nnn #1 { . } { \l_@@_translation_tmpa_tl }
+ }
+ \tl_if_in:NnT #1 { - }
+ { \tl_replace_once:NnV #1 { - } \c_@@_minus_tl }
#1
}
% \end{macrocode}
% \end{macro}
%
%
-% \begin{macro}{ \@@_formatiere_fractions:nNN }
+% \begin{macro}{ \@@_formatiere_fractions:nnn }
% The name of this function is the name of the game: It prints fractions.
% Furthermore it sets the boolean \lstinline|fraction_in_input_bool| to true
% so that the correct unit is printed. Instead of \lstinline|\kern| I used the
@@ -3801,10 +4796,9 @@ and the derived file cooking-units.sty.
%
% Since v.1.10(alpha) it also prints the minus sign (hopefully correct).
% \begin{macrocode}
-\cs_new:Npn \@@_formatiere_fractions:nNN #1#2#3
+\cs_new:Npn \@@_formatiere_fractions:nnn #1#2#3
{
- \bool_set_true:N \l_@@_fraction_in_input_bool
- \bool_if:NT \l_tmpb_bool { \c_@@_minus_tl }
+ \bool_if:NT \l_@@_minus_bool { \c_@@_minus_tl }
\tl_if_empty:nF {#1}
{
#1
@@ -3826,13 +4820,13 @@ and the derived file cooking-units.sty.
{
\bool_if:NT \l_@@_check_temperature_bool
{
- \clist_if_in:NVT \l_@@_temperatures_to_check_clist \l_@@_option_unit_tl
+ \seq_if_in:NVT \l_@@_temperatures_to_check_seq \l_@@_option_unit_tl
{
\fp_compare:cNnT
{ c_@@_ \l_@@_option_unit_tl _min_fp } > {#1}
{
\msg_error:nnxx { cooking-units }
- { Temperature-to-low }
+ { Temperature-too-low }
{ #1 \space \l_@@_option_unit_tl }
{
\fp_use:c { c_@@_ \l_@@_option_unit_tl _min_fp }
@@ -3841,13 +4835,50 @@ and the derived file cooking-units.sty.
}
}
}
- }
+ }
% \end{macrocode}
% \end{macro}
%
%
%
%
+%
+%
+%
+%
+%
+%
+%
+%
+% \begin{macrocode}
+\cs_new_nopar:Npn \@@_grab_arrows_for_safety_do_afterwards:nN #1#2
+ {
+ \str_if_eq:nnTF {#2} { > }
+ {
+ \tl_put_right:Nx \l_@@_tmpa_tl { \tl_to_str:N > }
+ \exp_last_unbraced:NV #1 \l_@@_tmpa_tl
+ }{
+ \tl_put_right:Nn \l_@@_tmpa_tl {#2}
+ \@@_grab_arrows_for_safety_do_afterwards:nN {#1}
+ }
+ }
+\cs_new_nopar:Npn \@@_if_arrow_grab_until_close_do:nnTF #1#2#3#4
+ {
+ \str_if_eq:nnTF {#1} { < }
+ {
+ \tl_if_in:NoT \l_@@_input_allowed_special_signs_tl { < }
+ { \msg_error:nn {cooking-units} { <-not-allowed-as-special-sign } }
+ \tl_clear:N \l_@@_tmpa_tl
+ \tl_put_right:Nx \l_@@_tmpa_tl { \tl_to_str:N < }
+ \@@_grab_arrows_for_safety_do_afterwards:nN
+ {#3} #2
+ }
+ {#4}
+ }
+% \end{macrocode}
+%
+%
+%
% \subsection {\mycs{cunum}}
%
%
@@ -3856,13 +4887,25 @@ and the derived file cooking-units.sty.
% \begin{macrocode}
\NewDocumentCommand \cunum { d<> O{} m O{} m }
{
- \group_begin:
+ \@@_if_arrow_grab_until_close_do:nnTF {#3} {#5}
+ { \cunum }
+ {
+ \group_begin:
+ \@@_cunum:nnnnn {#1} {#2} {#3} {#4} {#5}
+ \group_end:
+ }
+ }
+% \end{macrocode}
+% \end{macro}
+%
+%
+% \begin{macro}{ \@@_cunum }
+% \begin{macrocode}
+\cs_new:Npn \@@_cunum:nnnnn #1#2#3#4#5
+ {
\@@_cunum_initialise:nnnnn {#1} {#2} {#3} {#4} {#5}
- \bool_if:NTF \l_@@_parse_input_bool
- { \@@_parse_and_evaluate_input:n {#3} }
- { \@@_cunum_do_not_parse:nnn {#3} {#4} {#5} }
- \@@_cunum_print_correct_unit:nVV {#4} \l_@@_option_unit_tl \l_@@_tmp_unit_tl
- \group_end:
+ \@@_cunum_parse_numerical_input:n {#3}
+ \@@_print_correct_unit:
}
% \end{macrocode}
% \end{macro}
@@ -3881,41 +4924,47 @@ and the derived file cooking-units.sty.
% \begin{macrocode}
\cs_new_protected:Npn \@@_cunum_initialise:nnnnn #1#2#3#4#5
{
+ \@@_set_process_and_print_for_cunum:
+ \tl_set:Nn \l_@@_phantom_tl {#4}
\@@_initialise_default:nnn {#1} {#2} {#5}
\@@_initialise_unit_change:nnn {#1} {#2} {#5}
- \@@_initialise_after_unit_change:nnn {#1} {#2} {#5}
+ \@@_initialise_after_unit_change:nn {#1} {#2}
}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{ \@@_initialise_default:n }
-% Function shared by all initialization functions:.
-%
+% Function shared by all initialization functions:
% \begin{macrocode}
\cs_new_protected:Npn \@@_initialise_default:nnn #1#2#3
{
- \tl_set:Nn \l_@@_tmp_unit_tl {#3}
- \@@_error_if_unit_not_defined:V \l_@@_tmp_unit_tl
+ \tl_set:Nn \l_@@_given_unit_tl {#3}
+ \@@_error_if_unit_not_defined:V \l_@@_given_unit_tl
\bool_set_false:N \l_@@_special_sign_bool
\bool_set_false:N \l_@@_error_bool
- \bool_set_false:N \l_@@_parse_range_bool
+ \bool_set_false:N \l_@@_range_in_input_bool
+ \bool_set_false:N \l_@@_fraction_in_input_bool
}
-\cs_generate_variant:Nn \@@_initialise_default:nnn { nnV}
% \end{macrocode}
+% Some units have options added to them. To get those options it is first
+% needed to know which unit will be used at all. Therefore units will
+% be changed first and afterwards the other options are processed.
% \begin{macrocode}
\cs_new_protected:Npn \@@_initialise_unit_change:nnn #1#2#3
{
\tl_if_empty:nF {#2}
- { \keys_set_groups:nnn { cooking-units } { change-unit } {#2} }
- \bool_if:NT \l_@@_convert_to_eV_bool
- { \@@_convert_to_eV: }
- \prop_get:NVN \l_@@_change_unit_prop \l_@@_tmp_unit_tl \l_@@_option_unit_tl
- \quark_if_no_value:NT \l_@@_option_unit_tl
- { \tl_set_eq:NN \l_@@_option_unit_tl \l_@@_tmp_unit_tl }
+ {
+ \keys_set_groups:nnn { cooking-units } { change-unit } {#2}
+ }
+ \bool_if:NT \l_@@_convert_to_eV_bool { \@@_convert_to_eV: }
+ \prop_get:NVNF \l_@@_change_unit_prop \l_@@_given_unit_tl \l_@@_option_unit_tl
+ {
+ \tl_set_eq:NN \l_@@_option_unit_tl \l_@@_given_unit_tl
+ }
}
% \end{macrocode}
% \begin{macrocode}
-\cs_new_protected:Npn \@@_initialise_after_unit_change:nnn #1#2#3
+\cs_new_protected:Npn \@@_initialise_after_unit_change:nn #1#2
{
\IfNoValueF {#1}
{ \@@_reference_label_and_persons:n {#1} }
@@ -3928,25 +4977,40 @@ and the derived file cooking-units.sty.
}
\tl_if_empty:nF {#2}
{ \keys_set_filter:nnn { cooking-units } { change-unit } {#2} }
- \bool_set:Nn \l_@@_calc_persons_tmp_bool
- { \l_@@_calc_because_ref_was_given_bool && \l_@@_calc_for_persons_bool }
+ \bool_lazy_and:nnTF
+ { \l_@@_calc_because_ref_was_given_bool } { \l_@@_calc_for_persons_bool }
+ { \bool_set_true:N \l_@@_calc_persons_bool }
+ { \bool_set_false:N \l_@@_calc_persons_bool }
}
% \end{macrocode}
% \end{macro}
%
%
-% \begin{macro}{ \@@_cunum_do_not_parse:nnn }
+%
+% \begin{macrocode}
+\cs_new:Npn \@@_cunum_parse_numerical_input:n #1
+ {
+ \bool_if:NTF \l_@@_parse_input_bool
+ { \@@_parse_and_evaluate_input:n {#1} }
+ { \@@_do_not_parse:n {#1} }
+ }
+% \end{macrocode}
+%
+%
+%
+%
+% \begin{macro}{ \@@_do_not_parse:n }
% If the input shoudn't be parsed this function is used to print the
% input without error messages (mostly concerning the \_). Spaces are still ignored.
% \begin{macrocode}
-\cs_new:Npn \@@_cunum_do_not_parse:nnn #1#2#3
+\cs_new:Npn \@@_do_not_parse:n #1
{
- \tl_set_rescan:Nnn \l_tmpa_tl
+ \tl_set_rescan:Nnn \l_@@_number_tmpa_tl
{
\char_set_catcode_letter:N \_ %
\char_set_catcode_ignore:N \ %
} {#1}
- \l_tmpa_tl
+ \l_@@_number_tmpa_tl
}
% \end{macrocode}
% \end{macro}
@@ -3959,52 +5023,599 @@ and the derived file cooking-units.sty.
% \begin{macrocode}
\cs_new:Npn \@@_parse_and_evaluate_input:n #1
{
- \tl_set_rescan:Nnn \l_tmpa_tl
+ \tl_set_rescan:Nnn \l_@@_tmpa_tl
{
\char_set_catcode_letter:N \_ %
\char_set_catcode_ignore:N \ %
\char_set_catcode_other:N ? %
} {#1}
- \tl_if_empty:VF \l_tmpa_tl
+ \tl_if_empty:NF \l_@@_tmpa_tl
{
- \tl_if_in:NVT \l_tmpa_tl \l_@@_input_range_sign_tl
+ \tl_if_in:NVT \l_@@_tmpa_tl \l_@@_input_range_sign_tl
{
- \tl_replace_once:NVn \l_tmpa_tl \l_@@_input_range_sign_tl { \q_@@_range }
- \bool_set_true:N \l_@@_parse_range_bool
+ \tl_replace_once:NVn \l_@@_tmpa_tl \l_@@_input_range_sign_tl { \q_@@_range }
+ \bool_set_true:N \l_@@_range_in_input_bool
}
- \@@_cunum_parse_input:V \l_tmpa_tl
+ \@@_parse_input:V \l_@@_tmpa_tl
}
}
% \end{macrocode}
% \end{macro}
%
-% \begin{macro}{ \@@_cunum_print_correct_unit:nnn }
+% \begin{macro}{ \@@_cunum_print_correct_unit: }
% The invisible space is added by a \lstinline|\phantom|, afterwards
% \lstinline|value_unit_space_tl| is used (which is set to
% \lstinline|\thinspace| by default) and if either special signs or
% fractions are parsed the input-unit is printed else the converted
% unit is.
% \begin{macrocode}
-\cs_new:Npn \@@_cunum_print_correct_unit:nnn #1#2#3
+\cs_new:Npn \@@_cunum_print_correct_unit:
{
- \tl_if_empty:nF {#1} { \phantom {#1} }
+ \tl_if_empty:NF \l_@@_phantom_tl { \phantom { \l_@@_phantom_tl } }
\tl_use:N \l_@@_value_unit_space_tl
- \bool_if:nTF
+ \bool_lazy_any:nTF
{
- ! \l_@@_parse_input_bool ||
- \l_@@_fraction_in_input_bool ||
- \l_@@_special_sign_bool
+ { \l_@@_fraction_in_input_bool }
+ { \l_@@_special_sign_bool }
+ { ! \l_@@_parse_input_bool }
}
- { \translate { #3 ( cu-unit ) } }
- { \translate { #2 ( cu-unit ) } }
+ { \@@_translate:xx \l_@@_given_unit_tl \c_@@_postfix_unit_tl }
+ { \@@_translate:xx \l_@@_option_unit_tl \c_@@_postfix_unit_tl }
}
-\cs_generate_variant:Nn \@@_cunum_print_correct_unit:nnn { nVV }
% \end{macrocode}
% \end{macro}
%
%
+% \section { cutext \& Cutext }
%
%
+% A quite primitive implentation of \opt{cutext-to-cunum}, but
+% sufficient for now.
+% \begin{macrocode}
+\NewDocumentCommand \cutext { d<> O{} m m }
+ {
+ \@@_if_arrow_grab_until_close_do:nnTF {#3} {#4}
+ { \cutext }
+ {
+ \group_begin:
+ \@@_cutext_initialise:nnn {#1} {#2} {#4}
+ \bool_set_false:N \l_@@_cutext_uppercase_word_bool
+ \@@_cutext_do:nnnn {#1} {#2} {#3} {#4}
+ \group_end:
+ }
+ }
+% \end{macrocode}
+%
+% \begin{macrocode}
+\NewDocumentCommand \Cutext { d<> O{} m m }
+ {
+ \@@_if_arrow_grab_until_close_do:nnTF {#3} {#4}
+ { \Cutext }
+ {
+ \group_begin:
+ \@@_cutext_initialise:nnn {#1} {#2} {#4}
+ \bool_set_true:N \l_@@_cutext_uppercase_word_bool
+ \@@_cutext_do:nnnn {#1} {#2} {#3} {#4}
+ \group_end:
+ }
+ }
+% \end{macrocode}
+%
+% \begin{macrocode}
+\cs_new_protected:Npn \@@_cutext_initialise:nnn #1#2#3
+ {
+ \bool_set_true:N \l_@@_using_cutext_bool
+ \@@_set_process_and_print_for_cutext:
+ \@@_initialise_default:nnn {#1} {#2} {#3}
+ \bool_if:NTF \l_@@_cutext_change_unit_bool
+ { \@@_initialise_unit_change:nnn {#1} {#2} {#3} }
+ { \tl_set_eq:NN \l_@@_option_unit_tl \l_@@_given_unit_tl }
+ \@@_initialise_after_unit_change:nn {#1} {#2}
+ }
+% \end{macrocode}
+%
+% Besser benennen.
+% \begin{macrocode}
+\cs_new:Npn \@@_cutext_do:nnnn #1#2#3#4
+ {
+ \bool_if:NTF \l_@@_cutext_to_cunum_bool
+ { \cunum <#1> [#2] {#3} {#4} }
+ {
+ \@@_cutext:nnnn {#1} {#2} {#3} {#4}
+ }
+ }
+% \end{macrocode}
+%
+% \begin{macrocode}
+% #1: label, #2: Options, #3: Values, #4: unit
+\cs_new:Npn \@@_cutext:nnnn #1#2#3#4
+ {
+ \bool_if:NTF \l_@@_parse_input_bool
+ {
+ \bool_if:NTF \l_@@_cutext_old_bool
+ {
+ \@@_old_cutext_default:nnn {#2} {#3} {#4}
+ \tl_set_eq:NN \l_@@_option_unit_tl \l_@@_given_unit_tl
+ \@@_cutext_print_correct_unitname:
+ }{
+ \@@_parse_and_evaluate_input:n {#3}
+ \@@_print_correct_unit:
+ }
+ }{
+ \@@_do_not_parse:n {#3}
+ \tl_set_eq:NN \l_@@_option_unit_tl \l_@@_given_unit_tl
+ \@@_cutext_print_correct_unitname:
+ }
+ }
+% \end{macrocode}
+%
+%
+% \begin{macro} {\@@_cutext_if_numeral_is_int_and_parse_and_smaller_then_print_numerals:N}
+% \begin{macrocode}
+\prg_new_conditional:Npnn \@@_cutext_if_numeral_is_int_and_parse_and_smaller_then_print_numerals:N #1 { TF }
+ {
+ \bool_lazy_and:nnTF
+ { \g_@@_opt_numeral_bool }
+ { \l_@@_local_numeral_bool }
+ {
+ \@@_if_parse_and_integer:VTF #1
+ {
+ \int_compare:nNnTF {#1} < { \l_@@_print_numerals_below_int }
+ { \prg_return_true: }
+ { \prg_return_false: }
+ }{ \prg_return_false: }
+ }{ \prg_return_false: }
+ }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro} {\@@_cutext_print_input:Nn , \@@_cutext_print_input:NV}
+% \changes {2016/06/11} {0.99} {New.}
+% \begin{macrocode}
+\cs_new_protected:Npn \@@_cutext_print_input:Nn #1#2
+ {
+ \@@_cutext_if_numeral_is_int_and_parse_and_smaller_then_print_numerals:NTF #1
+ {
+ \@@_int_if_equal_one:nTF {#1}
+ {
+ \@@_translate_one_to_and_check_existance:Nx \l_@@_translation_tmpa_tl {#2}
+ \bool_if:NTF \l_@@_cutext_uppercase_word_bool
+ {
+ \exp_args:Nx \tl_upper_case:n { \tl_head:V \l_@@_translation_tmpa_tl }
+ \tl_tail:V \l_@@_translation_tmpa_tl
+ }
+ { \l_@@_translation_tmpa_tl }
+ }{
+ \bool_if:NTF \l_@@_cutext_uppercase_word_bool
+ { \@@_print_Numeral:n {#1} }
+ { \@@_print_numeral:n {#1} }
+ }
+ }
+ { \@@_print_numerical_input:N #1 }
+ }
+\cs_generate_variant:Nn \@@_cutext_print_input:Nn { NV }
+\cs_new_protected:Npn \@@_cutext_print_input:N #1
+ { \@@_cutext_print_input:NV #1 \l_@@_option_unit_tl }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macrocode}
+\cs_new:Npn \@@_cutext_print_correct_unitname:
+ {
+ \l_@@_cutext_space_tl
+ \bool_lazy_any:nTF
+ {
+ { \l_@@_fraction_in_input_bool }
+ { \l_@@_special_sign_bool }
+ { ! \l_@@_parse_input_bool }
+ }
+ { \@@_translate:xx \l_@@_given_unit_tl \c_@@_postfix_unitname_pl_tl }
+ {
+ \@@_fp_if_equal_one:nTF { \l_@@_cutext_last_value_tl }
+ { \@@_translate:xx \l_@@_option_unit_tl \c_@@_postfix_unitname_tl }
+ { \@@_translate:xx \l_@@_option_unit_tl \c_@@_postfix_unitname_pl_tl }
+ }
+ }
+% \end{macrocode}
+%
+% \begin{macrocode}
+\cs_new:Npn \@@_cutext_pre_process_input:NN #1#2
+ {
+ \@@_cutext_check_unitname_consequences:NN #1#2
+ }
+\cs_new:Npn \@@_cutext_post_process_input:NN #1#2
+ {
+ \bool_if:NTF \l_@@_range_in_input_bool
+ {
+ \tl_set_eq:NN \l_@@_cutext_last_value_tl #2
+ \bool_if:NT \g_@@_opt_numeral_bool
+ {
+ \bool_lazy_and:nnF
+ { \fp_compare_p:nNn {#1} < { \l_@@_print_numerals_below_int } }
+ { \fp_compare_p:nNn {#2} < { \l_@@_print_numerals_below_int } }
+ { \bool_set_false:N \l_@@_local_numeral_bool }
+ }
+ }
+ { \tl_set_eq:NN \l_@@_cutext_last_value_tl #1 }
+ }
+% \end{macrocode}
+%
+% It doesn't matter if I check if the singular or the plural translation exists,
+% as the plural one exists if the singular exists and vice versa.
+% \begin{macrocode}
+\cs_new:Npn \@@_cutext_check_unitname_consequences:NN #1#2
+ {
+ \bool_lazy_any:nTF
+ {
+ { \l_@@_fraction_in_input_bool }
+ { \l_@@_special_sign_bool }
+ { ! \l_@@_parse_input_bool }
+ }
+ { \tl_set_eq:NN \l_@@_tmpb_tl \l_@@_given_unit_tl }
+ { \tl_set_eq:NN \l_@@_tmpb_tl \l_@@_option_unit_tl }
+ \@@_unitname_get:NxF \l_@@_tmpa_tl \l_@@_tmpb_tl
+ {
+ \msg_warning:nnx
+ { cooking-units }
+ { cutext-no-translation-available }
+ \l_@@_tmpb_tl
+ \bool_set_false:N \l_@@_using_cutext_bool
+ \@@_set_process_and_print_for_cunum:
+ }
+ }
+% \end{macrocode}
+%
+%
+%
+%
+%
+%
+% \begin{macro} { \@@_old_cutext_default:nnn }
+% \changes {2016/06/11} {0.98a} { New command }
+% \begin{macrocode}
+\cs_new:Npn \@@_old_cutext_default:nnn #1#2#3
+ {
+ \bool_if:NTF \l_@@_parse_input_bool
+ {
+ \tl_set:Nn \l_@@_cutext_last_value_tl {#2}
+ \tl_if_in:NVTF \l_@@_cutext_last_value_tl \l_@@_input_range_sign_tl
+ {
+ \tl_replace_once:NVn \l_@@_cutext_last_value_tl
+ \l_@@_input_range_sign_tl { \q_@@_range }
+ \@@_old_cutext_parse_range:Vn \l_@@_cutext_last_value_tl {#3}
+ }{
+ \@@_cutext_print_input:Nn \l_@@_cutext_last_value_tl {#3}
+ }
+ }
+ {#2}
+ }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macrocode}
+\cs_new:Npn \@@_old_cutext_parse_range:Nn #1 #2
+ {
+ \@@_old_cutext_parse_range_aux:nww {#2} #1 \q_stop
+ }
+\cs_generate_variant:Nn \@@_old_cutext_parse_range:Nn { V }
+\cs_new:Npn \@@_old_cutext_parse_range_aux:nww #1 #2 \q_@@_range #3 \q_stop
+ {
+ \tl_set:Nn \l_@@_tmpa_tl {#2}
+ \tl_set:Nn \l_@@_cutext_last_value_tl {#3}
+ \@@_cutext_print_input:Nn \l_@@_tmpa_tl {#1}
+ \tl_use:N \l_@@_cutext_range_sign_tl
+ \@@_cutext_print_input:Nn \l_@@_cutext_last_value_tl {#1}
+ }
+% \end{macrocode}
+%
+%
+% \section{cuam}
+%
+% \begin{macrocode}
+\tl_const:Nn \c_@@_cuam_marker_tl { @@_cunum }
+\tl_new:c { l_@@_tmpa_ \c_@@_cuam_marker_tl _ tl }
+\tl_set:cn { l_@@_tmpa_ \c_@@_cuam_marker_tl _ tl } { \c_one_fp }
+\clist_new:c { l_@@_predefined_option_ \c_@@_cuam_marker_tl _clist }
+% \end{macrocode}
+%
+% Replaces and extends \mycs{cufrac}.
+% \begin{macro}{\cuam}
+% \begin{macrocode}
+\NewDocumentCommand \cuam { d<> O{} m }
+ {
+ \@@_if_arrow_grab_until_close_do:nnTF {#3} { }
+ { \cuam }
+ {
+ \group_begin:
+ \@@_cuam_initialise:nn {#1} {#2}
+ \@@_cuam:n {#3}
+ \group_end:
+ }
+ }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macrocode}
+\cs_new:Npn \@@_cuam:n #1
+ {
+ \bool_if:NTF \l_@@_parse_input_bool
+ {
+ \bool_if:NTF \l_@@_cuam_old_bool
+ { \@@_cuam_old:n {#1} }
+ {
+ \@@_parse_and_evaluate_input:n {#1}
+ \@@_print_correct_unit:
+ }
+ }
+ { \@@_do_not_parse:n {#1} }
+ }
+% \end{macrocode}
+%
+% \begin{macrocode}
+\cs_new_protected:Npn \@@_cuam_initialise:nn #1#2
+ {
+ \@@_set_process_and_print_for_cuam:
+ \tl_set_eq:NN \l_@@_given_unit_tl \c_@@_cuam_marker_tl
+ \tl_set_eq:NN \l_@@_option_unit_tl \c_@@_cuam_marker_tl
+ \@@_initialise_after_unit_change:nn {#1} {#2}
+ }
+% \end{macrocode}
+%
+% I should redo this command \dots\ later
+% \begin{macrocode}
+\cs_new_protected:Npn \@@_cuam_post_process_input:NN #1#2
+ {
+ \@@_if_integer:VTF #1
+ { \bool_set_true:N \l_@@_tmpa_bool }
+ { \bool_set_false:N \l_@@_tmpa_bool }
+ \bool_lazy_and:nnT
+ { \l_@@_range_in_input_bool } { \l_@@_tmpa_bool }
+ {
+ \@@_if_integer:VTF #2
+ { \bool_set_true:N \l_@@_tmpa_bool }
+ { \bool_set_false:N \l_@@_tmpa_bool }
+ }
+ \bool_lazy_and:nnT
+ { \l_@@_use_phrases_bool } { \l_@@_tmpa_bool }
+ {
+ \@@_if_phrase_list_exists:NT \l_@@_phrase_prop
+ {
+ \@@_translate_let:Nxx \l_@@_phrase_numbers_clist
+ { phrase-list-list } \c_@@_postfix_phrase_tl
+ \@@_cuam_process_input_aux:NNN #1 \l_@@_tmpa_int \l_@@_phrase_number_tl
+ \bool_if:NT \l_@@_check_if_phrase_used_bool
+ {
+ \bool_if:NTF \l_@@_range_in_input_bool
+ {
+ \@@_cuam_process_input_aux:NNN #2 \l_@@_tmpb_int \l_@@_tmpb_tl
+ \bool_lazy_and:nnTF
+ { \l_@@_check_if_phrase_used_bool }
+ { \tl_if_eq_p:NN \l_@@_phrase_number_tl \l_@@_tmpb_tl }
+ { \bool_set_true:N \l_@@_check_if_phrase_used_bool }
+ { \bool_set_false:N \l_@@_check_if_phrase_used_bool }
+ \bool_if:NT \l_@@_check_if_phrase_used_bool
+ {
+ \tl_set:NV #1 \l_@@_tmpa_int
+ \tl_set:NV #2 \l_@@_tmpb_int
+ \@@_cuam_get_phrase_name:NVN
+ \l_@@_phrase_phrase_tl \l_@@_phrase_number_tl \l_@@_tmpb_int
+ }
+ }{
+ \tl_set:NV #1 \l_@@_tmpa_int
+ \@@_cuam_get_phrase_name:NVN
+ \l_@@_phrase_phrase_tl \l_@@_phrase_number_tl \l_@@_tmpa_int
+ }
+ }
+ }
+ }
+ \bool_lazy_and:nnT
+ { \g_@@_opt_numeral_bool } { \l_@@_local_numeral_bool }
+ {
+ \bool_set_eq:NN \l_@@_local_numeral_bool \l_@@_tmpa_bool
+ \bool_if:NT \l_@@_local_numeral_bool
+ {
+ \bool_if:NTF \l_@@_range_in_input_bool
+ {
+ \bool_lazy_and:nnF
+ { \int_compare_p:nNn {#1} < { \l_@@_print_numerals_below_int } }
+ { \int_compare_p:nNn {#2} < { \l_@@_print_numerals_below_int } }
+ { \bool_set_false:N \l_@@_local_numeral_bool }
+ }{
+ \int_compare:nNnF {#1} < { \l_@@_print_numerals_below_int }
+ { \bool_set_false:N \l_@@_local_numeral_bool }
+ }
+ }
+ }
+ }
+% \end{macrocode}
+%
+% \begin{macrocode}
+\prg_new_conditional:Npnn \@@_cuam_check_if_larger:nn #1#2 { F }
+ {
+ \int_compare:nNnTF {#1} > {#2}
+ { \prg_return_true: }
+ { \prg_return_false: }
+ }
+% \end{macrocode}
+%
+% \begin{macrocode}
+\cs_new:Npn \@@_cuam_process_input_aux:NNN #1#2#3
+ {
+ \bool_set_false:N \l_@@_check_if_phrase_used_bool
+ \clist_map_inline:Nn \l_@@_phrase_numbers_clist
+ {
+ \@@_cuam_check_if_larger:nnF { \int_abs:n {##1} } {#1}
+ {
+ \int_compare:nNnTF {##1} < { \c_zero }
+ { \int_set_eq:NN \l_tmpa_int \c_one }
+ { \int_set:Nn \l_tmpa_int { \int_div_truncate:nn {#1} {##1} } }
+ \int_compare:nNnT { \int_abs:n {##1} * \l_tmpa_int } = {#1}
+ {
+ \int_set_eq:NN #2 \l_tmpa_int
+ \tl_set:Nn #3 {##1}
+ \bool_set_true:N \l_@@_check_if_phrase_used_bool
+ \clist_map_break:
+ }
+ }
+ }
+ }
+\cs_new:Npn \@@_cuam_get_phrase_name:NnN #1#2#3
+ {
+ \@@_int_if_equal_one:nTF {#3}
+ { \prop_get:NnN \l_@@_phrase_prop {#2} #1 }
+ { \prop_get:NnN \l_@@_phrase_prop { #2-pl } #1 }
+ }
+\cs_generate_variant:Nn \@@_cuam_get_phrase_name:NnN { NVN }
+% \end{macrocode}
+%
+% \begin{macrocode}
+\cs_new_protected:Npn \@@_cuam_print_numerical_input:N #1
+ {
+ \bool_lazy_all:nTF
+ {
+ { \l_@@_check_if_phrase_used_bool }
+ { \g_@@_opt_numeral_bool }
+ { \l_@@_local_numeral_bool }
+ }{
+ \@@_int_if_equal_one:nTF {#1}
+ {
+ \@@_translate_one_to_and_check_existance:Nx \l_@@_translation_tmpa_tl
+ { \l_@@_phrase_number_tl -phrase-gender }
+ \l_@@_translation_tmpa_tl
+ }
+ { \exp_args:NV \@@_print_numeral:n #1 }
+ }{ \@@_print_numerical_input:N #1 }
+ }
+% \end{macrocode}
+%
+% \begin{macrocode}
+\cs_new:Npn \@@_cuam_print_correct_unitphrase:
+ {
+ \bool_if:NT \l_@@_check_if_phrase_used_bool
+ {
+ \l_@@_cuphrase_space_tl
+ \l_@@_phrase_phrase_tl
+ }
+ }
+% \end{macrocode}
+%
+%
+%
+% \begin{macro}{\@@_cuam_old:n}
+% \begin{macrocode}
+\cs_new:Npn \@@_cuam_old:n #1
+ {
+ \tl_set_rescan:Nnn \l_@@_tmpa_tl
+ {
+ \char_set_catcode_letter:N \_ %
+ \char_set_catcode_ignore:N\ %
+ } {#1}
+ \@@_cuam_old_parse:V \l_@@_tmpa_tl
+ }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macrocode}
+\cs_new_protected:Npn \@@_cuam_old_parse:n #1
+ {
+ \tl_if_in:nVTF {#1} \l_@@_input_range_sign_tl
+ {
+ \tl_set:Nn \l_@@_tmpa_tl {#1}
+ \tl_replace_once:NVn \l_@@_tmpa_tl \l_@@_input_range_sign_tl { \q_@@_range }
+ \@@_cuam_old_parse_range:V \l_@@_tmpa_tl
+ }{
+ \tl_if_in:nnTF {#1} { / }
+ {
+ \tl_if_in:nnTF {#1} { _ }
+ { \@@_cuam_old_parse_mixed_frac:www #1 \q_stop }
+ { \@@_cuam_old_parse_frac:ww #1 \q_stop }
+ }{
+ \tl_if_in:nnTF {#1} { _ }
+ { \msg_error:nnn { cooking-units } { missing-slash } {#1} }
+ { \@@_cuam_old_parse_scale:n {#1} }
+ }
+ }
+ }
+\cs_generate_variant:Nn \@@_cuam_old_parse:n { V }
+% \end{macrocode}
+%
+% \begin{macrocode}
+\cs_new:Npn \@@_cuam_old_parse_range:n #1
+ {
+ \@@_cuam_old_parse_range_aux:ww #1 \q_nil
+ }
+\cs_generate_variant:Nn \@@_cuam_old_parse_range:n { V }
+\cs_new:Npn \@@_cuam_old_parse_range_aux:ww #1 \q_@@_range #2 \q_nil
+ {
+ #1 \l_@@_cunum_range_sign_tl #2
+ }
+% \end{macrocode}
+%
+%
+% \begin{macrocode}
+\cs_new:Npn \@@_cuam_old_parse_scale:n #1 {#1}
+% \end{macrocode}
+%
+% \begin{macrocode}
+\cs_new:Npn \@@_cuam_old_parse_frac:ww #1/#2 \q_stop
+ { \@@_frac:nn {#1} {#2} }
+% \end{macrocode}
+%
+% \begin{macrocode}
+\cs_new:Npn \@@_cuam_old_parse_mixed_frac:www #1_#2/#3 \q_stop
+ {
+ #1
+ \hbox_to_wd:nn { \l_@@_mixed_frac_dim } { }
+ \@@_frac:nn {#2} {#3}
+ }
+% \end{macrocode}
+%
+% \section {cufrac}
+%
+% Obsolete.
+% \begin{macrocode}
+\NewDocumentCommand \cufrac { O{} m }
+ {
+ \msg_error:nnnn { cooking-units } { obsolete-command } { \cufrac } { \cuam }
+ \group_begin:
+ \tl_if_empty:nF {#1}
+ { \keys_set:nn { cooking-units } {#1} }
+ \@@_cufrac:n {#2}
+ \group_end:
+ }
+\cs_new:Npn \@@_cufrac:n #1
+ {
+ \tl_set_rescan:Nnn \l_@@_tmpa_tl
+ {
+ \char_set_catcode_letter:N \_ %
+ \char_set_catcode_ignore:N\ %
+ } {#1}
+ \@@_cufrac_parse:V \l_@@_tmpa_tl
+ }
+\cs_new:Npn \@@_cufrac_parse:n #1
+ {
+ \tl_if_in:nnTF {#1} { / }
+ {
+ \tl_if_in:nnTF {#1} { _ }
+ { \@@_cufrac_parse_mixed_frac:www #1 \q_stop }
+ { \@@_cufrac_parse_frac:ww #1 \q_stop }
+ }{
+ \tl_if_in:nnTF {#1} { _ }
+ { \msg_error:nnn { cooking-units } { missing-slash } {#1} }
+ { \@@_cufrac_parse_scale:n {#1} }
+ }
+ }
+\cs_generate_variant:Nn \@@_cufrac_parse:n { V }
+\cs_new:Npn \@@_cufrac_parse_scale:n #1 {#1}
+\cs_new:Npn \@@_cufrac_parse_frac:ww #1/#2 \q_stop
+ { \@@_frac:nn {#1} {#2} }
+\cs_new:Npn \@@_cufrac_parse_mixed_frac:www #1_#2/#3 \q_stop
+ {
+ #1
+ \hbox_to_wd:nn { \l_@@_mixed_frac_dim } { }
+ \@@_frac:nn {#2} {#3}
+ }
+% \end{macrocode}
%
% \section {cukeys}
%
@@ -4035,22 +5646,22 @@ and the derived file cooking-units.sty.
% \begin{macro}{ \@@_cukeys_define_keys_and_single_keys:nn }
% First checks whetever the unit is defined or not, then clears some macros
% which are needed later. Further procession depends on the boolean.
-% If more than one key is created, the value \lstinline|\l_tmpa_fp| is set to one.
-% This is important for adding keys where \lstinline|\l_tmpa_fp| is changed accordingly.
+% If more than one key is created, the value \lstinline|\l_@@_tmpa_fp| is set to one.
+% This is important for adding keys where \lstinline|\l_@@_tmpa_fp| is changed accordingly.
% \begin{macrocode}
\cs_new:Npn \@@_cukeys_define_keys_and_single_keys:nn #1#2
{
\@@_error_if_unit_not_defined:n {#1}
\tl_if_blank:nF {#2}
{
- \clist_clear:N \l_tmpa_clist
- \prop_clear:N \l_tmpa_prop
+ \seq_clear:N \l_@@_tmpa_seq
+ \prop_clear:N \l_@@_tmpa_prop
\bool_if:NTF \l_@@_single_key_bool
{
\@@_cukeys_parse_and_create_single_key:nn {#1} {#2}
}{
- \fp_set_eq:NN \l_tmpa_fp \c_one_fp
- \tl_set:Nn \l_@@_tmp_unit_tl {#1}
+ \fp_set_eq:NN \l_@@_tmpa_fp \c_one_fp
+ \tl_set:Nn \l_@@_given_unit_tl {#1}
\@@_cukeys_parse_and_create_keys:nn {#1}
{
{#1} { \c_one_fp } #2
@@ -4071,15 +5682,16 @@ and the derived file cooking-units.sty.
\@@_cukeys_parse_input:nn #2
\q_recursion_tail \q_recursion_tail \q_recursion_stop
\@@_cukeys_create_key_prop:n {#1}
- \@@_cukeys_define_keys:V \l_tmpa_clist
+ \clist_set_from_seq:NN \l_@@_tmpa_clist \l_@@_tmpa_seq
+ \@@_cukeys_define_keys:V \l_@@_tmpa_clist
}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{ \@@_cukeys_parse_input:nn }
-% Yeah \dots\ \lstinline|\l_tmpa_clist| stores all the used unit-keys, while
+% Yeah \dots\ \lstinline|\l_@@_tmpa_clist| stores all the used unit-keys, while
% the property list saves the relation to each other. This cycle is repeated until an
-% recursion tail is found. If you define a new key, \verb|\l_tmpa_fp| is set to
+% recursion tail is found. If you define a new key, \verb|\l_@@_tmpa_fp| is set to
% 1 and changed later if a new key is added.
% \begin{macrocode}
\cs_new:Npn \@@_cukeys_parse_input:nn #1#2
@@ -4088,8 +5700,8 @@ and the derived file cooking-units.sty.
\quark_if_recursion_tail_stop_do:nn {#2}
{ \msg_error:nn { cooking-units } { missing-argument } }
\@@_error_if_unit_not_defined:n {#1}
- \clist_put_right:Nn \l_tmpa_clist {#1}
- \prop_put:Nnx \l_tmpa_prop {#1} { \fp_eval:n { #2 / \l_tmpa_fp } }
+ \seq_put_right:Nn \l_@@_tmpa_seq {#1}
+ \prop_put:Nnx \l_@@_tmpa_prop {#1} { \fp_eval:n { (#2) / \l_@@_tmpa_fp } }
\@@_cukeys_parse_input:nn
}
% \end{macrocode}
@@ -4100,7 +5712,7 @@ and the derived file cooking-units.sty.
% \changes {2016/09/22} {1.02f} {Save 'Liste', 'prop' and 'Erstes Ding' to \cs{l_tmpb_prop} and set the unit-prop lists equal to \cs{l_tmpb_prop}.}
% \changes {2016/09/22} {1.02g} {Do not need \cs{tl_clear_new:c} as token list is already defined.}
%
-% All linked unit-keys are stored within \lstinline|\l_tmpa_clist| and are mapped
+% All linked unit-keys are stored within \lstinline|\l_@@_tmpa_clist| and are mapped
% one after another. At first a property list is created (or cleared), this property list
% stores the units linked to this unit, saves the created property list which contains the
% numerical relation of each unit. \lstinline|Erstes Ding| (firsth thing) stores
@@ -4152,21 +5764,24 @@ and the derived file cooking-units.sty.
% \begin{macrocode}
\cs_new:Npn \@@_cukeys_create_key_prop:n #1
{
- \prop_clear:N \l_tmpb_prop
- \prop_put:NnV \l_tmpb_prop { Liste } \l_tmpa_clist
- \prop_put:NnV \l_tmpb_prop { prop } \l_tmpa_prop
- \prop_put:NnV \l_tmpb_prop { Erstes Ding } \l_@@_tmp_unit_tl
- \clist_map_inline:Nn \l_tmpa_clist
+ \prop_clear:N \l_@@_tmpb_prop
+ \prop_put:NnV \l_@@_tmpb_prop { Liste } \l_@@_tmpa_seq
+ \prop_put:NnV \l_@@_tmpb_prop { prop } \l_@@_tmpa_prop
+ \prop_put:NnV \l_@@_tmpb_prop { Erstes Ding } \l_@@_given_unit_tl
+ \seq_map_inline:Nn \l_@@_tmpa_seq
{
- \prop_set_eq:cN { l_@@_cukeys_ ##1 _prop } \l_tmpb_prop
+ \prop_set_eq:cN { l_@@_cukeys_ ##1 _prop } \l_@@_tmpb_prop
\tl_set_eq:cN { l_@@_tmpa_ ##1 _tl } \c_one_fp
- \clist_map_inline:Nn \l_tmpa_clist
+ \seq_map_inline:Nn \l_@@_tmpa_seq
{
\prop_put:cnx { l_@@_cukeys_ ##1 _prop }
{####1}
{
\fp_eval:n
- { \prop_item:Nn \l_tmpa_prop {####1} / \prop_item:Nn \l_tmpa_prop {##1} }
+ {
+ ( \prop_item:Nn \l_@@_tmpa_prop {####1} ) /
+ ( \prop_item:Nn \l_@@_tmpa_prop {##1} )
+ }
}
}
}
@@ -4176,17 +5791,18 @@ and the derived file cooking-units.sty.
%
% \begin{macro}{ \@@_cukeys_define_keys:N , \@@_cukeys_define_keys:V }
% Defining the keys: It maps through the list of unit-keys and creates a
-% unit key respectively.
+% unit-key respectively.
% \begin{macrocode}
\cs_new:Npn \@@_cukeys_define_keys:N #1
{
- \clist_map_inline:Nn \l_tmpa_clist
+ \seq_map_inline:Nn \l_@@_tmpa_seq
{
- \clist_put_right:Nn \l_@@_list_of_defined_keys_clist {##1}
+ \seq_if_in:NnF \l_@@_list_of_defined_keys_seq {##1}
+ { \seq_put_right:Nn \l_@@_list_of_defined_keys_seq {##1} }
\keys_define:nn { cooking-units }
{
##1 .choices:Vn =
- \l_tmpa_clist
+ \l_@@_tmpa_clist
{
\@@_cukeys_define_keys_and_single_key_aux:n {##1}
} ,
@@ -4198,13 +5814,12 @@ and the derived file cooking-units.sty.
{ key-choice-unknown }
{##1}
{####1}
- { \seq_use:Nnnn \l_tmpa_seq { ',' } { ',' } { ' ~ and ~ ' } }
+ { \seq_use:Nnnn \l_tmpa_seq { ',~ ' } { ',~ ' } { ' ~ and ~ ' } }
} ,
##1 .default:n = {##1} ,
##1 .groups:n = { change-unit }
}
}
- \clist_remove_duplicates:N \l_@@_list_of_defined_keys_clist
}
\cs_generate_variant:Nn \@@_cukeys_define_keys:N { V }
% \end{macrocode}
@@ -4228,14 +5843,15 @@ and the derived file cooking-units.sty.
% \begin{macrocode}
\cs_new:Npn \@@_cukeys_parse_and_create_single_key:nn #1#2
{
- \tl_set_rescan:Nnn \l_tmpa_tl
+ \tl_set_rescan:Nnn \l_@@_tmpa_tl
{
\char_set_catcode_letter:N \# %
\char_set_catcode_ignore:N\ %
} { {#1} { \c_one_fp } #2 }
- \@@_cusinglekeys_parse_input:V \l_tmpa_tl
+ \@@_cusinglekeys_parse_input:V \l_@@_tmpa_tl
\@@_cusinglekeys_create_key_prop:n {#1}
- \@@_cukeys_define_singlekey:nV {#1} \l_tmpa_clist
+ \clist_set_from_seq:NN \l_@@_tmpa_clist \l_@@_tmpa_seq
+ \@@_cukeys_define_singlekey:nV {#1} \l_@@_tmpa_clist
}
% \end{macrocode}
%
@@ -4253,10 +5869,10 @@ and the derived file cooking-units.sty.
\quark_if_recursion_tail_stop_do:nn {#2}
{ \msg_error:nn { cooking-units } { missing-argument } }
\@@_error_if_unit_not_defined:n {#1}
- \clist_put_right:Nn \l_tmpa_clist {#1}
- \tl_set:Nn \l_tmpa_tl {#2}
- \tl_replace_all:NVn \l_tmpa_tl \c_@@_str_hash_one_tl { \l_tmpa_fp }
- \prop_put:NnV \l_tmpa_prop {#1} \l_tmpa_tl
+ \seq_put_right:Nn \l_@@_tmpa_seq {#1}
+ \tl_set:Nn \l_@@_tmpa_tl {#2}
+ \tl_replace_all:NVn \l_@@_tmpa_tl \c_@@_input_str_hash_one_tl { \l_@@_tmpa_fp }
+ \prop_put:NnV \l_@@_tmpa_prop {#1} \l_@@_tmpa_tl
\@@_cusinglekeys_parse_input_aux:nn
}
% \end{macrocode}
@@ -4265,22 +5881,22 @@ and the derived file cooking-units.sty.
\cs_new:Npn \@@_cusinglekeys_create_key_prop:n #1
{
\tl_set_eq:cN { l_@@_tmpa_ #1 _tl } \c_one_fp
-% \tl_set:cn { l_@@_tmpa_ #1 _tl } { \c_one_fp }
- \prop_set_eq:cN { l_@@_cukeys_ #1 _prop } \l_tmpa_prop
+ \prop_set_eq:cN { l_@@_cukeys_ #1 _prop } \l_@@_tmpa_prop
\prop_put:cnn { l_@@_cukeys_ #1 _prop } { Erstes Ding } {#1}
- \prop_put:cnV { l_@@_cukeys_ #1 _prop } { Liste } \l_tmpa_clist
- \prop_put:cnV { l_@@_cukeys_ #1 _prop } { prop } \l_tmpa_prop
+ \prop_put:cnV { l_@@_cukeys_ #1 _prop } { Liste } \l_@@_tmpa_seq
+ \prop_put:cnV { l_@@_cukeys_ #1 _prop } { prop } \l_@@_tmpa_prop
}
% \end{macrocode}
%
% \begin{macrocode}
\cs_new:Npn \@@_cukeys_define_singlekey:nN #1#2
{
- \clist_put_right:Nn \l_@@_list_of_defined_keys_clist {#1}
+ \seq_if_in:NnF \l_@@_list_of_defined_keys_seq {#1}
+ { \seq_put_right:Nn \l_@@_list_of_defined_keys_seq {#1} }
\keys_define:nn { cooking-units }
{
#1 .choices:Vn =
- \l_tmpa_clist
+ \l_@@_tmpa_clist
{
\@@_cukeys_define_keys_and_single_key_aux:n {#1}
} ,
@@ -4297,7 +5913,6 @@ and the derived file cooking-units.sty.
#1 .default:n = {#1} ,
#1 .groups:n = { change-unit } ,
}
- \clist_remove_duplicates:N \l_@@_list_of_defined_keys_clist
}
\cs_generate_variant:Nn \@@_cukeys_define_singlekey:nN { nV }
% \end{macrocode}
@@ -4306,13 +5921,14 @@ and the derived file cooking-units.sty.
% \section {Adding Keys}
%
% Question to me: Why do we need \cs{l_tmpa(b)_tl}?
+% Maybe due to \cs{cuaddtokeys}?
% \begin{macrocode}
\NewDocumentCommand \cuaddkeys { m m }
{
\bool_set_false:N \l_@@_single_key_bool
- \tl_set:Nn \l_tmpa_tl {#1}
- \tl_set:Nn \l_tmpb_tl {#2}
- \@@_cukeys_add_keys_or_single_keys:VV \l_tmpa_tl \l_tmpb_tl
+ \tl_set:Nn \l_@@_tmpa_tl {#1}
+ \tl_set:Nn \l_@@_tmpb_tl {#2}
+ \@@_cukeys_add_keys_or_single_keys:VV \l_@@_tmpa_tl \l_@@_tmpb_tl
}
% \end{macrocode}
%
@@ -4320,9 +5936,9 @@ and the derived file cooking-units.sty.
\NewDocumentCommand \cuaddsinglekeys { m m }
{
\bool_set_true:N \l_@@_single_key_bool
- \tl_set:Nn \l_tmpa_tl {#1}
- \tl_set:Nn \l_tmpb_tl {#2}
- \@@_cukeys_add_keys_or_single_keys:VV \l_tmpa_tl \l_tmpb_tl
+ \tl_set:Nn \l_@@_tmpa_tl {#1}
+ \tl_set:Nn \l_@@_tmpb_tl {#2}
+ \@@_cukeys_add_keys_or_single_keys:VV \l_@@_tmpa_tl \l_@@_tmpb_tl
}
% \end{macrocode}
%
@@ -4330,9 +5946,9 @@ and the derived file cooking-units.sty.
\NewDocumentCommand \cuaddtokeys { m m m }
{
\bool_set_false:N \l_@@_single_key_bool
- \tl_set:Nn \l_tmpa_tl {#1}
- \tl_set:Nn \l_tmpb_tl { {#2} { \fp_eval:n { \c_one_fp / #3 } } }
- \@@_cukeys_add_keys_or_single_keys:VV \l_tmpa_tl \l_tmpb_tl
+ \tl_set:Nn \l_@@_tmpa_tl {#1}
+ \tl_set:Nn \l_@@_tmpb_tl { {#2} { \fp_eval:n { \c_one_fp / (#3) } } }
+ \@@_cukeys_add_keys_or_single_keys:VV \l_@@_tmpa_tl \l_@@_tmpb_tl
}
% \end{macrocode}
%
@@ -4342,8 +5958,8 @@ and the derived file cooking-units.sty.
\cs_new:Npn \@@_cukeys_add_keys_or_single_keys:nn #1#2
{
\@@_error_if_unit_not_defined:n {#1}
- \clist_if_in:NnF \l_@@_list_of_defined_keys_clist {#1}
- { \msg_error:nnn { cooking-units } { Key - not - defined } {#1} }
+ \seq_if_in:NnF \l_@@_list_of_defined_keys_seq {#1}
+ { \msg_error:nnn { cooking-units } { Key-not-defined } {#1} }
\tl_if_blank:nF {#2}
{
\@@_cukeys_add_keys_and_single_key_aux:n {#1}
@@ -4358,11 +5974,11 @@ and the derived file cooking-units.sty.
%
% \begin{macrocode}
\cs_new:Npn \@@_cukeys_add_keys_and_single_key_aux:n #1
- {
- \prop_get:cnN { l_@@_cukeys_ #1 _prop } { Liste } \l_tmpa_clist
- \prop_get:cnN { l_@@_cukeys_ #1 _prop } { prop } \l_tmpa_prop
- \prop_get:cnN { l_@@_cukeys_ #1 _prop } { Erstes Ding } \l_@@_tmp_unit_tl
- \prop_get:cVN { l_@@_cukeys_ #1 _prop } \l_@@_tmp_unit_tl \l_tmpa_fp
+ {
+ \prop_get:cnN { l_@@_cukeys_ #1 _prop } { Liste } \l_@@_tmpa_seq
+ \prop_get:cnN { l_@@_cukeys_ #1 _prop } { prop } \l_@@_tmpa_prop
+ \prop_get:cnN { l_@@_cukeys_ #1 _prop } { Erstes Ding } \l_@@_given_unit_tl
+ \prop_get:cVN { l_@@_cukeys_ #1 _prop } \l_@@_given_unit_tl \l_@@_tmpa_fp
}
% \end{macrocode}
%
@@ -4374,7 +5990,7 @@ and the derived file cooking-units.sty.
% \begin{macrocode}
\NewDocumentCommand \declarecookingunit { o m }
{
- \clist_if_in:NnTF \g_@@_list_of_defined_units_clist {#2}
+ \seq_if_in:NnTF \g_@@_list_of_defined_units_seq {#2}
{ \msg_info:nnn { cooking-units } { redefine-unit } {#2} }
{ \@@_new_cooking_unit:nn {#1} {#2} }
\@@_set_cooking_unit:nn {#1} {#2}
@@ -4386,8 +6002,8 @@ and the derived file cooking-units.sty.
}
\NewDocumentCommand \providecookingunit { o m }
{
- \clist_if_in:NnF \g_@@_list_of_defined_units_clist {#2}
- {
+ \seq_if_in:NnF \g_@@_list_of_defined_units_seq {#2}
+ {
\@@_new_cooking_unit:nn {#1} {#2}
\@@_set_cooking_unit:nn {#1} {#2}
}
@@ -4398,10 +6014,10 @@ and the derived file cooking-units.sty.
% \begin{macrocode}
\cs_new:Npn \@@_new_cooking_unit:nn #1#2
{
- \clist_if_in:NnTF \g_@@_list_of_defined_units_clist {#2}
+ \seq_if_in:NnTF \g_@@_list_of_defined_units_seq {#2}
{ \msg_error:nnn { cooking-units } { unit-already-defined } {#2} }
{
- \clist_put_right:Nn \g_@@_list_of_defined_units_clist {#2}
+ \seq_put_right:Nn \g_@@_list_of_defined_units_seq {#2}
\tl_new:c { l_@@_tmpa_ #2 _tl }
\tl_set_eq:cN { l_@@_tmpa_ #2 _tl } \c_one_fp
\clist_new:c { l_@@_predefined_option_#2_clist }
@@ -4412,505 +6028,356 @@ and the derived file cooking-units.sty.
{ \clist_put_right:cn { l_@@_predefined_option_#2_clist } {##1} },
}
\prop_new:c { l_@@_cukeys_ #2 _prop }
- \tl_new:c { l_@@_cu_unit_ #2 _tl }
+ \tl_new:c { l_@@_default_unit_ #2 _tl }
}
}
\cs_new:Npn \@@_set_cooking_unit:nn #1#2
{
\IfNoValueTF {#1}
{
- \tl_set:cn { l_@@_cu_unit_ #2 _tl } {#2}
- \deftranslation { #2 ( cu-unit ) } {#2}
+ \tl_set:cn { l_@@_default_unit_ #2 _tl } {#2}
+ \@@_deftranslation_base:xxn {#2} \c_@@_postfix_unit_tl {#2}
}{
- \tl_set:cn { l_@@_cu_unit_ #2 _tl } {#1}
- \deftranslation { #2 ( cu-unit ) } {#1}
+ \tl_set:cn { l_@@_default_unit_ #2 _tl } {#1}
+ \@@_deftranslation_base:xxn {#2} \c_@@_postfix_unit_tl {#1}
}
+ \@@_deftranslation_base:xxn {#2} \c_@@_postfix_unitname_tl { \q_@@_no_translation }
+ \@@_deftranslation_base:xxn {#2} \c_@@_postfix_unitname_pl_tl { \q_@@_no_translation }
+ \@@_deftranslation_base:xxn {#2} \c_@@_postfix_gender_tl { m }
}
% \end{macrocode}
%
%
-% \section { cutext \& Cutext }
+%
+% \section {Names}
%
%
-% A quite primitive implentation of \opt{cutext-to-cunum}, but
-% sufficient for now.
% \begin{macrocode}
-\NewDocumentCommand \cutext { d<> O{} m m }
- {
- \group_begin:
- \@@_cutext_initialise:nnn {#1} {#2} {#4}
- \bool_if:NTF \l_@@_cutext_to_cunum_bool
- { \cunum {#3} {#4} }
+\tl_new:N \l_@@_sanitise_tl
+\cs_new_protected:Npn \@@_sanitise_aux:w #1 \q_mark
+ { \tl_set:Nn \l_@@_sanitise_tl {#1} }
+\group_begin:
+ \char_set_catcode_active:n { `\< }
+ \char_set_catcode_active:n { `\> }
+ \cs_new:Npn \@@_sanitize_open_arrow:
+ {
+ \exp_after:wN \@@_sanitize_open_arrow_auxi:w \l_@@_sanitise_tl
+ \q_mark < \q_nil <
+ \exp_after:wN \@@_sanitise_aux:w \l_@@_sanitise_tl
+ }
+ \cs_new_protected:Npn \@@_sanitize_open_arrow_auxi:w #1 <
+ {
+ \tl_set:Nn \l_@@_sanitise_tl {#1}
+ \@@_sanitize_open_arrow_auxii:w
+ }
+ \cs_new_protected:Npn \@@_sanitize_open_arrow_auxii:w #1 <
+ {
+ \quark_if_nil:nF {#1}
{
- \bool_set_false:N \l_@@_cutext_uppercase_word_bool
- \@@_cutext:nnnn {#1} {#2} {#3} {#4}
+ \tl_set:Nx \l_@@_sanitise_tl
+ {
+ \exp_not:V \l_@@_sanitise_tl
+ \token_to_str:N <
+ \exp_not:n {#1}
+ }
+ \exp_after:wN \@@_sanitize_open_arrow_auxii:w
}
- \group_end:
- }
-% \end{macrocode}
-%
-% \begin{macrocode}
-\NewDocumentCommand \Cutext { d<> O{} m m }
- {
- \group_begin:
- \@@_cutext_initialise:nnn {#1} {#2} {#4}
- \bool_if:NTF \l_@@_cutext_to_cunum_bool
- { \cunum {#3} {#4} }
+ }
+ \cs_new:Npn \@@_sanitize_close_arrow:
+ {
+ \exp_after:wN \@@_sanitize_close_arrow_auxi:w \l_@@_sanitise_tl
+ \q_mark > \q_nil >
+ \exp_after:wN \@@_sanitise_aux:w \l_@@_sanitise_tl
+ }
+ \cs_new_protected:Npn \@@_sanitize_close_arrow_auxi:w #1 >
+ {
+ \tl_set:Nn \l_@@_sanitise_tl {#1}
+ \@@_sanitize_close_arrow_auxii:w
+ }
+ \cs_new_protected:Npn \@@_sanitize_close_arrow_auxii:w #1 >
+ {
+ \quark_if_nil:nF {#1}
{
- \bool_set_true:N \l_@@_cutext_uppercase_word_bool
- \@@_cutext:nnnn {#1} {#2} {#3} {#4}
+ \tl_set:Nx \l_@@_sanitise_tl
+ {
+ \exp_not:V \l_@@_sanitise_tl
+ \token_to_str:N >
+ \exp_not:n {#1}
+ }
+ \exp_after:wN \@@_sanitize_close_arrow_auxii:w
}
- \group_end:
+ }
+\group_end:
+\cs_new_protected:Npn \@@_sanitize_arrows:n #1
+ {
+ \tl_set:Nn \l_@@_sanitise_tl {#1}
+ \@@_sanitize_open_arrow:
+ \@@_sanitize_close_arrow:
}
% \end{macrocode}
%
+%
% \begin{macrocode}
-\cs_new_protected:Npn \@@_cutext_initialise:nnn #1#2#3
+\NewDocumentCommand \cudefinename { m m }
{
- \bool_set_true:N \l_@@_using_cutext_bool
- \@@_initialise_default:nnn {#1} {#2} {#3}
- \bool_if:NTF \l_@@_cutext_change_unit_bool
- { \@@_initialise_unit_change:nnn {#1} {#2} {#3} }
- { \tl_set_eq:NN \l_@@_option_unit_tl \l_@@_tmp_unit_tl }
- \@@_initialise_after_unit_change:nnn {#1} {#2} {#3}
+ \tl_set:Nn \l_@@_language_tl {#1}
+ \@@_sanitize_arrows:n {#2}
+ \exp_last_unbraced:NV
+ \@@_cuname_parse_input:n \l_@@_sanitise_tl
+ \q_recursion_tail \q_recursion_tail \q_recursion_stop
}
% \end{macrocode}
%
+%
% \begin{macrocode}
-\cs_new:Npn \@@_cutext:nnnn #1#2#3#4
+\cs_new:Npn \@@_cuname_parse_input:n #1
{
- \bool_if:nTF { \l_@@_cutext_old_bool || !\l_@@_parse_input_bool }
- {
- \@@_cutext_default:nnn {#2} {#3} {#4}
- \@@_cutext_print_correct_unitname:nnn {#3} {#4} {#4}
- }{
- \@@_parse_and_evaluate_input:n {#3}
- \@@_cutext_print_correct_unitname:VVV
- \l_@@_cutext_tmp_tl \l_@@_option_unit_tl \l_@@_tmp_unit_tl
+ \peek_meaning_ignore_spaces:NTF [
+ {
+ \@@_cuname_parse_unit_symbol:nw {#1}
+ }{
+ \clist_if_in:NnTF \g_@@_allowed_special_keys_clist {#1}
+ { \@@_cuname_parse_input_aux:nn {#1} }
+ { \@@_cuname_parse_unit_symbol:nw {#1} [ \q_no_value ] }
}
}
% \end{macrocode}
%
-% \begin{macro} { \@@_cutext_default:nnn }
-% \changes {2016/06/11} {0.98a} { New command }
% \begin{macrocode}
-\cs_new:Npn \@@_cutext_default:nnn #1#2#3
+\cs_new:Npn \@@_cuname_parse_unit_symbol:nw #1 [#2]
{
- \@@_error_if_unit_not_defined:n {#3}
- \bool_if:NT \l_@@_convert_to_eV_bool
- { \@@_convert_to_eV: }
- \bool_if:NTF \l_@@_parse_input_bool
+ \quark_if_recursion_tail_stop:n {#1}
+ \quark_if_recursion_tail_stop_do:nn {#2}
+ { \msg_error:nn { cooking-units } { missing-argument } }
+ \@@_error_if_unit_not_defined:n {#1}
+ \quark_if_no_value:nTF {#2}
{
- \tl_set:Nn \l_tmpb_tl {#2}
- \tl_if_in:NVTF \l_tmpb_tl \l_@@_input_range_sign_tl
- {
- \tl_replace_once:NVn \l_tmpb_tl \l_@@_input_range_sign_tl { \q_@@_range }
- \@@_cutext_parse_range:Vn \l_tmpb_tl {#3}
- }{
- \@@_cutext_print_output:Nn \l_tmpb_tl {#3}
- }
+ \@@_deftranslation_to:Vxxv
+ \l_@@_language_tl {#1}
+ \c_@@_postfix_unit_tl
+ { l_@@_default_unit_ #1 _tl }
+ }{
+ \@@_deftranslation_to:Vxxn
+ \l_@@_language_tl {#1}
+ \c_@@_postfix_unit_tl {#2}
}
- {#2}
+ \@@_cuname_parse_input_aux:nn {#1}
}
% \end{macrocode}
-% \end{macro}
+%
%
% \begin{macrocode}
-\cs_new:Npn \@@_cutext_parse_range:Nn #1 #2
- {
- \@@_cutext_parse_range_aux:nww {#2} #1 \q_stop
- }
-\cs_generate_variant:Nn \@@_cutext_parse_range:Nn { V }
-\cs_new:Npn \@@_cutext_parse_range_aux:nww #1 #2 \q_@@_range #3 \q_stop
+\cs_new:Npn \@@_cuname_parse_input_aux:nn #1#2
{
- \tl_set:Nn \l_@@_tmpa_tl {#2}
- \tl_set:Nn \l_@@_tmpb_tl {#3}
- \@@_cutext_print_output:Nn \l_@@_tmpa_tl {#1}
- \tl_use:N \l_@@_cutext_range_sign_tl
- \@@_cutext_print_output:Nn \l_@@_tmpb_tl {#1}
+ \quark_if_recursion_tail_stop:n {#1}
+ \quark_if_recursion_tail_stop_do:nn {#2}
+ { \msg_error:nn { cooking-units } { missing-argument } }
+ \clist_if_in:NnF \g_@@_allowed_special_keys_clist {#1}
+ { \@@_error_if_unit_not_defined:n {#1} }
+ \@@_deftranslation_to:Vxxn
+ \l_@@_language_tl {#1}
+ \c_@@_postfix_unitname_tl {#2}
+ \peek_meaning_ignore_spaces:NTF [
+ { \@@_cuname_parse_bracket:nw {#1} }
+ { \@@_cuname_parse_bracket:nw {#1} [#2] }
}
% \end{macrocode}
%
-% \begin{macro} {\@@_cutext_print_output:Nn , \@@_cutext_print_output:NV}
-% \changes {2016/06/11} {0.99} {New.}
% \begin{macrocode}
-\cs_new_protected:Npn \@@_cutext_print_output:Nn #1#2
+\cs_new:Npn \@@_cuname_parse_bracket:nw #1 [#2]
{
- \bool_if:NTF \g_@@_load_if_opt_numeral_bool
- {
- \@@_if_integer_and_parse:VTF #1
- {
- \fp_compare:nNnTF {#1} < { \l_@@_print_numerals_below_int }
- {
- \fp_compare:nNnTF {#1} = { \c_one_fp }
- {
- \translatelet \l_@@_translation_tmpa_tl { #2 (cu-unitgender) }
- \translatelet \l_@@_translation_tmpa_tl
- { one (\l_@@_translation_tmpa_tl) (cu-unitname) }
- \bool_if:NTF \l_@@_cutext_uppercase_word_bool
- {
- \exp_args:Nf \tl_to_uppercase:n { \tl_head:V \l_@@_translation_tmpa_tl }
- \tl_tail:V \l_@@_translation_tmpa_tl
- }
- { \l_@@_translation_tmpa_tl }
- }{
- \bool_if:NTF \l_@@_cutext_uppercase_word_bool
- { \Numberstringnum {#1} }
- { \numberstringnum {#1} }
- }
- }{ \@@_print_nummerical_output:N #1 }
- }{ \@@_print_nummerical_output:N #1 }
+ \clist_if_in:NnF \g_@@_allowed_special_keys_clist {#1}
+ {
+ \@@_deftranslation_to:Vxxn \l_@@_language_tl {#1}
+ \c_@@_postfix_unitname_pl_tl {#2}
}
- { \@@_print_nummerical_output:N #1 }
+ \peek_meaning_ignore_spaces:NTF <
+ { \@@_cuname_parse_gender:nw {#1} }
+ { \@@_cuname_parse_gender:nw {#1} <m> }
}
-\cs_generate_variant:Nn \@@_cutext_print_output:Nn { NV }
% \end{macrocode}
-% \end{macro}
%
% \begin{macrocode}
-\cs_new:Npn \@@_cutext_print_correct_unitname:nnn #1#2#3
+\cs_new:Npn \@@_cuname_parse_gender:nw #1 <#2>
{
- \l_@@_cutext_space_tl
- \bool_if:nTF
- {
- ! \l_@@_parse_input_bool ||
- \l_@@_fraction_in_input_bool ||
- \l_@@_special_sign_bool
- }
- { \translate { #3 (cu-unitname pl) } }
- {
- \@@_if_integer:nTF {#1}
- {
- \fp_compare:nNnTF {#1} = { \c_one_fp }
- { \translate { #2 (cu-unitname) } }
- { \translate { #2 (cu-unitname pl) } }
- }
- { \translate { #2 (cu-unitname pl) } }
- }
+ \@@_check_if_correct_gender_input:n {#2}
+ \@@_deftranslation_to:Vxxn
+ \l_@@_language_tl {#1}
+ \c_@@_postfix_gender_tl {#2}
+ \@@_cuname_parse_input:n
}
-\cs_generate_variant:Nn \@@_cutext_print_correct_unitname:nnn { VVV }
% \end{macrocode}
%
%
%
-% \section {cufrac}
+% \subsection {cudefinesymbol}
%
-% Obsolete.
-% \begin{macrocode}
-\NewDocumentCommand \cufrac { O{} m }
- {
- \msg_error:nnnn { cooking-units } { obsolete-command } { \cufrac } { \cuam }
- \group_begin:
- \tl_if_empty:nF {#1}
- { \keys_set:nn { cooking-units } {#1} }
- \@@_cufrac:n {#2}
- \group_end:
- }
-% \end{macrocode}
%
% \begin{macrocode}
-\cs_new:Npn \@@_cufrac:n #1
+\NewDocumentCommand \cudefinesymbol { m m }
{
- \tl_set_rescan:Nnn \l_tmpa_tl
- {
- \char_set_catcode_letter:N \_ %
- \char_set_catcode_ignore:N\ %
- } {#1}
- \@@_cufrac_parse:V \l_tmpa_tl
+ \tl_set:Nn \l_@@_language_tl {#1}
+ \@@_cuprint_define_printed_unit:nn #2
+ \q_recursion_tail \q_recursion_tail \q_recursion_stop
}
% \end{macrocode}
%
% \begin{macrocode}
-\cs_new:Npn \@@_cufrac_parse:n #1
+\cs_new:Npn \@@_cuprint_define_printed_unit:nn #1#2
{
- \tl_if_in:nnTF {#1} { / }
+ \quark_if_recursion_tail_stop:n {#1}
+ \quark_if_recursion_tail_stop_do:nn {#2}
+ { \msg_error:nn { cooking-units } { missing-argument } }
+ \clist_if_in:NnTF \g_@@_allowed_special_keys_clist {#1}
{
- \tl_if_in:nnTF {#1} { _ }
- { \@@_cufrac_parse_mixed_frac:www #1 \q_stop }
- { \@@_cufrac_parse_frac:ww #1 \q_stop }
+ \@@_deftranslation_to:Vxxn \l_@@_language_tl {#1}
+ \c_@@_postfix_unitname_tl {#2}
}{
- \tl_if_in:nnTF {#1} { _ }
- { \msg_error:nnn { cooking-units } { missing-slash } {#1} }
- { \@@_cufrac_parse_scale:n {#1} }
+ \@@_error_if_unit_not_defined:n {#1}
+ \@@_deftranslation_to:Vxxn
+ \l_@@_language_tl {#1}
+ \c_@@_postfix_unit_tl {#2}
}
- }
-\cs_generate_variant:Nn \@@_cufrac_parse:n { V }
-% \end{macrocode}
-%
-% \begin{macrocode}
-\cs_new:Npn \@@_cufrac_parse_scale:n #1 {#1}
-% \end{macrocode}
-%
-% \begin{macrocode}
-\cs_new:Npn \@@_cufrac_parse_frac:ww #1/#2 \q_stop
- { \@@_frac:nn {#1} {#2} }
-% \end{macrocode}
-%
-% \begin{macrocode}
-\cs_new:Npn \@@_cufrac_parse_mixed_frac:www #1_#2/#3 \q_stop
- {
- #1
- \hbox_to_wd:nn { \l_@@_mixed_frac_dim } { }
- \@@_frac:nn {#2} {#3}
- }
+ \@@_cuprint_define_printed_unit:nn
+ }
% \end{macrocode}
%
%
-% \section{cuam}
-%
-% \begin{macrocode}
-\tl_new:N \l_@@_cuam_marker_tl
-\tl_set:Nn \l_@@_cuam_marker_tl { @@_cunum }
-\tl_new:c { l_@@_tmpa_ \l_@@_cuam_marker_tl _ tl }
-\tl_set:cn { l_@@_tmpa_ \l_@@_cuam_marker_tl _ tl } { \c_one_fp }
-\clist_new:c { l_@@_predefined_option_ \l_@@_cuam_marker_tl _clist }
-% \end{macrocode}
%
-% Replaces and extends \mycs{cufrac}.
-% \begin{macro}{\cuam}
-% \begin{macrocode}
-\NewDocumentCommand \cuam { d<> O{} m }
- {
- \group_begin:
- \@@_cuam_initialise:nnn {#1} {#2} {}
- \bool_if:NTF \l_@@_parse_input_bool
- {
- \bool_if:NTF \l_@@_cuam_old_bool
- { \@@_cuam_old:n {#3} }
- { \@@_parse_and_evaluate_input:n {#3} }
- }
- { \@@_cunum_do_not_parse:nnn {#3} {} {} }
- \group_end:
- }
-% \end{macrocode}
-% \end{macro}
+% \subsection {Phrases}
%
%
% \begin{macrocode}
-\cs_new_protected:Npn \@@_cuam_initialise:nnn #1#2#3
- {
- \tl_set_eq:NN \l_@@_tmp_unit_tl \l_@@_cuam_marker_tl
- \tl_set_eq:NN \l_@@_option_unit_tl \l_@@_cuam_marker_tl
- \@@_initialise_after_unit_change:nnn {#1} {#2} {#3}
- }
+\@@_newtranslation_base:nVn { phrase-list } \c_@@_postfix_phrase_tl { \q_@@_no_translation }
% \end{macrocode}
%
-% \begin{macro}{\@@_cuam:n}
% \begin{macrocode}
-\cs_new:Npn \@@_cuam:n #1
+\prg_new_conditional:Npnn \@@_phrase_list_get_for:NN #1#2 { TF , T , F }
{
- \tl_set_rescan:Nnn \l_tmpa_tl
- {
- \char_set_catcode_letter:N \_ %
- \char_set_catcode_ignore:N \ %
- \char_set_catcode_other:N ? %
- } {#1}
- \@@_cuam_parse:V \l_tmpa_tl
- }
-%
-\cs_new:Npn \@@_cuam_old:n #1
- {
- \tl_set_rescan:Nnn \l_tmpa_tl
- {
- \char_set_catcode_letter:N \_ %
- \char_set_catcode_ignore:N\ %
- } {#1}
- \@@_cuam_old_parse:V \l_tmpa_tl
- }
-% \end{macrocode}
-% \end{macro}
-%
-% \begin{macrocode}
-\cs_new_protected:Npn \@@_cuam_old_parse:n #1
+ \@@_translate_let:VNxx #2 #1 { phrase-list } \c_@@_postfix_phrase_tl
+ \tl_if_eq:NNTF #1 \q_@@_no_translation
+ { \prg_return_false: }
+ { \prg_return_true: }
+ }
+\prg_new_conditional:Npnn \@@_if_phrase_list_exists:N #1 { TF , T , F }
{
- \tl_if_in:nVTF {#1} \l_@@_input_range_sign_tl
- {
- \tl_set:Nn \l_tmpa_tl {#1}
- \tl_replace_once:NVn \l_tmpa_tl \l_@@_input_range_sign_tl { \q_@@_range }
- \@@_cuam_old_parse_range:V \l_tmpa_tl
- }{
- \tl_if_in:nnTF {#1} { / }
- {
- \tl_if_in:nnTF {#1} { _ }
- { \@@_cuam_old_parse_mixed_frac:www #1 \q_stop }
- { \@@_cuam_old_parse_frac:ww #1 \q_stop }
- }{
- \tl_if_in:nnTF {#1} { _ }
- { \msg_error:nnn { cooking-units } { missing-slash } {#1} }
- { \@@_cuam_old_parse_scale:n {#1} }
- }
- }
- }
-\cs_generate_variant:Nn \@@_cuam_old_parse:n { V }
+ \@@_translate_let:Nxx \l_tmpa_tl { phrase-list } \c_@@_postfix_phrase_tl
+ \tl_if_eq:NNTF \l_tmpa_tl \q_@@_no_translation
+ { \prg_return_false: }
+ { \prg_return_true: }
+ }
% \end{macrocode}
-%
% \begin{macrocode}
-\cs_new:Npn \@@_cuam_parse_range:n #1
- {
- \@@_cuam_parse_range_aux:ww #1 \q_nil
- }
-\cs_generate_variant:Nn \@@_cuam_parse_range:n { V }
-\cs_new:Npn \@@_cuam_parse_range_aux:ww #1 \q_@@_range #2 \q_nil
+\NewDocumentCommand \cudefinephrase { m m }
{
- \@@_parse_input_and_safe_in:nN {#1} \l_tmpa_tl
- \@@_parse_input_and_safe_in:nN {#2} \l_tmpb_tl
- \@@_print_nummerical_output:N \l_tmpa_tl
- \l_@@_cunum_range_sign_tl
- \@@_print_nummerical_output:N \l_tmpb_tl
+ \@@_cuphrase:nn {#1} {#2}
}
-% \end{macrocode}
-%
-% \begin{macrocode}
-\cs_new:Npn \@@_cuam_old_parse_range:n #1
+\cs_new:Npn \@@_cuphrase:nn #1#2
{
- \@@_cuam_old_parse_range_aux:ww #1 \q_nil
- }
-\cs_generate_variant:Nn \@@_cuam_old_parse_range:n { V }
-\cs_new:Npn \@@_cuam_old_parse_range_aux:ww #1 \q_@@_range #2 \q_nil
- {
- #1 \l_@@_cunum_range_sign_tl #2
- }
+ \tl_set:Nn \l_@@_language_tl {#1}
% \end{macrocode}
-%
-%
% \begin{macrocode}
-\cs_new:Npn \@@_cuam_old_parse_scale:n #1 {#1}
+ \@@_phrase_list_get_for:NNTF \l_@@_phrase_prop \l_@@_language_tl
+ {
+ \@@_translate_let:VNxx \l_@@_language_tl \l_@@_phrase_numbers_clist
+ { phrase-list-list } \c_@@_postfix_phrase_tl
+ }{
+ \prop_clear:N \l_@@_phrase_prop
+ \clist_clear:N \l_@@_phrase_numbers_clist
+ }
% \end{macrocode}
-%
% \begin{macrocode}
-\cs_new:Npn \@@_cuam_old_parse_frac:ww #1/#2 \q_stop
- { \@@_frac:nn {#1} {#2} }
+ \@@_sanitize_arrows:n {#2}
+ \exp_last_unbraced:NV
+ \@@_cuphrase_parse:n \l_@@_sanitise_tl
+ \q_recursion_tail \q_recursion_tail \q_recursion_stop
% \end{macrocode}
-%
% \begin{macrocode}
-\cs_new:Npn \@@_cuam_old_parse_mixed_frac:www #1_#2/#3 \q_stop
- {
- #1
- \hbox_to_wd:nn { \l_@@_mixed_frac_dim } { }
- \@@_frac:nn {#2} {#3}
- }
+ \clist_sort:Nn \l_@@_phrase_numbers_clist
+ {
+ \int_compare:nNnTF { \int_abs:n {##1} } < { \int_abs:n {##2} }
+ { \sort_return_swapped: }
+ {
+ \int_compare:nNnTF { \int_abs:n {##1} } = { \int_abs:n {##2} }
+ {
+ \int_compare:nNnTF {##1} < {##2}
+ { \sort_return_same: }
+ { \sort_return_swapped: }
+ }{ \sort_return_same: }
+ }
+ }
% \end{macrocode}
-%
-% \section {Names}
-%
-%
% \begin{macrocode}
-\NewDocumentCommand \cudefinename { m m }
- {
- \tl_set:Nn \l_@@_language_tl {#1}
- \@@_cuname_parse_input:n #2
- \q_recursion_tail \q_recursion_tail \q_recursion_stop
- }
+ \@@_deftranslation_to:VxxV
+ \l_@@_language_tl { phrase-list }
+ \c_@@_postfix_phrase_tl
+ \l_@@_phrase_prop
+ \@@_deftranslation_to:VxxV
+ \l_@@_language_tl { phrase-list-list }
+ \c_@@_postfix_phrase_tl \l_@@_phrase_numbers_clist
+ }
% \end{macrocode}
%
%
% \begin{macrocode}
-\cs_new:Npn \@@_cuname_parse_input:n #1
- {
- \peek_meaning_ignore_spaces:NTF [
- {
- \@@_cuname_parse_unit_symbol:nw {#1}
- }{
- \clist_if_in:NnTF \g_@@_allowed_unit_phrases_clist {#1}
- { \@@_cuname_parse_input_aux:nn {#1} }
- { \@@_cuname_parse_unit_symbol:nw {#1} [ \q_no_value ] }
- }
- }
-% \end{macrocode}
-%
-% \begin{macrocode}
-\cs_new:Npn \@@_cuname_parse_unit_symbol:nw #1 [#2]
+\cs_new:Npn \@@_cuphrase_parse:n #1
{
- \quark_if_recursion_tail_stop:n {#1}
- \quark_if_recursion_tail_stop_do:nn {#2}
- { \msg_error:nn { cooking-units } { missing-argument } }
- \@@_error_if_unit_not_defined:n {#1}
- \quark_if_no_value:nTF {#2}
+ \quark_if_recursion_tail_stop:n {#1}
+ \@@_if_integer:nF {#1}
+ { \msg_error:nnn { cooking-units} { phrase-unit-not-an-integer } {#1} }
+ \peek_meaning_remove_ignore_spaces:NTF *
{
- \@@_deftranslation:Vnv
- \l_@@_language_tl { #1 ( cu-unit ) } { l_@@_cu_unit_ #1 _tl }
- }
- {
- \@@_deftranslation:Vnn \l_@@_language_tl { #1 ( cu-unit ) } {#2}
+ \int_set:Nn \l_@@_tmpa_int {-#1}
+ \@@_cuphrase_parse_normal:Vn \l_@@_tmpa_int
+ }{
+ \int_set:Nn \l_@@_tmpa_int {#1}
+ \@@_cuphrase_parse_normal:Vn \l_@@_tmpa_int
}
- \@@_cuname_parse_input_aux:nn {#1}
}
% \end{macrocode}
%
-%
% \begin{macrocode}
-\cs_new:Npn \@@_cuname_parse_input_aux:nn #1#2
+\cs_new:Npn \@@_cuphrase_parse_normal:nn #1#2
{
- \quark_if_recursion_tail_stop:n {#1}
\quark_if_recursion_tail_stop_do:nn {#2}
{ \msg_error:nn { cooking-units } { missing-argument } }
- \clist_if_in:NnF \g_@@_allowed_unit_phrases_clist {#1}
- { \@@_error_if_unit_not_defined:n {#1} }
- \@@_deftranslation:Vnn \l_@@_language_tl { #1 ( cu-unitname ) } {#2}
+ \prop_put:Nnn \l_@@_phrase_prop {#1} {#2}
+ \clist_if_in:NnF \l_@@_phrase_numbers_clist {#1}
+ { \clist_put_right:Nn \l_@@_phrase_numbers_clist {#1} }
\peek_meaning_ignore_spaces:NTF [
- { \@@_cuname_parse_bracket:nw {#1} }
- { \@@_cuname_parse_bracket:nw {#1} [#2] }
+ {
+ \@@_chuphrase_parse_plural:nw {#1}
+ }{
+ \@@_chuphrase_parse_plural:nw {#1} [#2]
+ }
}
+\cs_generate_variant:Nn \@@_cuphrase_parse_normal:nn { V }
% \end{macrocode}
%
% \begin{macrocode}
-\cs_new:Npn \@@_cuname_parse_bracket:nw #1 [#2]
+\cs_new:Npn \@@_chuphrase_parse_plural:nw #1 [#2]
{
-% \deftranslation [ to=\l_@@_language_tl ] { #1 ( cu-unitname pl ) } {#2}
- \clist_if_in:NnF \g_@@_allowed_unit_phrases_clist {#1}
- {
- \@@_deftranslation:Vnn \l_@@_language_tl { #1 ( cu-unitname pl ) } {#2}
- }
+ \prop_put:Nnn \l_@@_phrase_prop { #1-pl } {#2}
\peek_meaning_ignore_spaces:NTF <
- { \@@_cuname_parse_arrows:nw {#1} }
- { \@@_cuname_parse_arrows:nw {#1} <m> }
+ {
+ \@@_chuphrase_parse_gender:nw {#1}
+ }{
+ \@@_chuphrase_parse_gender:nw {#1} < m >
+ }
}
% \end{macrocode}
%
% \begin{macrocode}
-\cs_new:Npn \@@_cuname_parse_arrows:nw #1 <#2>
+\cs_new:Npn \@@_chuphrase_parse_gender:nw #1 <#2>
{
-% \deftranslation [ to=\l_@@_language_tl ] { #1 ( cu-unitgender ) } {#2}
- \@@_deftranslation:Vnn \l_@@_language_tl { #1 ( cu-unitgender ) } {#2}
- \@@_cuname_parse_input:n
+ \@@_check_if_correct_gender_input:n {#2}
+ \@@_deftranslation_to:Vxxn
+ \l_@@_language_tl { #1-phrase-gender }
+ \c_@@_postfix_gender_tl {#2}
+ \@@_cuphrase_parse:n
}
% \end{macrocode}
%
-%
-%
-% \subsection {cudefinesymbol}
-%
-%
-% \begin{macrocode}
-\NewDocumentCommand \cudefinesymbol { m m }
- {
- \tl_set:Nn \l_@@_language_tl {#1}
- \@@_cuprint_define_printed_unit:nn #2
- \q_recursion_tail \q_recursion_tail \q_recursion_stop
- }
-% \end{macrocode}
-%
-% \begin{macrocode}
-\cs_new:Npn \@@_cuprint_define_printed_unit:nn #1#2
- {
- \quark_if_recursion_tail_stop:n {#1}
- \quark_if_recursion_tail_stop_do:nn {#2}
- { \msg_error:nn { cooking-units } { missing-argument } }
- \clist_if_in:NnTF \g_@@_allowed_unit_phrases_clist {#1}
- {
- \@@_deftranslation:Vnn \l_@@_language_tl { #1 ( cu-unitname ) } {#2}
- }{
- \@@_error_if_unit_not_defined:n {#1}
- \@@_deftranslation:Vnn \l_@@_language_tl { #1 ( cu-unit ) } {#2}
- }
- \@@_cuprint_define_printed_unit:nn
- }
-% \end{macrocode}
-%
-%
-%
-%
-%
% \subsection {cusetup}
%
% \begin{macrocode}
@@ -4921,18 +6388,22 @@ and the derived file cooking-units.sty.
% \end{macrocode}
%
%
+%
+% \subsection{Definitions et all}
+%
% \begin{macrocode}
\newcookingunit { kg }
\newcookingunit { dag }
\newcookingunit { g }
\newcookingunit { oz }
\newcookingunit { lb }
+\newcookingunit { stick }
\newcookingunit [ \ensuremath{ \@@_frac:nn { eV } { c^2 } } ] { eVc-2 }
% \end{macrocode}
%
% \begin{macrocode}
-\newcookingunit [ \ensuremath{ {} ^ { \circ } } \kern-\scriptspace C ] { C }
\newcookingunit { K }
+\newcookingunit [ \ensuremath{ {} ^ { \circ } } \kern-\scriptspace C ] { C }
\newcookingunit [ \ensuremath{ {} ^ { \circ } } \kern-\scriptspace F ] { F }
\newcookingunit [ \ensuremath{ {} ^ { \circ } } \kern-\scriptspace R\'{e} ] { Re }
% \end{macrocode}
@@ -4980,8 +6451,10 @@ and the derived file cooking-units.sty.
\newcookingunit [ Msp. ] { Msp }
% \end{macrocode}
%
+% \begin{macrocode}
+\DeclareLanguageAlias { AmericanEnglish } { American }
+% \end{macrocode}
%
-% Notiz am mich: ueberall symbol dazugeben.
% \begin{macrocode}
\cudefinename { German }
{
@@ -5047,6 +6520,7 @@ and the derived file cooking-units.sty.
{ g } { gramme }
{ oz } { ounce }
{ lb } { pound } [ pounds ]
+ { stick } { stick } [ sticks ]
% \end{macrocode}
% \begin{macrocode}
{ d } { day } [ days ]
@@ -5082,10 +6556,10 @@ and the derived file cooking-units.sty.
% \end{macrocode}
% \begin{macrocode}
% { Msp } [ pinch ] { pinch } [ pinches ]
- { Msp } { Messerspitze } [ Messerspitzen ] <f>
+% { Msp } { Messerspitze } [ Messerspitzen ] <f>
{ pn } [ pinch ] { pinch } [ pinches ]
- { EL } [ tsp. ] { tablespoon } [ tablespoons ]
- { TL } [ tbsp. ] { teaspoon } [ teaspoons ]
+ { EL } [ tbsp. ] { tablespoon } [ tablespoons ]
+ { TL } [ tsp. ] { teaspoon } [ teaspoons ]
{ dsp } { dessertspoonful }
{ csp } { coffeespoonful }
{ ssp } { saltspoonful }
@@ -5120,7 +6594,7 @@ and the derived file cooking-units.sty.
{ ml } { milliliter } [ milliliters ]
% \end{macrocode}
% \begin{macrocode}
- { Msp } { Messerspitze } [ Messerspitzen ] <f>
+% { Msp } { Messerspitze } [ Messerspitzen ] <f>
{ pn } [ pn. ] { pinch } [ pinches ]
}
% \end{macrocode}
@@ -5188,10 +6662,10 @@ and the derived file cooking-units.sty.
{ dag }{ 100 }
{ g } { 1000 }
{ oz } { 35.27399 }
- { lb } { 2.204 622 6 } %% 2.204 622 6
+ { lb } { 2.2046226 } %% 2.204 622 6
+ { stick } { 8.81849 }
{ eVc-2 } { 560958865.0e+27 } %% 560958865.0 +- 3.5 e+27
}
-%\cuaddtokeys { kg } { eVc-2 } { 1.78266173e-16 }
% \end{macrocode}
% \begin{macrocode}
\cudefinekeys { d }
@@ -5267,14 +6741,18 @@ and the derived file cooking-units.sty.
%
%
% \begin{macrocode}
-%\fp_const:Nn \c_@@_K_min_fp { 0 }
-%\fp_const:Nn \c_@@_C_min_fp { -273.15 }
-%\fp_const:Nn \c_@@_F_min_fp { -459.67 }
-%\fp_const:Nn \c_@@_Re_min_fp { -218.52 }
+\cudefinephrase { German }
+ {
+% { 6 } * { halbes \ Dutzend } < n >
+% { 6 } { efkjwefjkl \ Dutzend } < n >
+ { 12 } { Dutzend } < n >
+% { 60 } { Schock } < n >
+% { 1728 } { Gro{\ss}gros } < n >
+% { 144 } { Gros } < n >
+ }
% \end{macrocode}
%
%
-%
% \subsection{Finish}
%
% \begin{macrocode}
@@ -5294,12 +6772,22 @@ and the derived file cooking-units.sty.
}
% \end{macrocode}
%
+%
+%
+%
+%
+%
+%
+%
+%
+%
% \begin{macrocode}
%</package>
% \end{macrocode}
%
% \end{implementation}
%
+%
% \endinput
%
%
diff --git a/Master/texmf-dist/source/latex/cooking-units/cooking-units.ins b/Master/texmf-dist/source/latex/cooking-units/cooking-units.ins
index ba80ea43655..da756d8a345 100644
--- a/Master/texmf-dist/source/latex/cooking-units/cooking-units.ins
+++ b/Master/texmf-dist/source/latex/cooking-units/cooking-units.ins
@@ -5,7 +5,7 @@
%% The original source files were:
%%
%% cooking-units.dtx (with options: `install')
-%% Copyright (C) 2016 by Ben Vitecek (current Maintainer)
+%% Copyright (C) 2016--2017 by Ben Vitecek (current Maintainer)
%%
%% This file may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License, either
@@ -14,7 +14,7 @@
%%
%% http://www.latex-project.org/lppl.txt
%%
-%% and version 1.3c or later is part of all distributions of
+%% and version 1.3 or later is part of all distributions of
%% LaTeX version 2008-05-04 or later.
%%
%% This work has the LPPL maintenance status `maintained'.
@@ -25,7 +25,7 @@
\input l3docstrip.tex
\askforoverwritefalse
\preamble
-Copyright (C) 2016 by Ben Vitecek (current Maintainer)
+Copyright (C) 2016--2017 by Ben Vitecek (current Maintainer)
This file may be distributed and/or modified under the
conditions of the LaTeX Project Public License, either
@@ -34,7 +34,7 @@ version. The latest version of this license is in:
http://www.latex-project.org/lppl.txt
-and version 1.3c or later is part of all distributions of
+and version 1.3 or later is part of all distributions of
LaTeX version 2008-05-04 or later.
This work has the LPPL maintenance status `maintained'.
@@ -49,6 +49,7 @@ and the derived file cooking-units.sty.
\file{\jobname.sty}{\from{\jobname.dtx}{package}}
}
\endbatchfile
+%%
\endinput
%%
%% End of file `cooking-units.ins'.
diff --git a/Master/texmf-dist/tex/latex/cooking-units/cooking-units.sty b/Master/texmf-dist/tex/latex/cooking-units/cooking-units.sty
index 701f8c3a718..466ca5b3b63 100644
--- a/Master/texmf-dist/tex/latex/cooking-units/cooking-units.sty
+++ b/Master/texmf-dist/tex/latex/cooking-units/cooking-units.sty
@@ -5,7 +5,7 @@
%% The original source files were:
%%
%% cooking-units.dtx (with options: `package')
-%% Copyright (C) 2016 by Ben Vitecek (current Maintainer)
+%% Copyright (C) 2016--2017 by Ben Vitecek (current Maintainer)
%%
%% This file may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License, either
@@ -14,7 +14,7 @@
%%
%% http://www.latex-project.org/lppl.txt
%%
-%% and version 1.3c or later is part of all distributions of
+%% and version 1.3 or later is part of all distributions of
%% LaTeX version 2008-05-04 or later.
%%
%% This work has the LPPL maintenance status `maintained'.
@@ -22,6 +22,7 @@
%% This work consists of the files README.md, cooking-units.dtx and cooking-units.ins
%% and the derived file cooking-units.sty.
%%
+%%
\@ifpackageloaded {xparse}
{ }
{ \RequirePackage {xparse} }
@@ -30,10 +31,10 @@
{ \RequirePackage {expl3} }
\ProvidesExplPackage
{cooking-units}
- {2016/11/13}
- {1.10}
+ {2017/10/23}
+ {1.2}
{Ein Paket fuer Kocheinheiten}
-\@ifpackagelater { expl3 } { 2016/05/18 }
+\@ifpackagelater { expl3 } { 2017/09/18 }
{ }
{
\PackageError { cooking-units } { Support~package~expl3~too~old }
@@ -44,70 +45,92 @@
}
\tex_endinput:D
}
-\@ifpackageloaded { translator } { } { \RequirePackage { translator } }
+\@ifpackageloaded { translations } { } { \RequirePackage { translations } }
\@ifpackageloaded { xfrac } { } { \RequirePackage { xfrac } }
\@ifpackageloaded { l3keys2e } { } { \RequirePackage { l3keys2e } }
-\bool_new:N \g__cooking_units_load_if_opt_numeral_bool
+\@ifpackagelater { translations } { 2017/08/31 }
+ { }
+ {
+ \PackageError { cooking-units } { Support~package~translations~too~old }
+ {
+ You~need~to~update~your~installation~of~the~package~'translations'.\MessageBreak
+ Loading~cooking-units~will~abort!
+ }
+ \tex_endinput:D
+ }
+\bool_new:N \g__cooking_units_opt_numeral_bool
\keys_define:nn { cooking-units }
{
- use-numerals .bool_gset:N = \g__cooking_units_load_if_opt_numeral_bool ,
+ use-numerals .bool_gset:N = \g__cooking_units_opt_numeral_bool ,
use-numerals .default:n = { false },
}
\ProcessKeysOptions { cooking-units }
-\bool_if:NT \g__cooking_units_load_if_opt_numeral_bool
+\bool_if:NT \g__cooking_units_opt_numeral_bool
{
\@ifpackageloaded { fmtcount } { } { \RequirePackage { fmtcount } }
}
\keys_define:nn { cooking-units }
{
- use-numerals .code:n = \msg_error:nnn { cooking-units } { load-time-option } { fmtcount } ,
+ use-numerals .code:n = { \msg_error:nnn { cooking-units } { load-time-option } { fmtcount } } ,
}
\cs_generate_variant:Nn \tl_replace_all:Nnn { NVn }
\cs_generate_variant:Nn \tl_replace_once:Nnn { NnV, NVn }
\cs_generate_variant:Nn \tl_if_in:nnTF { nVTF }
-\cs_generate_variant:Nn \tl_if_in:NnTF { NVTF }
+\cs_generate_variant:Nn \tl_if_in:NnTF { NVTF }
\cs_generate_variant:Nn \tl_if_in:NnT { NVT }
\cs_generate_variant:Nn \fp_compare:nNnT { cNnT }
\cs_generate_variant:Nn \fp_eval:n { c }
\cs_generate_variant:Nn \prop_get:cVN { cVc }
\cs_generate_variant:Nn \int_abs:n { c }
-\cs_generate_variant:Nn \tl_show:n { f , x }
-\cs_generate_variant:Nn \fp_compare:nNnTF { v }
+\cs_generate_variant:Nn \tl_show:n { x , f }
\cs_new_eq:NN \__cooking_units_frac:nn \sfrac
+\cs_new:Npn \__cooking_units_print_numeral:n #1 {}
+\cs_new:Npn \__cooking_units_print_Numeral:n #1 {}
+\bool_if:NT \g__cooking_units_opt_numeral_bool
+ {
+ \cs_set_eq:NN \__cooking_units_print_numeral:n \numberstringnum
+ \cs_set_eq:NN \__cooking_units_print_Numeral:n \Numberstringnum
+ }
\prop_new:N \l__cooking_units_change_unit_prop
+\tl_new:N \l__cooking_units_number_tmpa_tl
+\tl_new:N \l__cooking_units_number_tmpb_tl
\tl_new:N \l__cooking_units_tmpa_tl
\tl_new:N \l__cooking_units_tmpb_tl
\tl_new:N \l__cooking_units_mixed_fraction_tl
-\tl_new:N \l__cooking_units_tmp_unit_tl
+\tl_new:N \l__cooking_units_given_unit_tl
\tl_new:N \l__cooking_units_option_unit_tl
\tl_new:N \l__cooking_units_language_tl
\tl_new:N \l__cooking_units_cunum_range_sign_tl
\tl_new:N \l__cooking_units_cutext_range_sign_tl
\tl_new:N \l__cooking_units_value_unit_space_tl
\tl_new:N \l__cooking_units_input_digits_tl
-\tl_new:N \l__cooking_units_decimal_mark_tl
-\tl_new:N \l__cooking_units_value_signs_tl
-\tl_new:N \l__cooking_units_allowed_special_signs_tl
-\tl_new:N \c__cooking_units_str_hash_one_tl
+\tl_new:N \l__cooking_units_input_decimal_mark_tl
+\tl_new:N \l__cooking_units_input_value_signs_tl
+\tl_new:N \l__cooking_units_input_allowed_special_signs_tl
+\tl_new:N \c__cooking_units_input_str_hash_one_tl
\tl_new:N \l__cooking_units_input_range_sign_tl
-\tl_new:N \l__cooking_units_input_for_persons_sign
\tl_new:N \l__cooking_units_input_times_persons_sign
\tl_new:N \l__cooking_units_cutext_space_tl
+\tl_new:N \l__cooking_units_cuphrase_space_tl
\tl_new:N \l__cooking_units_translation_tmpa_tl
-\tl_new:N \l__cooking_units_cutext_tmp_tl
-\tl_set:Nn \l__cooking_units_cunum_range_sign_tl { -- }
-\tl_set:Nn \l__cooking_units_cutext_range_sign_tl { -- }
-\tl_set:Nn \l__cooking_units_value_unit_space_tl { \thinspace }
+\tl_new:N \l__cooking_units_cutext_last_value_tl
+\tl_new:N \l__cooking_units_phantom_tl
+\tl_new:N \l__cooking_units_phrase_phrase_tl
+\tl_new:N \l__cooking_units_unit_key_not_allowed_tl
\tl_set:Nn \l__cooking_units_input_digits_tl { 0123456789 }
-\tl_set:Nn \l__cooking_units_input_for_persons_sign { @ }
\tl_set:Nn \l__cooking_units_input_times_persons_sign { * }
-\tl_set:Nn \l__cooking_units_decimal_mark_tl { . , }
-\tl_set:Nn \l__cooking_units_value_signs_tl { + - }
\tl_set:Nn \l__cooking_units_input_range_sign_tl { -- }
-\tl_set:Nn \l__cooking_units_allowed_special_signs_tl { ? }
-\tl_set_rescan:Nnn \c__cooking_units_str_hash_one_tl
+\tl_set:Nn \l__cooking_units_input_decimal_mark_tl { . , }
+\tl_set:Nn \l__cooking_units_input_value_signs_tl { + - }
+\tl_set:Nn \l__cooking_units_input_allowed_special_signs_tl { ? }
+\tl_set_rescan:Nnn \c__cooking_units_input_str_hash_one_tl
{ \char_set_catcode_letter:N \# } {#1}
+\tl_set:Nn \l__cooking_units_cunum_range_sign_tl { -- }
+\tl_set:Nn \l__cooking_units_cutext_range_sign_tl { -- }
+\tl_set:Nn \l__cooking_units_value_unit_space_tl { \thinspace }
\tl_set:Nn \l__cooking_units_cutext_space_tl { \space }
+\tl_set:Nn \l__cooking_units_cuphrase_space_tl { \space }
+\tl_set:Nn \l__cooking_units_unit_key_not_allowed_tl { , / }
\AtBeginDocument {
\cs_if_free:cT { T@TS1 }
{
@@ -132,59 +155,61 @@
}
\dim_new:N \l__cooking_units_mixed_frac_dim
\dim_set:Nn \l__cooking_units_mixed_frac_dim { 0.1 em }
-\int_new:N \l__cooking_units_persons_tmp_int
\int_new:N \l__cooking_units_significant_figures_int
\int_new:N \l__cooking_units_significant_figures_plus_one_int
\int_set:Nn \l__cooking_units_significant_figures_int { 2 }
\int_set:Nn \l__cooking_units_significant_figures_plus_one_int { 2 + 1 }
\int_new:N \l__cooking_units_print_numerals_below_int
\int_set:Nn \l__cooking_units_print_numerals_below_int { 13 }
+\int_new:N \l__cooking_units_number_of_persons_tmpa_int
\int_new:N \l__cooking_units_calc_for_number_of_persons_int
\int_set:Nn \l__cooking_units_calc_for_number_of_persons_int { 4 }
-\clist_new:N \l__cooking_units_list_of_defined_keys_clist
-\clist_new:N \g__cooking_units_list_of_defined_units_clist
-\clist_new:N \g__cooking_units_allowed_unit_phrases_clist
-\clist_new:N \l__cooking_units_temperatures_to_check_clist
+\int_new:N \l__cooking_units_phrase_number_tl
+\seq_new:N \l__cooking_units_list_of_defined_keys_seq
+\seq_new:N \g__cooking_units_list_of_defined_units_seq
+\clist_new:N \g__cooking_units_allowed_special_keys_clist
+\clist_new:N \l__cooking_units_phrase_numbers_clist
+\seq_new:N \l__cooking_units_temperatures_to_check_seq
+\prop_new:N \l__cooking_units_phrase_prop
+\bool_new:N \l__cooking_units_minus_bool
+\bool_new:N \l__cooking_units_round_decimal_part_bool
\bool_new:N \l__cooking_units_error_bool
\bool_new:N \l__cooking_units_eval_fractions_bool
\bool_new:N \l__cooking_units_parse_input_bool
\bool_new:N \l__cooking_units_round_to_int_bool
\bool_new:N \l__cooking_units_special_sign_bool
-\bool_new:N \l__cooking_units_decimal_in_input_bool
\bool_new:N \l__cooking_units_single_key_bool
-\bool_new:N \l__cooking_units_fraction_in_input_bool
\bool_new:N \l__cooking_units_check_temperature_bool
\bool_new:N \l__cooking_units_convert_to_eV_bool
\bool_new:N \l__cooking_units_cutext_uppercase_word_bool
\bool_new:N \l__cooking_units_error_for_unknown_value_bool
-\bool_new:N \l__cooking_units_parse_range_bool
\bool_new:N \l__cooking_units_using_cutext_bool
\bool_new:N \l__cooking_units_cuam_old_bool
\bool_new:N \l__cooking_units_calc_for_persons_bool
\bool_new:N \l__cooking_units_calc_because_ref_was_given_bool
-\bool_new:N \l__cooking_units_calc_persons_tmp_bool
+\bool_new:N \l__cooking_units_calc_persons_bool
\bool_new:N \l__cooking_units_cutext_to_cunum_bool
\bool_new:N \l__cooking_units_cutext_old_bool
\bool_new:N \l__cooking_units_cutext_change_unit_bool
\bool_new:N \l__cooking_units_round_commercial_bool
+\bool_new:N \l__cooking_units_use_phrases_bool
+\bool_new:N \l__cooking_units_check_if_phrase_used_bool
+\bool_new:N \l__cooking_units_local_numeral_bool
+\bool_new:N \l__cooking_units_range_in_input_bool
+\bool_new:N \l__cooking_units_fraction_in_input_bool
+\bool_new:N \l__cooking_units_decimal_in_input_bool
\bool_set_true:N \l__cooking_units_parse_input_bool
\bool_set_true:N \l__cooking_units_cutext_change_unit_bool
+\bool_set_eq:NN \l__cooking_units_local_numeral_bool \g__cooking_units_opt_numeral_bool
\quark_new:N \q__cooking_units_range
-\clist_gset:Nn \g__cooking_units_allowed_unit_phrases_clist
- {
- decimal-mark ,
- one (m) ,
- one (f) ,
- one (n)
- }
-\newtranslation { decimal-mark (cu-unitname) } { . }
-\newtranslation [ to=German ] { decimal-mark (cu-unitname) } { , }
-\newtranslation { one (m) (cu-unitname) } { one }
-\newtranslation { one (f) (cu-unitname) } { one }
-\newtranslation { one (n) (cu-unitname) } { one }
-\newtranslation [ to=German ] { one (m) (cu-unitname) } { ein }
-\newtranslation [ to=German ] { one (f) (cu-unitname) } { eine }
-\newtranslation [ to=German ] { one (n) (cu-unitname) } { ein }
+\quark_new:N \q__cooking_units_no_translation
+\fp_new:N \l__cooking_units_tmpa_fp
+\clist_new:N \l__cooking_units_tmpa_clist
+\prop_new:N \l__cooking_units_tmpa_prop
+\prop_new:N \l__cooking_units_tmpb_prop
+\seq_new:N \l__cooking_units_tmpa_seq
+\int_new:N \l__cooking_units_tmpa_int
+\int_new:N \l__cooking_units_tmpb_int
\keys_define:nn { cooking-units }
{
eval-fraction .bool_set:N = \l__cooking_units_eval_fractions_bool ,
@@ -207,19 +232,29 @@
cunum-range-sign .default:n = { -- } ,
cutext-range-sign .tl_set:N = \l__cooking_units_cutext_range_sign_tl ,
cutext-range-sign .default:n = { -- } ,
- value-unit-space .tl_set:N = \l__cooking_units_value_unit_space_tl ,
- value-unit-space .default:n = { \thinspace } ,
+ amount-unit-space .tl_set:N = \l__cooking_units_value_unit_space_tl ,
+ amount-unit-space .default:n = { \thinspace } ,
fraction-command .code:n = { \cs_set_eq:NN \__cooking_units_frac:nn #1 } ,
fraction-command .default:n = { \sfrac } ,
fraction-inline .code:n = { \cs_set:Npn \__cooking_units_frac:nn ##1##2 {#1} } ,
- fraction-inline .default:n = { \sfrac {#1}{#2} } ,
+ fraction-inline .default:n = { \sfrac {#1} {#2} } ,
mixed-fraction-space .dim_set:N = \l__cooking_units_mixed_frac_dim ,
mixed-fraction-space .default:n = { 0.1 em } ,
parse-number .bool_set:N = \l__cooking_units_parse_input_bool ,
parse-number .default:n= { true } ,
- add-special-sign .code:n = { \tl_put_right:Nn \l__cooking_units_allowed_special_signs_tl {#1} } ,
+ add-special-sign .code:n =
+ {
+ \str_if_eq:nnTF {#1} { < }
+ { \msg_error:nn { cooking-units } { <-not-allowed-as-special-sign } }
+ { \tl_put_right:Nn \l__cooking_units_input_allowed_special_signs_tl {#1} }
+ } ,
add-special-sign .default:n = { } ,
- set-special-sign .tl_set:N = \l__cooking_units_allowed_special_signs_tl ,
+ set-special-sign .code:n =
+ {
+ \str_if_eq:nnTF {#1} { < }
+ { \msg_error:nn { cooking-units } { <-not-allowed-as-special-sign } }
+ { \tl_set:Nn \l__cooking_units_input_allowed_special_signs_tl {#1} }
+ } ,
input-range-sign .tl_set:N = \l__cooking_units_input_range_sign_tl ,
input-range-sign .default:n = { -- } ,
check-temperature .bool_set:N = \l__cooking_units_check_temperature_bool ,
@@ -244,9 +279,16 @@
{ \l_keys_choice_tl }
} ,
set-unknown-message .default:n = { warning } ,
+ set-cutext-translation-message .choices:nn =
+ { error , warning , none }
+ {
+ \msg_redirect_name:nnn { cooking-units } { cutext-no-translation-available }
+ { \l_keys_choice_tl }
+ } ,
+ set-cutext-translation-message .default:n = { warning } ,
erase-all-options .code:n =
{
- \clist_map_inline:Nn \g__cooking_units_list_of_defined_units_clist
+ \seq_map_inline:Nn \g__cooking_units_list_of_defined_units_seq
{
\clist_clear:c { l__cooking_units_predefined_option_##1_clist }
}
@@ -304,8 +346,16 @@
cutext-to-cunum .default:n = { false } ,
cutext-space .tl_set:N = \l__cooking_units_cutext_space_tl ,
cutext-space .default:n = { \space } ,
+ phrase-space .tl_set:N = \l__cooking_units_cuphrase_space_tl ,
+ phrase-space .default:n = { \space } ,
cutext-change-unit .bool_set:N = \l__cooking_units_cutext_change_unit_bool ,
cutext-change-unit .default:n = { true } ,
+ use-phrases .bool_set:N = \l__cooking_units_use_phrases_bool ,
+ use-phrases .default:n = { true } ,
+ print-numerals .bool_set:N = \l__cooking_units_local_numeral_bool ,
+ print-numerals .default:n = { true } ,
+ numeral-function .code:n = { \cs_set_eq:NN \__cooking_units_print_numeral:n #1 } ,
+ Numeral-function .code:n = { \cs_set_eq:NN \__cooking_units_print_Numeral:n #1 } ,
}
\msg_new:nnnn { cooking-units } { fraction-not-allowed-with-range }
{
@@ -324,7 +374,7 @@
a \ normal \ fraction \ ('/').
\msg_see_documentation_text:n { cooking-units }
}
-\msg_new:nnnn { cooking-units } { unknown - unit }
+\msg_new:nnnn { cooking-units } { unknown-unit }
{
The \ unit \ '#1' \ is \ not \ defined. \ Use \
\newcookingunit \ to \ define \ new \ units.
@@ -355,13 +405,13 @@
The \ command \ accepts \ only \ a \ fixed \ number \ of \ tokens.
\msg_see_documentation_text:n {cooking-units}
}
-\msg_new:nnnn { cooking-units } { Second - decimal -sign - not - allowed }
+\msg_new:nnnn { cooking-units } { Second-decimal-sign-not-allowed }
{ A \ second \ decimal \ sign \ is \ not \ allowed. }
{
Perhaps \ you \ didn't \ type \ it \ correctly.
\msg_see_documentation_text:n {cooking-units}
}
-\msg_new:nnnn { cooking-units } { Key - not -defined }
+\msg_new:nnnn { cooking-units } { Key-not-defined }
{
The \ key \ '#1' \ is \ not \ defined. \ Use \ \cudefinekeys or \
\cudefinesinglekey to \ define \ keys.
@@ -370,11 +420,13 @@
This \ key \ is \ not \ defined, \ perhaps \ you \ misspelled \ it.
\msg_see_documentation_text:n {cooking-units}
}
-\msg_new:nnnn { cooking-units } { Temperature-to-low }
+\msg_new:nnnn { cooking-units } { Temperature-too-low }
{
- The \ temperature \ '#1' \ is \ to \ low.\ It \ cannot \ be \
+ The \ temperature \ '#1' \ is \ too \ low.\ It \ cannot \ be \
below \ the \ absolute \ zero - point \ of \ '#2'. \ Note \ that \
- by \ default \ the \ temperatures \ 'C', \ 'F' , \ 'K' \ and \ 'Re' \
+ the \ temperatures \
+ '\seq_use:Nnnn \l__cooking_units_temperatures_to_check_seq
+ { ', ~ ' } { ', ~ ' } { ' ~ and ~ ' }' \
are \ rounded \ to \ integers.
\\\\
You \ can \ disable \ the \ option \ 'check-temperature' \ to \
@@ -389,7 +441,7 @@
{
The \ key \ accepts \ accepts\ only \ a \ fixed \ set \ of \ choices. \
You \ can \ add \ new \ choices \ via \ \cuaddkeys, \ \cuaddsinglekeys \
- and \ \cuaddtokeys.
+ and \ \cuaddtokeys{}.
\msg_see_documentation_text:n {cooking-units}
}
\msg_new:nnnn { cooking-units } { amount-not-known }
@@ -452,7 +504,7 @@
\msg_new:nnnn { cooking-units } { Number-of-persons-is-not-an-integer }
{
The \ number \ of \ persons \ the \ recipe \ is \ for \ must \ be \ an \
- integer.
+ integer. \ '#1' \ is \ not \ allowed.
}
{
The \ number \ '#1' \ is \ not \ allowed.
@@ -482,13 +534,59 @@
{
\msg_see_documentation_text:n { cooking-units }
}
+\msg_new:nnnn { cooking-units } { phrase-unit-not-an-integer }
+ {
+ A \ phrase \ must \ be \ an \ integer, \ '#1' \ is \ not \ allowed.
+ }
+ {
+ You \ can \ only \ use \ integers.
+ \msg_see_documentation_text:n { cooking-units }
+ }
+\msg_new:nnnn { cooking-units } { cutext-no-translation-available } %% ToDo
+ {
+ For \ the \ unit \ '#1' \ there \ exists \ no \ translation \ to \ be \ used \
+ for \ \cutext and \ \Cutext{}. \
+ You \ can \ define \ new \ translations \ for \ a \ given \ language \ using \
+ \cudefinename{}.
+ }
+ {
+ \cunum \ is \ used \ instead.
+ \msg_see_documentation_text:n { cooking-units }
+ }
+\msg_new:nnnn { cooking-units } { Translation-not-available } %% ToDo
+ {
+ The \ translation \ for \ #1 \ does \ not \ exist.
+ Please \ define \ it \ using \ \cudefinename{}.
+ }
+ {
+ And \ you \ may \ send \ me \ the \ translation \ as \ it \ is \
+ not \ available \ yet.
+ \msg_see_documentation_text:n { cooking-units }
+ }
+\msg_new:nnnn { cooking-units } { <-not-allowed-as-special-sign }
+ {
+ Currently \ (and \ probably \ forever) \ the \ sign \ '<' \
+ is \ not \ allowed \ to \ be \ used \ as \ a \ special \ sign.
+ }
+ {
+ I \ apologize \ for \ the \ inconvenience.
+ \msg_see_documentation_text:n { cooking-units }
+ }
+\msg_new:nnnn { cooking-units } { unknown-gender }
+ {
+ '#1' \ is \ not \ allowed \ to \ be \ used \ as \ a \ gender-specification.
+ Only \ 'm', \ 'f' \ or \ 'n' \ are \ allowed
+ }{
+ Please \ remove \ spaces \ if \ there \ are \ some.
+ \msg_see_documentation_text:n { cooking-units }
+ }
\cs_new:Npn \__cooking_units_error_if_unit_not_defined:n #1
{
- \clist_if_in:NnF \g__cooking_units_list_of_defined_units_clist {#1}
+ \seq_if_in:NnF \g__cooking_units_list_of_defined_units_seq {#1}
{ \msg_error:nnn { cooking-units } { unknown-unit } {#1} }
}
\cs_generate_variant:Nn \__cooking_units_error_if_unit_not_defined:n { V }
-\prg_new_protected_conditional:Npnn \__cooking_units_if_integer:n #1 { TF }
+\prg_new_protected_conditional:Npnn \__cooking_units_if_integer:n #1 { TF , F , T }
{
\tl_map_inline:nn {#1}
{
@@ -499,7 +597,10 @@
}
\use_i:nn \prg_return_true: \prg_return_false:
}
-\prg_new_protected_conditional:Npnn \__cooking_units_if_integer_and_parse:n #1 { TF }
+\cs_generate_variant:Nn \__cooking_units_if_integer:nTF { V }
+\cs_generate_variant:Nn \__cooking_units_if_integer:nT { V }
+\cs_generate_variant:Nn \__cooking_units_if_integer:nF { V }
+\prg_new_protected_conditional:Npnn \__cooking_units_if_parse_and_integer:n #1 { TF }
{
\bool_if:NTF \l__cooking_units_parse_input_bool
{
@@ -509,48 +610,70 @@
}
{ \prg_return_false: }
}
-\cs_generate_variant:Nn \__cooking_units_if_integer_and_parse:nTF { V }
-\cs_new:Npn \__cooking_units_convert_to_eV:
+\cs_generate_variant:Nn \__cooking_units_if_parse_and_integer:nTF { V }
+\prg_new_conditional:Npnn \__cooking_units_fp_if_equal_one:n #1 { TF }
{
- \keys_set:nn { cooking-units }
- {
- m= chbareV-1,
- cm= chbareV-1,
- dm= chbareV-1,
- mm= chbareV-1,
- in= chbareV-1,
- kg= eVc-2,
- dag= eVc-2,
- g= eVc-2,
- oz= eVc-2,
- lb= eVc-2,
- d= hbareV-1,
- h= hbareV-1,
- min= hbareV-1,
- s= hbareV-1,
- cal= eV,
- kcal= eV,
- J= eV,
- kJ= eV,
- F= eV,
- K= eV,
- C= eV,
- Re= eV,
- l= (chbareV-1)3 ,
- dl= (chbareV-1)3 ,
- cl= (chbareV-1)3 ,
- ml= (chbareV-1)3 ,
- }
- }
-\cs_new:Npn \__cooking_units_deftranslation:Nnn #1#2#3
- {
- \deftranslation [ to=#1 ] {#2} {#3}
- }
-\cs_generate_variant:Nn \__cooking_units_deftranslation:Nnn { Vnn , Vnv }
-\cs_new:Npn \__cooking_units_tl_set_fp_and_eval:Nn #1#2
+ \fp_compare:nNnTF {#1} = { \c_one_fp }
+ { \prg_return_true: }
+ { \prg_return_false: }
+ }
+\prg_new_conditional:Npnn \__cooking_units_int_if_equal_one:n #1 { TF }
+ {
+ \int_compare:nNnTF {#1} = { \c_one }
+ { \prg_return_true: }
+ { \prg_return_false: }
+ }
+\cs_new:Npn \__cooking_units_check_if_correct_gender_input:n #1
+ {
+ \str_case:nnF {#1}
+ {
+ { m } {}
+ { f } {}
+ { n } {}
+ } { \msg_error:nnn { cooking-units } { unknown-gender } {#1} }
+ }
+\seq_new:N \g__cooking_units_natural_units_seq
+\prop_new:N \g__cooking_units_convert_to_eV_remember_prop
+\seq_set_split:Nnn \g__cooking_units_natural_units_seq { , }
+ {
+ eV ,
+ eVc-2 ,
+ hbareV-1 ,
+ chbareV-1 ,
+ (chbareV-1)3 ,
+ }
+\cs_new:Npn \__cooking_units_keys_set:nnn #1#2#3
{
- \tl_set:Nf #1 { \fp_eval:n {#2} }
+ \keys_set:nn {#1} { #2 = #3 }
+ }
+\cs_generate_variant:Nn \__cooking_units_keys_set:nnn { nVV , nVn }
+\cs_new:Npn \__cooking_units_convert_to_eV:
+ {
+ \prop_if_exist:cT { l__cooking_units_cukeys_ \l__cooking_units_given_unit_tl _prop }
+ {
+ \prop_get:NVNTF \g__cooking_units_convert_to_eV_remember_prop
+ \l__cooking_units_given_unit_tl \l__cooking_units_tmpa_tl
+ {
+ \__cooking_units_keys_set:nVV { cooking-units } \l__cooking_units_given_unit_tl \l__cooking_units_tmpa_tl
+ }{
+ \prop_get:cnNT { l__cooking_units_cukeys_ \l__cooking_units_given_unit_tl _prop } { Liste } \l__cooking_units_tmpa_seq
+ {
+ \seq_map_inline:Nn \g__cooking_units_natural_units_seq
+ {
+ \seq_if_in:NnT \l__cooking_units_tmpa_seq {##1}
+ {
+ \prop_gput:NVn \g__cooking_units_convert_to_eV_remember_prop
+ \l__cooking_units_given_unit_tl {##1}
+ \__cooking_units_keys_set:nVn { cooking-units } \l__cooking_units_given_unit_tl {##1}
+ \seq_map_break:
+ }
+ }
+ }
+ }
+ }
}
+\cs_new:Npn \__cooking_units_tl_set_fp_and_eval:Nn #1#2
+ { \tl_set:Nx #1 { \fp_eval:n {#2} } }
\cs_generate_variant:Nn \__cooking_units_tl_set_fp_and_eval:Nn { Nc }
\cs_new:Npn \__cooking_units_temperature_to_check_print_error:n #1
{
@@ -562,7 +685,7 @@
\fp_if_exist:cTF { c__cooking_units_ #1 _min_fp }
{ \msg_warning:nnn { cooking-units } { Minimum-already-defined } {#1} }
{
- \clist_put_right:Nn \l__cooking_units_temperatures_to_check_clist {#1}
+ \seq_put_right:Nn \l__cooking_units_temperatures_to_check_seq {#1}
\fp_const:cn { c__cooking_units_ #1 _min_fp } {#2}
}
}
@@ -571,81 +694,70 @@
#1
\bool_if:NTF \l__cooking_units_round_commercial_bool
{
+ ,
\bool_if:NTF \l__cooking_units_round_to_int_bool
- { , \c_zero_fp }
- { , \l__cooking_units_significant_figures_int }
+ { \c_zero_fp }
+ { \l__cooking_units_significant_figures_int }
, #1
}
{ \bool_if:NF \l__cooking_units_round_to_int_bool { , \l__cooking_units_significant_figures_int } }
}
\cs_new:Npn \__cooking_units_label_and_persons:n #1
{
- \tl_if_in:nnTF {#1} { @ }
+ \tl_if_in:nnTF {#1} { * }
{
- \__cooking_units_label_and_persons_for_persons:ww #1 \q_stop
+ \__cooking_units_label_and_persons_times_persons:ww #1 \q_stop
}{
- \tl_if_in:nnTF {#1} { * }
- {
- \__cooking_units_label_and_persons_times_persons:ww #1 \q_stop
- }{
- \msg_error:nnn { cooking-units} { Number-of-persons-missing } {#1}
- }
+ \msg_error:nnn { cooking-units} { Number-of-persons-missing } {#1}
}
}
-\cs_new:Npn \__cooking_units_label_and_persons_for_persons:ww #1 @ #2 \q_stop
- {
- \__cooking_units_culabel:nnn {#1} {#2} { }
- }
\cs_new:Npn \__cooking_units_label_and_persons_times_persons:ww #1 * #2 \q_stop
{
- \__cooking_units_culabel:nnn {#1} {#2} { - }
- }
-\cs_new:Npn \__cooking_units_reference_label_and_persons:n #1
- {
- \int_if_exist:cTF { l__cooking_units_persons_ #1 _int }
- {
- \bool_set_true:N \l__cooking_units_calc_because_ref_was_given_bool
- \int_set:Nn \l__cooking_units_persons_tmp_int
- {
- \int_abs:c { l__cooking_units_persons_ #1 _int }
- }
- }
- { \msg_error:nnn { cooking-units } { label-not-defined } {#1} }
+ \__cooking_units_culabel:nn {#1} {#2}
}
-\cs_new:Npn \__cooking_units_culabel:nnn #1#2#3
+\cs_new:Npn \__cooking_units_culabel:nn #1#2
{
- \int_if_exist:cTF { l__cooking_units_persons_ #1 _int }
+ \int_if_exist:cTF { l__cooking_units_number_of_persons_ #1 _int }
{
\msg_error:nnn { cooking-units } { label-already-defined } {#1}
}{
\__cooking_units_if_integer:nTF {#2}
{
- \int_new:c { l__cooking_units_persons_ #1 _int }
- \int_gset:cn { l__cooking_units_persons_ #1 _int } { #3 #2 }
+ \int_new:c { l__cooking_units_number_of_persons_ #1 _int }
+ \int_gset:cn { l__cooking_units_number_of_persons_ #1 _int } {#2}
}
{ \msg_error:nnn { cooking-units } { Number-of-persons-is-not-an-integer } {#2} }
}
}
+\cs_new:Npn \__cooking_units_reference_label_and_persons:n #1
+ {
+ \int_if_exist:cTF { l__cooking_units_number_of_persons_ #1 _int }
+ {
+ \bool_set_true:N \l__cooking_units_calc_because_ref_was_given_bool
+ \int_set_eq:Nc \l__cooking_units_number_of_persons_tmpa_int
+ { l__cooking_units_number_of_persons_ #1 _int }
+ }
+ { \msg_error:nnn { cooking-units } { label-not-defined } {#1} }
+ }
\cs_new:Npn \__cooking_units_curef:n #1
{
- \int_if_exist:cTF { l__cooking_units_persons_ #1 _int }
+ \int_if_exist:cTF { l__cooking_units_number_of_persons_ #1 _int }
{
\bool_if:NTF \l__cooking_units_calc_for_persons_bool
{ \int_use:N \l__cooking_units_calc_for_number_of_persons_int }
- { \int_abs:c { l__cooking_units_persons_ #1 _int } }
+ { \int_use:c { l__cooking_units_number_of_persons_ #1 _int } }
}{ \msg_error:nnn { cooking-units } { label-not-defined } {#1} }
}
-\NewDocumentCommand \culabel { m m } { \__cooking_units_culabel:nnn {#1} {#2} {} }
-\DeclareExpandableDocumentCommand \curef { m } { \__cooking_units_curef:n {#1} }
+\NewDocumentCommand \culabel { m m } { \__cooking_units_culabel:nn {#1} {#2} }
+\NewExpandableDocumentCommand \curef { m } { \__cooking_units_curef:n {#1} }
\cs_new:Npn \__cooking_units_tl_if_in_remove_and_set_bool:NnN #1#2#3
{
\tl_if_in:NnTF #1 {#2}
{
\bool_set_true:N #3
\tl_remove_once:Nn #1 {#2}
- }{
- \bool_set_false:N #3
}
+ { \bool_set_false:N #3 }
}
\cs_new:Npn \__cooking_units_tl_if_in_remove_and_reverse_bool:NnN #1#2#3
{
@@ -657,13 +769,97 @@
\tl_remove_once:Nn #1 {#2}
}
}
-\cs_new:Npn \__cooking_units_cunum_parse_input:N #1
+\tl_const:Nn \c__cooking_units_postfix_unit_tl { ( cu-unit ) }
+\tl_const:Nn \c__cooking_units_postfix_unit_pl_tl { ( cu-unit-pl ) }
+\tl_const:Nn \c__cooking_units_postfix_unitname_tl { ( cu-unitname ) }
+\tl_const:Nn \c__cooking_units_postfix_unitname_pl_tl { ( cu-unitname-pl ) }
+\tl_const:Nn \c__cooking_units_postfix_gender_tl { ( cu-unitgender ) }
+\tl_const:Nn \c__cooking_units_postfix_phrase_tl { ( cu-unitphrase ) }
+\cs_new:Npn \__cooking_units_deftranslation_base:nnn #1#2#3
+ {
+ \declaretranslationfallback { #1 #2 } {#3}
+ }
+\cs_new:Npn \__cooking_units_deftranslation_to:nnnn #1#2#3#4
+ {
+ \declaretranslation {#1} { #2 #3 } {#4}
+ }
+\cs_generate_variant:Nn \__cooking_units_deftranslation_base:nnn { xx , xxV }
+\cs_generate_variant:Nn \__cooking_units_deftranslation_to:nnnn { Vxxv, VxxV , Vxxn, Vxxx,Vxxo,Vxxf }
+\cs_new:Npn \__cooking_units_newtranslation_base:nnn #1#2#3
+ {
+ \definetranslationfallback { #1 #2 } {#3}
+ }
+\cs_new:Npn \__cooking_units_newtranslation_to:nnnn #1#2#3#4
+ {
+ \definetranslation {#1} { #2 #3 } {#4}
+ }
+\cs_generate_variant:Nn \__cooking_units_newtranslation_base:nnn { nVn }
+\cs_generate_variant:Nn \__cooking_units_newtranslation_to:nnnn { nnVn }
+\cs_new:Npn \__cooking_units_translate:nn #1#2
+ {
+ \GetTranslation { #1 #2 }
+ }
+\cs_new:Npn \__cooking_units_translate_let:Nnn #1#2#3
+ {
+ \SaveTranslation {#1} { #2 #3 }
+ }
+\cs_new:Npn \__cooking_units_translate_let:nNnn #1#2#3#4
{
- \bool_if:NTF \l__cooking_units_parse_range_bool
+ \SaveTranslationFor {#2} {#1} { #3 #4 }
+ }
+\cs_generate_variant:Nn \__cooking_units_translate:nn { xx }
+\cs_generate_variant:Nn \__cooking_units_translate_let:Nnn { Nxx }
+\cs_generate_variant:Nn \__cooking_units_translate_let:nNnn { VNxx, nNxx }
+\prg_new_conditional:Npnn \__cooking_units_unitname_get:Nn #1#2 { F }
+ {
+ \__cooking_units_translate_let:Nxx #1 {#2} \c__cooking_units_postfix_unitname_tl
+ \tl_if_eq:NNTF #1 \q__cooking_units_no_translation
+ { \prg_return_false: }
+ { \prg_return_true: }
+ }
+\cs_generate_variant:Nn \__cooking_units_unitname_get:NnF { Nx }
+\cs_new:Npn \__cooking_units_translate_one_to_and_check_existance:Nx #1#2
+ {
+ \__cooking_units_translate_let:Nxx #1 {#2} \c__cooking_units_postfix_gender_tl
+ \__cooking_units_unitname_get:NxF #1 { one (#1) }
+ {
+ \__cooking_units_translate_let:Nxx #1 {#2} \c__cooking_units_postfix_gender_tl
+ \msg_error:nnn { cooking-units } { Translation-not-available } { one (#1) }
+ }
+ }
+\clist_gset:Nn \g__cooking_units_allowed_special_keys_clist
+ {
+ decimal-mark ,
+ one (m) ,
+ one (f) ,
+ one (n)
+ }
+\__cooking_units_newtranslation_base:nVn { decimal-mark } \c__cooking_units_postfix_unitname_tl { . }
+\__cooking_units_newtranslation_base:nVn { decimal-mark } \c__cooking_units_postfix_unitname_pl_tl { \q__cooking_units_no_translation }
+\__cooking_units_newtranslation_to:nnVn { German } { decimal-mark } \c__cooking_units_postfix_unitname_tl { , }
+\__cooking_units_newtranslation_base:nVn { one (m) } \c__cooking_units_postfix_unitname_tl { \q__cooking_units_no_translation }
+\__cooking_units_newtranslation_base:nVn { one (f) } \c__cooking_units_postfix_unitname_tl { \q__cooking_units_no_translation }
+\__cooking_units_newtranslation_base:nVn { one (n) } \c__cooking_units_postfix_unitname_tl { \q__cooking_units_no_translation }
+\__cooking_units_newtranslation_base:nVn { one (m) } \c__cooking_units_postfix_unitname_pl_tl { \q__cooking_units_no_translation }
+\__cooking_units_newtranslation_base:nVn { one (f) } \c__cooking_units_postfix_unitname_pl_tl { \q__cooking_units_no_translation }
+\__cooking_units_newtranslation_base:nVn { one (n) } \c__cooking_units_postfix_unitname_pl_tl { \q__cooking_units_no_translation }
+\__cooking_units_newtranslation_to:nnVn { English } { one (m) } \c__cooking_units_postfix_unitname_tl { one }
+\__cooking_units_newtranslation_to:nnVn { English } { one (f) } \c__cooking_units_postfix_unitname_tl { one }
+\__cooking_units_newtranslation_to:nnVn { English } { one (n) } \c__cooking_units_postfix_unitname_tl { one }
+\__cooking_units_newtranslation_to:nnVn { German } { one (m) } \c__cooking_units_postfix_unitname_tl { ein }
+\__cooking_units_newtranslation_to:nnVn { German } { one (f) } \c__cooking_units_postfix_unitname_tl { eine }
+\__cooking_units_newtranslation_to:nnVn { German } { one (n) } \c__cooking_units_postfix_unitname_tl { ein }
+\cs_new:Npn \__cooking_units_parse_input:N #1
+ {
+ \bool_if:NTF \l__cooking_units_range_in_input_bool
{ \__cooking_units_parse_range_in_input:ww #1 \q_stop }
{
\tl_if_in:nnTF {#1} { / }
{
+ \bool_lazy_or:nnTF
+ { \l__cooking_units_calc_persons_bool }{ \l__cooking_units_eval_fractions_bool }
+ { \bool_set_false:N \l__cooking_units_fraction_in_input_bool }
+ { \bool_set_true:N \l__cooking_units_fraction_in_input_bool }
\tl_if_in:nnTF {#1} { _ }
{ \__cooking_units_parse_mixed_fraction_in_input:www #1 \q_stop }
{ \__cooking_units_parse_fraction_in_input:ww #1 \q_stop }
@@ -671,83 +867,93 @@
{ \__cooking_units_parse_number_in_input:n {#1} }
}
}
-\cs_generate_variant:Nn \__cooking_units_cunum_parse_input:N { V }
+\cs_generate_variant:Nn \__cooking_units_parse_input:N { V }
\cs_new:Npn \__cooking_units_parse_number_in_input:n #1
{
- \__cooking_units_parse_input_and_safe_in:nN {#1} \l__cooking_units_tmpa_tl
- \__cooking_units_calculate_and_print_input:N \l__cooking_units_tmpa_tl
+ \__cooking_units_parse_input_and_safe_in:nN {#1} \l__cooking_units_number_tmpa_tl
+ \__cooking_units_process_and_print_number_in_input:N \l__cooking_units_number_tmpa_tl
+ }
+\cs_new:Npn \__cooking_units_process_and_print_number_in_input:N #1
+ {
+ \__cooking_units_pre_process_input:NN #1 \q_no_value
+ \__cooking_units_calculate_and_store_in:N #1
+ \__cooking_units_post_process_input:NN #1 \q_no_value
+ \__cooking_units_print_input:N #1
}
\cs_new:Npn \__cooking_units_parse_range_in_input:ww #1 \q__cooking_units_range #2 \q_stop
{
- \__cooking_units_parse_input_and_safe_in:nN {#1} \l__cooking_units_tmpa_tl
- \__cooking_units_parse_input_and_safe_in:nN {#2} \l__cooking_units_tmpb_tl
- \__cooking_units_calculate_and_print_input:N \l__cooking_units_tmpa_tl
+ \__cooking_units_parse_input_and_safe_in:nN {#1} \l__cooking_units_number_tmpa_tl
+ \__cooking_units_parse_input_and_safe_in:nN {#2} \l__cooking_units_number_tmpb_tl
+ \__cooking_units_pre_process_input:NN \l__cooking_units_number_tmpa_tl \l__cooking_units_number_tmpb_tl
+ \__cooking_units_calculate_and_store_in:N \l__cooking_units_number_tmpa_tl
+ \__cooking_units_calculate_and_store_in:N \l__cooking_units_number_tmpb_tl
+ \__cooking_units_post_process_input:NN \l__cooking_units_number_tmpa_tl \l__cooking_units_number_tmpb_tl
+ \__cooking_units_print_input:N \l__cooking_units_number_tmpa_tl
\bool_if:NTF \l__cooking_units_using_cutext_bool
{ \tl_use:N \l__cooking_units_cutext_range_sign_tl }
{ \tl_use:N \l__cooking_units_cunum_range_sign_tl }
- \__cooking_units_calculate_and_print_input:N \l__cooking_units_tmpb_tl
+ \__cooking_units_print_input:N \l__cooking_units_number_tmpb_tl
}
\cs_new:Npn \__cooking_units_parse_fraction_in_input:ww #1/#2 \q_stop
{
- \__cooking_units_parse_input_and_safe_in:nN {#1} \l__cooking_units_tmpa_tl
- \__cooking_units_parse_input_and_safe_in:nN {#2} \l__cooking_units_tmpb_tl
- \bool_if:nTF
- {
- \l__cooking_units_calc_persons_tmp_bool ||
- \l__cooking_units_eval_fractions_bool
- }
+ \__cooking_units_parse_input_and_safe_in:nN {#1} \l__cooking_units_number_tmpa_tl
+ \__cooking_units_parse_input_and_safe_in:nN {#2} \l__cooking_units_number_tmpb_tl
+ \bool_lazy_or:nnTF
+ { \l__cooking_units_fraction_in_input_bool }
+ { \l__cooking_units_special_sign_bool }
{
- \__cooking_units_calculate_and_print_input:n
- { \l__cooking_units_tmpa_tl / \l__cooking_units_tmpb_tl }
- }{
- \__cooking_units_tl_if_in_remove_and_set_bool:NnN \l__cooking_units_tmpa_tl { - } \l_tmpb_bool
- \__cooking_units_tl_if_in_remove_and_reverse_bool:NnN \l__cooking_units_tmpb_tl { - } \l_tmpb_bool
- \__cooking_units_formatiere_fractions:nNN
+ \__cooking_units_tl_if_in_remove_and_set_bool:NnN \l__cooking_units_number_tmpa_tl { - } \l__cooking_units_minus_bool
+ \__cooking_units_tl_if_in_remove_and_reverse_bool:NnN \l__cooking_units_number_tmpb_tl { - } \l__cooking_units_minus_bool
+ \__cooking_units_formatiere_fractions:nnn
{ }
- { \l__cooking_units_tmpa_tl }
- { \l__cooking_units_tmpb_tl }
+ { \l__cooking_units_number_tmpa_tl }
+ { \l__cooking_units_number_tmpb_tl }
+ }{
+ \__cooking_units_tl_set_fp_and_eval:Nn \l__cooking_units_number_tmpa_tl
+ { \l__cooking_units_number_tmpa_tl / \l__cooking_units_number_tmpb_tl }
+ \__cooking_units_process_and_print_number_in_input:N \l__cooking_units_number_tmpa_tl
}
}
\cs_new:Npn \__cooking_units_parse_mixed_fraction_in_input:www #1_#2/#3 \q_stop
{
\__cooking_units_parse_input_and_safe_in:nN {#1} \l__cooking_units_mixed_fraction_tl
- \__cooking_units_parse_input_and_safe_in:nN {#2} \l__cooking_units_tmpa_tl
- \__cooking_units_parse_input_and_safe_in:nN {#3} \l__cooking_units_tmpb_tl
- \__cooking_units_tl_if_in_remove_and_set_bool:NnN \l__cooking_units_mixed_fraction_tl { - } \l_tmpb_bool
- \__cooking_units_tl_if_in_remove_and_reverse_bool:NnN \l__cooking_units_tmpa_tl { - } \l_tmpb_bool
- \__cooking_units_tl_if_in_remove_and_reverse_bool:NnN \l__cooking_units_tmpb_tl { - } \l_tmpb_bool
- \bool_if:nTF
- {
- \l__cooking_units_calc_persons_tmp_bool ||
- \l__cooking_units_eval_fractions_bool
+ \__cooking_units_parse_input_and_safe_in:nN {#2} \l__cooking_units_number_tmpa_tl
+ \__cooking_units_parse_input_and_safe_in:nN {#3} \l__cooking_units_number_tmpb_tl
+ \__cooking_units_tl_if_in_remove_and_set_bool:NnN \l__cooking_units_mixed_fraction_tl { - } \l__cooking_units_minus_bool
+ \__cooking_units_tl_if_in_remove_and_reverse_bool:NnN \l__cooking_units_number_tmpa_tl { - } \l__cooking_units_minus_bool
+ \__cooking_units_tl_if_in_remove_and_reverse_bool:NnN \l__cooking_units_number_tmpb_tl { - } \l__cooking_units_minus_bool
+ \bool_lazy_or:nnTF
+ { \l__cooking_units_fraction_in_input_bool }
+ { \l__cooking_units_special_sign_bool }
+ {
+ \__cooking_units_formatiere_fractions:nnn
+ { \l__cooking_units_mixed_fraction_tl }
+ { \l__cooking_units_number_tmpa_tl }
+ { \l__cooking_units_number_tmpb_tl }
}{
- \__cooking_units_calculate_and_print_input:n
+ \__cooking_units_tl_set_fp_and_eval:Nn \l__cooking_units_number_tmpa_tl
{
- \bool_if:NTF \l_tmpb_bool
+ \bool_if:NTF \l__cooking_units_minus_bool
{ - \l__cooking_units_mixed_fraction_tl - }
{ \l__cooking_units_mixed_fraction_tl + }
- \l__cooking_units_tmpa_tl / \l__cooking_units_tmpb_tl
+ \l__cooking_units_number_tmpa_tl / \l__cooking_units_number_tmpb_tl
}
- }{
- \__cooking_units_formatiere_fractions:nNN
- { \l__cooking_units_mixed_fraction_tl }
- { \l__cooking_units_tmpa_tl }
- { \l__cooking_units_tmpb_tl }
+ \__cooking_units_process_and_print_number_in_input:N \l__cooking_units_number_tmpa_tl
}
}
\cs_new:Npn \__cooking_units_parse_input_and_safe_in:nN #1 #2
{
- \tl_clear:N \l_tmpa_tl
+ \tl_clear:N \l__cooking_units_tmpa_tl
\bool_set_false:N \l__cooking_units_decimal_in_input_bool
\__cooking_units_parse_vorzeichen_and_rest:Nw #1 \q_stop
\bool_if:NTF \l__cooking_units_error_bool
{ \tl_set:Nn #2 {#1} }
- { \tl_set_eq:NN #2 \l_tmpa_tl }
+ { \tl_set_eq:NN #2 \l__cooking_units_tmpa_tl }
}
\cs_new:Npn \__cooking_units_parse_vorzeichen_and_rest:Nw #1#2 \q_stop
{
- \tl_if_in:NnTF \l__cooking_units_value_signs_tl {#1}
- { \tl_put_right:Nn \l_tmpa_tl {#1} }
+ \tl_if_in:NnTF \l__cooking_units_input_value_signs_tl {#1}
+ { \tl_put_right:Nn \l__cooking_units_tmpa_tl {#1} }
{
\tl_map_function:nN {#1} \__cooking_units_parse_input_for_safety_aux:N
}
@@ -757,24 +963,24 @@
\cs_new:Npn \__cooking_units_parse_input_for_safety_aux:N #1
{
\tl_if_in:NnTF \l__cooking_units_input_digits_tl {#1}
- { \tl_put_right:Nn \l_tmpa_tl {#1} }
+ { \tl_put_right:Nn \l__cooking_units_tmpa_tl {#1} }
{
- \tl_if_in:NnTF \l__cooking_units_decimal_mark_tl {#1}
+ \tl_if_in:NnTF \l__cooking_units_input_decimal_mark_tl {#1}
{
\bool_if:NT \l__cooking_units_decimal_in_input_bool
{
\msg_error:nn { cooking-units }
- { Second - decimal -sign - not - allowed }
+ { Second-decimal-sign-not-allowed }
}
\bool_set_true:N \l__cooking_units_decimal_in_input_bool
- \tl_put_right:Nn \l_tmpa_tl { . }
+ \tl_put_right:Nn \l__cooking_units_tmpa_tl { . }
}{
- \tl_if_in:NnTF \l__cooking_units_allowed_special_signs_tl {#1}
+ \tl_if_in:NnTF \l__cooking_units_input_allowed_special_signs_tl {#1}
{
\bool_set_true:N \l__cooking_units_special_sign_bool
- \tl_put_right:Nn \l_tmpa_tl {#1}
+ \tl_put_right:Nn \l__cooking_units_tmpa_tl {#1}
}{
- \bool_if:NTF \l__cooking_units_parse_range_bool
+ \bool_if:NTF \l__cooking_units_range_in_input_bool
{
\tl_if_in:nnTF { / _ } {#1}
{ \msg_error:nnn { cooking-units } { fraction-not-allowed-with-range } {#1} }
@@ -790,39 +996,36 @@
}
}
}
-\cs_new:Npn \__cooking_units_calculate_and_print_input:n #1
+\cs_new:Npn \__cooking_units_calculate_and_store_in:N #1
{
- \bool_if:NTF \l__cooking_units_error_bool
- {#1}
+ \bool_if:NF \l__cooking_units_error_bool
{
\bool_if:NTF \l__cooking_units_special_sign_bool
{
- \tl_set:Nf \l_tmpa_tl {#1}
- \msg_warning:nnx { cooking-units } { amount-not-known } \l_tmpa_tl
- }
- {
- \bool_if:nTF
- { \l__cooking_units_using_cutext_bool && ! \l__cooking_units_cutext_change_unit_bool }
- { \tl_set:Nf \l_tmpa_tl {#1} }
- { \__cooking_units_calculate_input_and_store_in:nN {#1} \l_tmpa_tl }
- \bool_if:NT \l__cooking_units_calc_persons_tmp_bool
- { \__cooking_units_calc_for_number_of_persons_and_store_in:NN \l_tmpa_tl \l_tmpa_tl }
- \__cooking_units_round_calculated_input:NV \l_tmpa_tl \l_tmpa_tl
- \__cooking_units_check_temperature_limit:N \l_tmpa_tl
+ \tl_set_eq:NN \l__cooking_units_tmpa_tl #1
+ \msg_warning:nnx { cooking-units } { amount-not-known } \l__cooking_units_tmpa_tl
+ }{
+ \bool_lazy_and:nnTF
+ { \l__cooking_units_using_cutext_bool } { ! \l__cooking_units_cutext_change_unit_bool }
+ { \tl_set_eq:NN \l__cooking_units_tmpa_tl #1 }
+ { \__cooking_units_calculate_input_and_store_in:nN {#1} \l__cooking_units_tmpa_tl }
+ \bool_if:NT \l__cooking_units_calc_persons_bool
+ { \__cooking_units_calc_for_number_of_persons_and_store_in:NN \l__cooking_units_tmpa_tl \l__cooking_units_tmpa_tl }
+ \__cooking_units_round_calculated_input:NV \l__cooking_units_tmpa_tl \l__cooking_units_tmpa_tl
+ \__cooking_units_check_temperature_limit:N \l__cooking_units_tmpa_tl
}
- \__cooking_units_print_output:N \l_tmpa_tl
+ \tl_set_eq:NN #1 \l__cooking_units_tmpa_tl
}
}
-\cs_generate_variant:Nn \__cooking_units_calculate_and_print_input:n { N }
\cs_new:Npn \__cooking_units_calculate_input_and_store_in:nN #1#2
{
- \fp_set:Nn \l_tmpa_fp {#1}
- \tl_if_in:cnTF { l__cooking_units_tmpa_ \l__cooking_units_tmp_unit_tl _ tl } { \l_tmpa_fp }
+ \fp_set:Nn \l__cooking_units_tmpa_fp {#1}
+ \tl_if_in:cnTF { l__cooking_units_tmpa_ \l__cooking_units_given_unit_tl _ tl } { \l__cooking_units_tmpa_fp }
{
- \__cooking_units_tl_set_fp_and_eval:Nc #2 { l__cooking_units_tmpa_ \l__cooking_units_tmp_unit_tl _ tl }
+ \__cooking_units_tl_set_fp_and_eval:Nc #2 { l__cooking_units_tmpa_ \l__cooking_units_given_unit_tl _ tl }
}{
\__cooking_units_tl_set_fp_and_eval:Nn #2
- { \l_tmpa_fp * \tl_use:c { l__cooking_units_tmpa_ \l__cooking_units_tmp_unit_tl _ tl } }
+ { \l__cooking_units_tmpa_fp * \tl_use:c { l__cooking_units_tmpa_ \l__cooking_units_given_unit_tl _ tl } }
}
}
\cs_new:Npn \__cooking_units_calc_for_number_of_persons_and_store_in:NN #1#2
@@ -830,18 +1033,19 @@
\int_compare:nNnF
{ \l__cooking_units_calc_for_number_of_persons_int }
=
- { \l__cooking_units_persons_tmp_int }
+ { \l__cooking_units_number_of_persons_tmpa_int }
{
\__cooking_units_tl_set_fp_and_eval:Nn #1
{
\l__cooking_units_calc_for_number_of_persons_int /
- \l__cooking_units_persons_tmp_int *
+ \l__cooking_units_number_of_persons_tmpa_int *
#2
}
}
}
-\cs_new:Npn \__cooking_units_check_number_after_dot:n #1
+\cs_new:Npn \__cooking_units_check_number_for_rounding:n #1
{
+ \bool_set_false:N \l__cooking_units_round_decimal_part_bool
\__cooking_units_check_number_after_dot_aux:w #1 . \q_recursion_tail .
\q_recursion_stop
}
@@ -851,43 +1055,63 @@
\bool_if:NTF \l__cooking_units_round_to_int_bool
{ \int_zero:N \l_tmpa_int }
{ \int_set_eq:NN \l_tmpa_int \l__cooking_units_significant_figures_plus_one_int }
- \int_compare:nNnTF
+ \int_compare:nNnF
{ \tl_count:n {#2} } < { \l_tmpa_int }
- { \bool_set_false:N \l_tmpa_bool }
- { \bool_set_true:N \l_tmpa_bool }
+ { \bool_set_true:N \l__cooking_units_round_decimal_part_bool }
\use_none_delimit_by_q_recursion_stop:w
}
\cs_new:Npn \__cooking_units_round_calculated_input:NN #1#2
{
- \__cooking_units_check_number_after_dot:n {#2}
- \tl_set:Nf #1
+ \__cooking_units_check_number_for_rounding:n {#2}
+ \tl_set:Nx #1
{
- \bool_if:NTF \l_tmpa_bool
+ \bool_if:NTF \l__cooking_units_round_decimal_part_bool
{ \fp_eval:n { round ( \__cooking_units_rounding_function:n {#2} ) } }
{#2}
}
}
\cs_generate_variant:Nn \__cooking_units_round_calculated_input:NN { NV }
-\cs_new_protected:Npn \__cooking_units_print_output:N #1
+\cs_new_protected:Npn \__cooking_units_print_input:N #1 { }
+\cs_new_protected:Npn \__cooking_units_print_correct_unit: { }
+\cs_new_protected:Npn \__cooking_units_do_not_process_input:NN #1#2 { }
+\cs_new_eq:NN \__cooking_units_pre_process_input:NN \__cooking_units_do_not_process_input:NN
+\cs_new_eq:NN \__cooking_units_post_process_input:NN \__cooking_units_do_not_process_input:NN
+\cs_new_protected:Npn \__cooking_units_set_process_and_print_for_cunum:
{
- \bool_if:NTF \l__cooking_units_using_cutext_bool
- {
- \tl_set_eq:NN \l__cooking_units_cutext_tmp_tl #1
- \__cooking_units_cutext_print_output:NV #1 \l__cooking_units_option_unit_tl
- }
- { \__cooking_units_print_nummerical_output:N #1 }
+ \cs_set_eq:NN \__cooking_units_print_input:N \__cooking_units_print_numerical_input:N
+ \cs_set_eq:NN \__cooking_units_print_correct_unit: \__cooking_units_cunum_print_correct_unit:
+ \cs_set_eq:NN \__cooking_units_pre_process_input:NN \__cooking_units_do_not_process_input:NN
+ \cs_set_eq:NN \__cooking_units_post_process_input:NN \__cooking_units_do_not_process_input:NN
}
-\cs_new_protected:Npn \__cooking_units_print_nummerical_output:N #1
+\cs_new_protected:Npn \__cooking_units_set_process_and_print_for_cutext:
{
- \translatelet \l__cooking_units_translation_tmpa_tl { decimal-mark ( cu-unitname ) }
- \tl_replace_once:NnV #1 { . } \l__cooking_units_translation_tmpa_tl
- \tl_replace_once:NnV #1 { - } \c__cooking_units_minus_tl
+ \cs_set_eq:NN \__cooking_units_print_input:N \__cooking_units_cutext_print_input:N
+ \cs_set_eq:NN \__cooking_units_print_correct_unit: \__cooking_units_cutext_print_correct_unitname:
+ \cs_set_eq:NN \__cooking_units_pre_process_input:NN \__cooking_units_cutext_pre_process_input:NN
+ \cs_set_eq:NN \__cooking_units_post_process_input:NN \__cooking_units_cutext_post_process_input:NN
+ }
+\cs_new_protected:Npn \__cooking_units_set_process_and_print_for_cuam:
+ {
+ \cs_set_eq:NN \__cooking_units_print_input:N \__cooking_units_cuam_print_numerical_input:N
+ \cs_set_eq:NN \__cooking_units_print_correct_unit: \__cooking_units_cuam_print_correct_unitphrase:
+ \cs_set_eq:NN \__cooking_units_pre_process_input:NN \__cooking_units_do_not_process_input:NN
+ \cs_set_eq:NN \__cooking_units_post_process_input:NN \__cooking_units_cuam_post_process_input:NN
+ }
+\cs_new_protected:Npn \__cooking_units_print_numerical_input:N #1
+ {
+ \tl_if_in:NnT #1 { . }
+ {
+ \__cooking_units_translate_let:Nxx \l__cooking_units_translation_tmpa_tl
+ { decimal-mark } \c__cooking_units_postfix_unitname_tl
+ \tl_replace_once:Nnn #1 { . } { \l__cooking_units_translation_tmpa_tl }
+ }
+ \tl_if_in:NnT #1 { - }
+ { \tl_replace_once:NnV #1 { - } \c__cooking_units_minus_tl }
#1
}
-\cs_new:Npn \__cooking_units_formatiere_fractions:nNN #1#2#3
+\cs_new:Npn \__cooking_units_formatiere_fractions:nnn #1#2#3
{
- \bool_set_true:N \l__cooking_units_fraction_in_input_bool
- \bool_if:NT \l_tmpb_bool { \c__cooking_units_minus_tl }
+ \bool_if:NT \l__cooking_units_minus_bool { \c__cooking_units_minus_tl }
\tl_if_empty:nF {#1}
{
#1
@@ -899,13 +1123,13 @@
{
\bool_if:NT \l__cooking_units_check_temperature_bool
{
- \clist_if_in:NVT \l__cooking_units_temperatures_to_check_clist \l__cooking_units_option_unit_tl
+ \seq_if_in:NVT \l__cooking_units_temperatures_to_check_seq \l__cooking_units_option_unit_tl
{
\fp_compare:cNnT
{ c__cooking_units_ \l__cooking_units_option_unit_tl _min_fp } > {#1}
{
\msg_error:nnxx { cooking-units }
- { Temperature-to-low }
+ { Temperature-too-low }
{ #1 \space \l__cooking_units_option_unit_tl }
{
\fp_use:c { c__cooking_units_ \l__cooking_units_option_unit_tl _min_fp }
@@ -914,43 +1138,77 @@
}
}
}
- }
+ }
+\cs_new_nopar:Npn \__cooking_units_grab_arrows_for_safety_do_afterwards:nN #1#2
+ {
+ \str_if_eq:nnTF {#2} { > }
+ {
+ \tl_put_right:Nx \l__cooking_units_tmpa_tl { \tl_to_str:N > }
+ \exp_last_unbraced:NV #1 \l__cooking_units_tmpa_tl
+ }{
+ \tl_put_right:Nn \l__cooking_units_tmpa_tl {#2}
+ \__cooking_units_grab_arrows_for_safety_do_afterwards:nN {#1}
+ }
+ }
+\cs_new_nopar:Npn \__cooking_units_if_arrow_grab_until_close_do:nnTF #1#2#3#4
+ {
+ \str_if_eq:nnTF {#1} { < }
+ {
+ \tl_if_in:NoT \l__cooking_units_input_allowed_special_signs_tl { < }
+ { \msg_error:nn {cooking-units} { <-not-allowed-as-special-sign } }
+ \tl_clear:N \l__cooking_units_tmpa_tl
+ \tl_put_right:Nx \l__cooking_units_tmpa_tl { \tl_to_str:N < }
+ \__cooking_units_grab_arrows_for_safety_do_afterwards:nN
+ {#3} #2
+ }
+ {#4}
+ }
\NewDocumentCommand \cunum { d<> O{} m O{} m }
{
- \group_begin:
+ \__cooking_units_if_arrow_grab_until_close_do:nnTF {#3} {#5}
+ { \cunum }
+ {
+ \group_begin:
+ \__cooking_units_cunum:nnnnn {#1} {#2} {#3} {#4} {#5}
+ \group_end:
+ }
+ }
+\cs_new:Npn \__cooking_units_cunum:nnnnn #1#2#3#4#5
+ {
\__cooking_units_cunum_initialise:nnnnn {#1} {#2} {#3} {#4} {#5}
- \bool_if:NTF \l__cooking_units_parse_input_bool
- { \__cooking_units_parse_and_evaluate_input:n {#3} }
- { \__cooking_units_cunum_do_not_parse:nnn {#3} {#4} {#5} }
- \__cooking_units_cunum_print_correct_unit:nVV {#4} \l__cooking_units_option_unit_tl \l__cooking_units_tmp_unit_tl
- \group_end:
+ \__cooking_units_cunum_parse_numerical_input:n {#3}
+ \__cooking_units_print_correct_unit:
}
\cs_new_protected:Npn \__cooking_units_cunum_initialise:nnnnn #1#2#3#4#5
{
+ \__cooking_units_set_process_and_print_for_cunum:
+ \tl_set:Nn \l__cooking_units_phantom_tl {#4}
\__cooking_units_initialise_default:nnn {#1} {#2} {#5}
\__cooking_units_initialise_unit_change:nnn {#1} {#2} {#5}
- \__cooking_units_initialise_after_unit_change:nnn {#1} {#2} {#5}
+ \__cooking_units_initialise_after_unit_change:nn {#1} {#2}
}
\cs_new_protected:Npn \__cooking_units_initialise_default:nnn #1#2#3
{
- \tl_set:Nn \l__cooking_units_tmp_unit_tl {#3}
- \__cooking_units_error_if_unit_not_defined:V \l__cooking_units_tmp_unit_tl
+ \tl_set:Nn \l__cooking_units_given_unit_tl {#3}
+ \__cooking_units_error_if_unit_not_defined:V \l__cooking_units_given_unit_tl
\bool_set_false:N \l__cooking_units_special_sign_bool
\bool_set_false:N \l__cooking_units_error_bool
- \bool_set_false:N \l__cooking_units_parse_range_bool
+ \bool_set_false:N \l__cooking_units_range_in_input_bool
+ \bool_set_false:N \l__cooking_units_fraction_in_input_bool
}
-\cs_generate_variant:Nn \__cooking_units_initialise_default:nnn { nnV}
\cs_new_protected:Npn \__cooking_units_initialise_unit_change:nnn #1#2#3
{
\tl_if_empty:nF {#2}
- { \keys_set_groups:nnn { cooking-units } { change-unit } {#2} }
- \bool_if:NT \l__cooking_units_convert_to_eV_bool
- { \__cooking_units_convert_to_eV: }
- \prop_get:NVN \l__cooking_units_change_unit_prop \l__cooking_units_tmp_unit_tl \l__cooking_units_option_unit_tl
- \quark_if_no_value:NT \l__cooking_units_option_unit_tl
- { \tl_set_eq:NN \l__cooking_units_option_unit_tl \l__cooking_units_tmp_unit_tl }
+ {
+ \keys_set_groups:nnn { cooking-units } { change-unit } {#2}
+ }
+ \bool_if:NT \l__cooking_units_convert_to_eV_bool { \__cooking_units_convert_to_eV: }
+ \prop_get:NVNF \l__cooking_units_change_unit_prop \l__cooking_units_given_unit_tl \l__cooking_units_option_unit_tl
+ {
+ \tl_set_eq:NN \l__cooking_units_option_unit_tl \l__cooking_units_given_unit_tl
+ }
}
-\cs_new_protected:Npn \__cooking_units_initialise_after_unit_change:nnn #1#2#3
+\cs_new_protected:Npn \__cooking_units_initialise_after_unit_change:nn #1#2
{
\IfNoValueF {#1}
{ \__cooking_units_reference_label_and_persons:n {#1} }
@@ -963,50 +1221,486 @@
}
\tl_if_empty:nF {#2}
{ \keys_set_filter:nnn { cooking-units } { change-unit } {#2} }
- \bool_set:Nn \l__cooking_units_calc_persons_tmp_bool
- { \l__cooking_units_calc_because_ref_was_given_bool && \l__cooking_units_calc_for_persons_bool }
+ \bool_lazy_and:nnTF
+ { \l__cooking_units_calc_because_ref_was_given_bool } { \l__cooking_units_calc_for_persons_bool }
+ { \bool_set_true:N \l__cooking_units_calc_persons_bool }
+ { \bool_set_false:N \l__cooking_units_calc_persons_bool }
}
-\cs_new:Npn \__cooking_units_cunum_do_not_parse:nnn #1#2#3
+\cs_new:Npn \__cooking_units_cunum_parse_numerical_input:n #1
{
- \tl_set_rescan:Nnn \l_tmpa_tl
+ \bool_if:NTF \l__cooking_units_parse_input_bool
+ { \__cooking_units_parse_and_evaluate_input:n {#1} }
+ { \__cooking_units_do_not_parse:n {#1} }
+ }
+\cs_new:Npn \__cooking_units_do_not_parse:n #1
+ {
+ \tl_set_rescan:Nnn \l__cooking_units_number_tmpa_tl
{
\char_set_catcode_letter:N \_ %
\char_set_catcode_ignore:N \ %
} {#1}
- \l_tmpa_tl
+ \l__cooking_units_number_tmpa_tl
}
\cs_new:Npn \__cooking_units_parse_and_evaluate_input:n #1
{
- \tl_set_rescan:Nnn \l_tmpa_tl
+ \tl_set_rescan:Nnn \l__cooking_units_tmpa_tl
{
\char_set_catcode_letter:N \_ %
\char_set_catcode_ignore:N \ %
\char_set_catcode_other:N ? %
} {#1}
- \tl_if_empty:VF \l_tmpa_tl
+ \tl_if_empty:NF \l__cooking_units_tmpa_tl
{
- \tl_if_in:NVT \l_tmpa_tl \l__cooking_units_input_range_sign_tl
+ \tl_if_in:NVT \l__cooking_units_tmpa_tl \l__cooking_units_input_range_sign_tl
{
- \tl_replace_once:NVn \l_tmpa_tl \l__cooking_units_input_range_sign_tl { \q__cooking_units_range }
- \bool_set_true:N \l__cooking_units_parse_range_bool
+ \tl_replace_once:NVn \l__cooking_units_tmpa_tl \l__cooking_units_input_range_sign_tl { \q__cooking_units_range }
+ \bool_set_true:N \l__cooking_units_range_in_input_bool
}
- \__cooking_units_cunum_parse_input:V \l_tmpa_tl
+ \__cooking_units_parse_input:V \l__cooking_units_tmpa_tl
}
}
-\cs_new:Npn \__cooking_units_cunum_print_correct_unit:nnn #1#2#3
+\cs_new:Npn \__cooking_units_cunum_print_correct_unit:
{
- \tl_if_empty:nF {#1} { \phantom {#1} }
+ \tl_if_empty:NF \l__cooking_units_phantom_tl { \phantom { \l__cooking_units_phantom_tl } }
\tl_use:N \l__cooking_units_value_unit_space_tl
- \bool_if:nTF
+ \bool_lazy_any:nTF
+ {
+ { \l__cooking_units_fraction_in_input_bool }
+ { \l__cooking_units_special_sign_bool }
+ { ! \l__cooking_units_parse_input_bool }
+ }
+ { \__cooking_units_translate:xx \l__cooking_units_given_unit_tl \c__cooking_units_postfix_unit_tl }
+ { \__cooking_units_translate:xx \l__cooking_units_option_unit_tl \c__cooking_units_postfix_unit_tl }
+ }
+\NewDocumentCommand \cutext { d<> O{} m m }
+ {
+ \__cooking_units_if_arrow_grab_until_close_do:nnTF {#3} {#4}
+ { \cutext }
+ {
+ \group_begin:
+ \__cooking_units_cutext_initialise:nnn {#1} {#2} {#4}
+ \bool_set_false:N \l__cooking_units_cutext_uppercase_word_bool
+ \__cooking_units_cutext_do:nnnn {#1} {#2} {#3} {#4}
+ \group_end:
+ }
+ }
+\NewDocumentCommand \Cutext { d<> O{} m m }
+ {
+ \__cooking_units_if_arrow_grab_until_close_do:nnTF {#3} {#4}
+ { \Cutext }
{
- ! \l__cooking_units_parse_input_bool ||
- \l__cooking_units_fraction_in_input_bool ||
- \l__cooking_units_special_sign_bool
+ \group_begin:
+ \__cooking_units_cutext_initialise:nnn {#1} {#2} {#4}
+ \bool_set_true:N \l__cooking_units_cutext_uppercase_word_bool
+ \__cooking_units_cutext_do:nnnn {#1} {#2} {#3} {#4}
+ \group_end:
}
- { \translate { #3 ( cu-unit ) } }
- { \translate { #2 ( cu-unit ) } }
}
-\cs_generate_variant:Nn \__cooking_units_cunum_print_correct_unit:nnn { nVV }
+\cs_new_protected:Npn \__cooking_units_cutext_initialise:nnn #1#2#3
+ {
+ \bool_set_true:N \l__cooking_units_using_cutext_bool
+ \__cooking_units_set_process_and_print_for_cutext:
+ \__cooking_units_initialise_default:nnn {#1} {#2} {#3}
+ \bool_if:NTF \l__cooking_units_cutext_change_unit_bool
+ { \__cooking_units_initialise_unit_change:nnn {#1} {#2} {#3} }
+ { \tl_set_eq:NN \l__cooking_units_option_unit_tl \l__cooking_units_given_unit_tl }
+ \__cooking_units_initialise_after_unit_change:nn {#1} {#2}
+ }
+\cs_new:Npn \__cooking_units_cutext_do:nnnn #1#2#3#4
+ {
+ \bool_if:NTF \l__cooking_units_cutext_to_cunum_bool
+ { \cunum <#1> [#2] {#3} {#4} }
+ {
+ \__cooking_units_cutext:nnnn {#1} {#2} {#3} {#4}
+ }
+ }
+\cs_new:Npn \__cooking_units_cutext:nnnn #1#2#3#4
+ {
+ \bool_if:NTF \l__cooking_units_parse_input_bool
+ {
+ \bool_if:NTF \l__cooking_units_cutext_old_bool
+ {
+ \__cooking_units_old_cutext_default:nnn {#2} {#3} {#4}
+ \tl_set_eq:NN \l__cooking_units_option_unit_tl \l__cooking_units_given_unit_tl
+ \__cooking_units_cutext_print_correct_unitname:
+ }{
+ \__cooking_units_parse_and_evaluate_input:n {#3}
+ \__cooking_units_print_correct_unit:
+ }
+ }{
+ \__cooking_units_do_not_parse:n {#3}
+ \tl_set_eq:NN \l__cooking_units_option_unit_tl \l__cooking_units_given_unit_tl
+ \__cooking_units_cutext_print_correct_unitname:
+ }
+ }
+\prg_new_conditional:Npnn \__cooking_units_cutext_if_numeral_is_int_and_parse_and_smaller_then_print_numerals:N #1 { TF }
+ {
+ \bool_lazy_and:nnTF
+ { \g__cooking_units_opt_numeral_bool }
+ { \l__cooking_units_local_numeral_bool }
+ {
+ \__cooking_units_if_parse_and_integer:VTF #1
+ {
+ \int_compare:nNnTF {#1} < { \l__cooking_units_print_numerals_below_int }
+ { \prg_return_true: }
+ { \prg_return_false: }
+ }{ \prg_return_false: }
+ }{ \prg_return_false: }
+ }
+\cs_new_protected:Npn \__cooking_units_cutext_print_input:Nn #1#2
+ {
+ \__cooking_units_cutext_if_numeral_is_int_and_parse_and_smaller_then_print_numerals:NTF #1
+ {
+ \__cooking_units_int_if_equal_one:nTF {#1}
+ {
+ \__cooking_units_translate_one_to_and_check_existance:Nx \l__cooking_units_translation_tmpa_tl {#2}
+ \bool_if:NTF \l__cooking_units_cutext_uppercase_word_bool
+ {
+ \exp_args:Nx \tl_upper_case:n { \tl_head:V \l__cooking_units_translation_tmpa_tl }
+ \tl_tail:V \l__cooking_units_translation_tmpa_tl
+ }
+ { \l__cooking_units_translation_tmpa_tl }
+ }{
+ \bool_if:NTF \l__cooking_units_cutext_uppercase_word_bool
+ { \__cooking_units_print_Numeral:n {#1} }
+ { \__cooking_units_print_numeral:n {#1} }
+ }
+ }
+ { \__cooking_units_print_numerical_input:N #1 }
+ }
+\cs_generate_variant:Nn \__cooking_units_cutext_print_input:Nn { NV }
+\cs_new_protected:Npn \__cooking_units_cutext_print_input:N #1
+ { \__cooking_units_cutext_print_input:NV #1 \l__cooking_units_option_unit_tl }
+\cs_new:Npn \__cooking_units_cutext_print_correct_unitname:
+ {
+ \l__cooking_units_cutext_space_tl
+ \bool_lazy_any:nTF
+ {
+ { \l__cooking_units_fraction_in_input_bool }
+ { \l__cooking_units_special_sign_bool }
+ { ! \l__cooking_units_parse_input_bool }
+ }
+ { \__cooking_units_translate:xx \l__cooking_units_given_unit_tl \c__cooking_units_postfix_unitname_pl_tl }
+ {
+ \__cooking_units_fp_if_equal_one:nTF { \l__cooking_units_cutext_last_value_tl }
+ { \__cooking_units_translate:xx \l__cooking_units_option_unit_tl \c__cooking_units_postfix_unitname_tl }
+ { \__cooking_units_translate:xx \l__cooking_units_option_unit_tl \c__cooking_units_postfix_unitname_pl_tl }
+ }
+ }
+\cs_new:Npn \__cooking_units_cutext_pre_process_input:NN #1#2
+ {
+ \__cooking_units_cutext_check_unitname_consequences:NN #1#2
+ }
+\cs_new:Npn \__cooking_units_cutext_post_process_input:NN #1#2
+ {
+ \bool_if:NTF \l__cooking_units_range_in_input_bool
+ {
+ \tl_set_eq:NN \l__cooking_units_cutext_last_value_tl #2
+ \bool_if:NT \g__cooking_units_opt_numeral_bool
+ {
+ \bool_lazy_and:nnF
+ { \fp_compare_p:nNn {#1} < { \l__cooking_units_print_numerals_below_int } }
+ { \fp_compare_p:nNn {#2} < { \l__cooking_units_print_numerals_below_int } }
+ { \bool_set_false:N \l__cooking_units_local_numeral_bool }
+ }
+ }
+ { \tl_set_eq:NN \l__cooking_units_cutext_last_value_tl #1 }
+ }
+\cs_new:Npn \__cooking_units_cutext_check_unitname_consequences:NN #1#2
+ {
+ \bool_lazy_any:nTF
+ {
+ { \l__cooking_units_fraction_in_input_bool }
+ { \l__cooking_units_special_sign_bool }
+ { ! \l__cooking_units_parse_input_bool }
+ }
+ { \tl_set_eq:NN \l__cooking_units_tmpb_tl \l__cooking_units_given_unit_tl }
+ { \tl_set_eq:NN \l__cooking_units_tmpb_tl \l__cooking_units_option_unit_tl }
+ \__cooking_units_unitname_get:NxF \l__cooking_units_tmpa_tl \l__cooking_units_tmpb_tl
+ {
+ \msg_warning:nnx
+ { cooking-units }
+ { cutext-no-translation-available }
+ \l__cooking_units_tmpb_tl
+ \bool_set_false:N \l__cooking_units_using_cutext_bool
+ \__cooking_units_set_process_and_print_for_cunum:
+ }
+ }
+\cs_new:Npn \__cooking_units_old_cutext_default:nnn #1#2#3
+ {
+ \bool_if:NTF \l__cooking_units_parse_input_bool
+ {
+ \tl_set:Nn \l__cooking_units_cutext_last_value_tl {#2}
+ \tl_if_in:NVTF \l__cooking_units_cutext_last_value_tl \l__cooking_units_input_range_sign_tl
+ {
+ \tl_replace_once:NVn \l__cooking_units_cutext_last_value_tl
+ \l__cooking_units_input_range_sign_tl { \q__cooking_units_range }
+ \__cooking_units_old_cutext_parse_range:Vn \l__cooking_units_cutext_last_value_tl {#3}
+ }{
+ \__cooking_units_cutext_print_input:Nn \l__cooking_units_cutext_last_value_tl {#3}
+ }
+ }
+ {#2}
+ }
+\cs_new:Npn \__cooking_units_old_cutext_parse_range:Nn #1 #2
+ {
+ \__cooking_units_old_cutext_parse_range_aux:nww {#2} #1 \q_stop
+ }
+\cs_generate_variant:Nn \__cooking_units_old_cutext_parse_range:Nn { V }
+\cs_new:Npn \__cooking_units_old_cutext_parse_range_aux:nww #1 #2 \q__cooking_units_range #3 \q_stop
+ {
+ \tl_set:Nn \l__cooking_units_tmpa_tl {#2}
+ \tl_set:Nn \l__cooking_units_cutext_last_value_tl {#3}
+ \__cooking_units_cutext_print_input:Nn \l__cooking_units_tmpa_tl {#1}
+ \tl_use:N \l__cooking_units_cutext_range_sign_tl
+ \__cooking_units_cutext_print_input:Nn \l__cooking_units_cutext_last_value_tl {#1}
+ }
+\tl_const:Nn \c__cooking_units_cuam_marker_tl { __cooking_units_cunum }
+\tl_new:c { l__cooking_units_tmpa_ \c__cooking_units_cuam_marker_tl _ tl }
+\tl_set:cn { l__cooking_units_tmpa_ \c__cooking_units_cuam_marker_tl _ tl } { \c_one_fp }
+\clist_new:c { l__cooking_units_predefined_option_ \c__cooking_units_cuam_marker_tl _clist }
+\NewDocumentCommand \cuam { d<> O{} m }
+ {
+ \__cooking_units_if_arrow_grab_until_close_do:nnTF {#3} { }
+ { \cuam }
+ {
+ \group_begin:
+ \__cooking_units_cuam_initialise:nn {#1} {#2}
+ \__cooking_units_cuam:n {#3}
+ \group_end:
+ }
+ }
+\cs_new:Npn \__cooking_units_cuam:n #1
+ {
+ \bool_if:NTF \l__cooking_units_parse_input_bool
+ {
+ \bool_if:NTF \l__cooking_units_cuam_old_bool
+ { \__cooking_units_cuam_old:n {#1} }
+ {
+ \__cooking_units_parse_and_evaluate_input:n {#1}
+ \__cooking_units_print_correct_unit:
+ }
+ }
+ { \__cooking_units_do_not_parse:n {#1} }
+ }
+\cs_new_protected:Npn \__cooking_units_cuam_initialise:nn #1#2
+ {
+ \__cooking_units_set_process_and_print_for_cuam:
+ \tl_set_eq:NN \l__cooking_units_given_unit_tl \c__cooking_units_cuam_marker_tl
+ \tl_set_eq:NN \l__cooking_units_option_unit_tl \c__cooking_units_cuam_marker_tl
+ \__cooking_units_initialise_after_unit_change:nn {#1} {#2}
+ }
+\cs_new_protected:Npn \__cooking_units_cuam_post_process_input:NN #1#2
+ {
+ \__cooking_units_if_integer:VTF #1
+ { \bool_set_true:N \l__cooking_units_tmpa_bool }
+ { \bool_set_false:N \l__cooking_units_tmpa_bool }
+ \bool_lazy_and:nnT
+ { \l__cooking_units_range_in_input_bool } { \l__cooking_units_tmpa_bool }
+ {
+ \__cooking_units_if_integer:VTF #2
+ { \bool_set_true:N \l__cooking_units_tmpa_bool }
+ { \bool_set_false:N \l__cooking_units_tmpa_bool }
+ }
+ \bool_lazy_and:nnT
+ { \l__cooking_units_use_phrases_bool } { \l__cooking_units_tmpa_bool }
+ {
+ \__cooking_units_if_phrase_list_exists:NT \l__cooking_units_phrase_prop
+ {
+ \__cooking_units_translate_let:Nxx \l__cooking_units_phrase_numbers_clist
+ { phrase-list-list } \c__cooking_units_postfix_phrase_tl
+ \__cooking_units_cuam_process_input_aux:NNN #1 \l__cooking_units_tmpa_int \l__cooking_units_phrase_number_tl
+ \bool_if:NT \l__cooking_units_check_if_phrase_used_bool
+ {
+ \bool_if:NTF \l__cooking_units_range_in_input_bool
+ {
+ \__cooking_units_cuam_process_input_aux:NNN #2 \l__cooking_units_tmpb_int \l__cooking_units_tmpb_tl
+ \bool_lazy_and:nnTF
+ { \l__cooking_units_check_if_phrase_used_bool }
+ { \tl_if_eq_p:NN \l__cooking_units_phrase_number_tl \l__cooking_units_tmpb_tl }
+ { \bool_set_true:N \l__cooking_units_check_if_phrase_used_bool }
+ { \bool_set_false:N \l__cooking_units_check_if_phrase_used_bool }
+ \bool_if:NT \l__cooking_units_check_if_phrase_used_bool
+ {
+ \tl_set:NV #1 \l__cooking_units_tmpa_int
+ \tl_set:NV #2 \l__cooking_units_tmpb_int
+ \__cooking_units_cuam_get_phrase_name:NVN
+ \l__cooking_units_phrase_phrase_tl \l__cooking_units_phrase_number_tl \l__cooking_units_tmpb_int
+ }
+ }{
+ \tl_set:NV #1 \l__cooking_units_tmpa_int
+ \__cooking_units_cuam_get_phrase_name:NVN
+ \l__cooking_units_phrase_phrase_tl \l__cooking_units_phrase_number_tl \l__cooking_units_tmpa_int
+ }
+ }
+ }
+ }
+ \bool_lazy_and:nnT
+ { \g__cooking_units_opt_numeral_bool } { \l__cooking_units_local_numeral_bool }
+ {
+ \bool_set_eq:NN \l__cooking_units_local_numeral_bool \l__cooking_units_tmpa_bool
+ \bool_if:NT \l__cooking_units_local_numeral_bool
+ {
+ \bool_if:NTF \l__cooking_units_range_in_input_bool
+ {
+ \bool_lazy_and:nnF
+ { \int_compare_p:nNn {#1} < { \l__cooking_units_print_numerals_below_int } }
+ { \int_compare_p:nNn {#2} < { \l__cooking_units_print_numerals_below_int } }
+ { \bool_set_false:N \l__cooking_units_local_numeral_bool }
+ }{
+ \int_compare:nNnF {#1} < { \l__cooking_units_print_numerals_below_int }
+ { \bool_set_false:N \l__cooking_units_local_numeral_bool }
+ }
+ }
+ }
+ }
+\prg_new_conditional:Npnn \__cooking_units_cuam_check_if_larger:nn #1#2 { F }
+ {
+ \int_compare:nNnTF {#1} > {#2}
+ { \prg_return_true: }
+ { \prg_return_false: }
+ }
+\cs_new:Npn \__cooking_units_cuam_process_input_aux:NNN #1#2#3
+ {
+ \bool_set_false:N \l__cooking_units_check_if_phrase_used_bool
+ \clist_map_inline:Nn \l__cooking_units_phrase_numbers_clist
+ {
+ \__cooking_units_cuam_check_if_larger:nnF { \int_abs:n {##1} } {#1}
+ {
+ \int_compare:nNnTF {##1} < { \c_zero }
+ { \int_set_eq:NN \l_tmpa_int \c_one }
+ { \int_set:Nn \l_tmpa_int { \int_div_truncate:nn {#1} {##1} } }
+ \int_compare:nNnT { \int_abs:n {##1} * \l_tmpa_int } = {#1}
+ {
+ \int_set_eq:NN #2 \l_tmpa_int
+ \tl_set:Nn #3 {##1}
+ \bool_set_true:N \l__cooking_units_check_if_phrase_used_bool
+ \clist_map_break:
+ }
+ }
+ }
+ }
+\cs_new:Npn \__cooking_units_cuam_get_phrase_name:NnN #1#2#3
+ {
+ \__cooking_units_int_if_equal_one:nTF {#3}
+ { \prop_get:NnN \l__cooking_units_phrase_prop {#2} #1 }
+ { \prop_get:NnN \l__cooking_units_phrase_prop { #2-pl } #1 }
+ }
+\cs_generate_variant:Nn \__cooking_units_cuam_get_phrase_name:NnN { NVN }
+\cs_new_protected:Npn \__cooking_units_cuam_print_numerical_input:N #1
+ {
+ \bool_lazy_all:nTF
+ {
+ { \l__cooking_units_check_if_phrase_used_bool }
+ { \g__cooking_units_opt_numeral_bool }
+ { \l__cooking_units_local_numeral_bool }
+ }{
+ \__cooking_units_int_if_equal_one:nTF {#1}
+ {
+ \__cooking_units_translate_one_to_and_check_existance:Nx \l__cooking_units_translation_tmpa_tl
+ { \l__cooking_units_phrase_number_tl -phrase-gender }
+ \l__cooking_units_translation_tmpa_tl
+ }
+ { \exp_args:NV \__cooking_units_print_numeral:n #1 }
+ }{ \__cooking_units_print_numerical_input:N #1 }
+ }
+\cs_new:Npn \__cooking_units_cuam_print_correct_unitphrase:
+ {
+ \bool_if:NT \l__cooking_units_check_if_phrase_used_bool
+ {
+ \l__cooking_units_cuphrase_space_tl
+ \l__cooking_units_phrase_phrase_tl
+ }
+ }
+\cs_new:Npn \__cooking_units_cuam_old:n #1
+ {
+ \tl_set_rescan:Nnn \l__cooking_units_tmpa_tl
+ {
+ \char_set_catcode_letter:N \_ %
+ \char_set_catcode_ignore:N\ %
+ } {#1}
+ \__cooking_units_cuam_old_parse:V \l__cooking_units_tmpa_tl
+ }
+\cs_new_protected:Npn \__cooking_units_cuam_old_parse:n #1
+ {
+ \tl_if_in:nVTF {#1} \l__cooking_units_input_range_sign_tl
+ {
+ \tl_set:Nn \l__cooking_units_tmpa_tl {#1}
+ \tl_replace_once:NVn \l__cooking_units_tmpa_tl \l__cooking_units_input_range_sign_tl { \q__cooking_units_range }
+ \__cooking_units_cuam_old_parse_range:V \l__cooking_units_tmpa_tl
+ }{
+ \tl_if_in:nnTF {#1} { / }
+ {
+ \tl_if_in:nnTF {#1} { _ }
+ { \__cooking_units_cuam_old_parse_mixed_frac:www #1 \q_stop }
+ { \__cooking_units_cuam_old_parse_frac:ww #1 \q_stop }
+ }{
+ \tl_if_in:nnTF {#1} { _ }
+ { \msg_error:nnn { cooking-units } { missing-slash } {#1} }
+ { \__cooking_units_cuam_old_parse_scale:n {#1} }
+ }
+ }
+ }
+\cs_generate_variant:Nn \__cooking_units_cuam_old_parse:n { V }
+\cs_new:Npn \__cooking_units_cuam_old_parse_range:n #1
+ {
+ \__cooking_units_cuam_old_parse_range_aux:ww #1 \q_nil
+ }
+\cs_generate_variant:Nn \__cooking_units_cuam_old_parse_range:n { V }
+\cs_new:Npn \__cooking_units_cuam_old_parse_range_aux:ww #1 \q__cooking_units_range #2 \q_nil
+ {
+ #1 \l__cooking_units_cunum_range_sign_tl #2
+ }
+\cs_new:Npn \__cooking_units_cuam_old_parse_scale:n #1 {#1}
+\cs_new:Npn \__cooking_units_cuam_old_parse_frac:ww #1/#2 \q_stop
+ { \__cooking_units_frac:nn {#1} {#2} }
+\cs_new:Npn \__cooking_units_cuam_old_parse_mixed_frac:www #1_#2/#3 \q_stop
+ {
+ #1
+ \hbox_to_wd:nn { \l__cooking_units_mixed_frac_dim } { }
+ \__cooking_units_frac:nn {#2} {#3}
+ }
+\NewDocumentCommand \cufrac { O{} m }
+ {
+ \msg_error:nnnn { cooking-units } { obsolete-command } { \cufrac } { \cuam }
+ \group_begin:
+ \tl_if_empty:nF {#1}
+ { \keys_set:nn { cooking-units } {#1} }
+ \__cooking_units_cufrac:n {#2}
+ \group_end:
+ }
+\cs_new:Npn \__cooking_units_cufrac:n #1
+ {
+ \tl_set_rescan:Nnn \l__cooking_units_tmpa_tl
+ {
+ \char_set_catcode_letter:N \_ %
+ \char_set_catcode_ignore:N\ %
+ } {#1}
+ \__cooking_units_cufrac_parse:V \l__cooking_units_tmpa_tl
+ }
+\cs_new:Npn \__cooking_units_cufrac_parse:n #1
+ {
+ \tl_if_in:nnTF {#1} { / }
+ {
+ \tl_if_in:nnTF {#1} { _ }
+ { \__cooking_units_cufrac_parse_mixed_frac:www #1 \q_stop }
+ { \__cooking_units_cufrac_parse_frac:ww #1 \q_stop }
+ }{
+ \tl_if_in:nnTF {#1} { _ }
+ { \msg_error:nnn { cooking-units } { missing-slash } {#1} }
+ { \__cooking_units_cufrac_parse_scale:n {#1} }
+ }
+ }
+\cs_generate_variant:Nn \__cooking_units_cufrac_parse:n { V }
+\cs_new:Npn \__cooking_units_cufrac_parse_scale:n #1 {#1}
+\cs_new:Npn \__cooking_units_cufrac_parse_frac:ww #1/#2 \q_stop
+ { \__cooking_units_frac:nn {#1} {#2} }
+\cs_new:Npn \__cooking_units_cufrac_parse_mixed_frac:www #1_#2/#3 \q_stop
+ {
+ #1
+ \hbox_to_wd:nn { \l__cooking_units_mixed_frac_dim } { }
+ \__cooking_units_frac:nn {#2} {#3}
+ }
\NewDocumentCommand \cudefinekeys { m m }
{
\bool_set_false:N \l__cooking_units_single_key_bool
@@ -1022,14 +1716,14 @@
\__cooking_units_error_if_unit_not_defined:n {#1}
\tl_if_blank:nF {#2}
{
- \clist_clear:N \l_tmpa_clist
- \prop_clear:N \l_tmpa_prop
+ \seq_clear:N \l__cooking_units_tmpa_seq
+ \prop_clear:N \l__cooking_units_tmpa_prop
\bool_if:NTF \l__cooking_units_single_key_bool
{
\__cooking_units_cukeys_parse_and_create_single_key:nn {#1} {#2}
}{
- \fp_set_eq:NN \l_tmpa_fp \c_one_fp
- \tl_set:Nn \l__cooking_units_tmp_unit_tl {#1}
+ \fp_set_eq:NN \l__cooking_units_tmpa_fp \c_one_fp
+ \tl_set:Nn \l__cooking_units_given_unit_tl {#1}
\__cooking_units_cukeys_parse_and_create_keys:nn {#1}
{
{#1} { \c_one_fp } #2
@@ -1042,7 +1736,8 @@
\__cooking_units_cukeys_parse_input:nn #2
\q_recursion_tail \q_recursion_tail \q_recursion_stop
\__cooking_units_cukeys_create_key_prop:n {#1}
- \__cooking_units_cukeys_define_keys:V \l_tmpa_clist
+ \clist_set_from_seq:NN \l__cooking_units_tmpa_clist \l__cooking_units_tmpa_seq
+ \__cooking_units_cukeys_define_keys:V \l__cooking_units_tmpa_clist
}
\cs_new:Npn \__cooking_units_cukeys_parse_input:nn #1#2
{
@@ -1050,40 +1745,44 @@
\quark_if_recursion_tail_stop_do:nn {#2}
{ \msg_error:nn { cooking-units } { missing-argument } }
\__cooking_units_error_if_unit_not_defined:n {#1}
- \clist_put_right:Nn \l_tmpa_clist {#1}
- \prop_put:Nnx \l_tmpa_prop {#1} { \fp_eval:n { #2 / \l_tmpa_fp } }
+ \seq_put_right:Nn \l__cooking_units_tmpa_seq {#1}
+ \prop_put:Nnx \l__cooking_units_tmpa_prop {#1} { \fp_eval:n { (#2) / \l__cooking_units_tmpa_fp } }
\__cooking_units_cukeys_parse_input:nn
}
\cs_new:Npn \__cooking_units_cukeys_create_key_prop:n #1
{
- \prop_clear:N \l_tmpb_prop
- \prop_put:NnV \l_tmpb_prop { Liste } \l_tmpa_clist
- \prop_put:NnV \l_tmpb_prop { prop } \l_tmpa_prop
- \prop_put:NnV \l_tmpb_prop { Erstes Ding } \l__cooking_units_tmp_unit_tl
- \clist_map_inline:Nn \l_tmpa_clist
+ \prop_clear:N \l__cooking_units_tmpb_prop
+ \prop_put:NnV \l__cooking_units_tmpb_prop { Liste } \l__cooking_units_tmpa_seq
+ \prop_put:NnV \l__cooking_units_tmpb_prop { prop } \l__cooking_units_tmpa_prop
+ \prop_put:NnV \l__cooking_units_tmpb_prop { Erstes Ding } \l__cooking_units_given_unit_tl
+ \seq_map_inline:Nn \l__cooking_units_tmpa_seq
{
- \prop_set_eq:cN { l__cooking_units_cukeys_ ##1 _prop } \l_tmpb_prop
+ \prop_set_eq:cN { l__cooking_units_cukeys_ ##1 _prop } \l__cooking_units_tmpb_prop
\tl_set_eq:cN { l__cooking_units_tmpa_ ##1 _tl } \c_one_fp
- \clist_map_inline:Nn \l_tmpa_clist
+ \seq_map_inline:Nn \l__cooking_units_tmpa_seq
{
\prop_put:cnx { l__cooking_units_cukeys_ ##1 _prop }
{####1}
{
\fp_eval:n
- { \prop_item:Nn \l_tmpa_prop {####1} / \prop_item:Nn \l_tmpa_prop {##1} }
+ {
+ ( \prop_item:Nn \l__cooking_units_tmpa_prop {####1} ) /
+ ( \prop_item:Nn \l__cooking_units_tmpa_prop {##1} )
+ }
}
}
}
}
\cs_new:Npn \__cooking_units_cukeys_define_keys:N #1
{
- \clist_map_inline:Nn \l_tmpa_clist
+ \seq_map_inline:Nn \l__cooking_units_tmpa_seq
{
- \clist_put_right:Nn \l__cooking_units_list_of_defined_keys_clist {##1}
+ \seq_if_in:NnF \l__cooking_units_list_of_defined_keys_seq {##1}
+ { \seq_put_right:Nn \l__cooking_units_list_of_defined_keys_seq {##1} }
\keys_define:nn { cooking-units }
{
##1 .choices:Vn =
- \l_tmpa_clist
+ \l__cooking_units_tmpa_clist
{
\__cooking_units_cukeys_define_keys_and_single_key_aux:n {##1}
} ,
@@ -1095,13 +1794,12 @@
{ key-choice-unknown }
{##1}
{####1}
- { \seq_use:Nnnn \l_tmpa_seq { ',' } { ',' } { ' ~ and ~ ' } }
+ { \seq_use:Nnnn \l_tmpa_seq { ',~ ' } { ',~ ' } { ' ~ and ~ ' } }
} ,
##1 .default:n = {##1} ,
##1 .groups:n = { change-unit }
}
}
- \clist_remove_duplicates:N \l__cooking_units_list_of_defined_keys_clist
}
\cs_generate_variant:Nn \__cooking_units_cukeys_define_keys:N { V }
\cs_new:Npn \__cooking_units_cukeys_define_keys_and_single_key_aux:n #1
@@ -1114,14 +1812,15 @@
}
\cs_new:Npn \__cooking_units_cukeys_parse_and_create_single_key:nn #1#2
{
- \tl_set_rescan:Nnn \l_tmpa_tl
+ \tl_set_rescan:Nnn \l__cooking_units_tmpa_tl
{
\char_set_catcode_letter:N \# %
\char_set_catcode_ignore:N\ %
} { {#1} { \c_one_fp } #2 }
- \__cooking_units_cusinglekeys_parse_input:V \l_tmpa_tl
+ \__cooking_units_cusinglekeys_parse_input:V \l__cooking_units_tmpa_tl
\__cooking_units_cusinglekeys_create_key_prop:n {#1}
- \__cooking_units_cukeys_define_singlekey:nV {#1} \l_tmpa_clist
+ \clist_set_from_seq:NN \l__cooking_units_tmpa_clist \l__cooking_units_tmpa_seq
+ \__cooking_units_cukeys_define_singlekey:nV {#1} \l__cooking_units_tmpa_clist
}
\cs_new:Npn \__cooking_units_cusinglekeys_parse_input:n #1
{
@@ -1135,27 +1834,28 @@
\quark_if_recursion_tail_stop_do:nn {#2}
{ \msg_error:nn { cooking-units } { missing-argument } }
\__cooking_units_error_if_unit_not_defined:n {#1}
- \clist_put_right:Nn \l_tmpa_clist {#1}
- \tl_set:Nn \l_tmpa_tl {#2}
- \tl_replace_all:NVn \l_tmpa_tl \c__cooking_units_str_hash_one_tl { \l_tmpa_fp }
- \prop_put:NnV \l_tmpa_prop {#1} \l_tmpa_tl
+ \seq_put_right:Nn \l__cooking_units_tmpa_seq {#1}
+ \tl_set:Nn \l__cooking_units_tmpa_tl {#2}
+ \tl_replace_all:NVn \l__cooking_units_tmpa_tl \c__cooking_units_input_str_hash_one_tl { \l__cooking_units_tmpa_fp }
+ \prop_put:NnV \l__cooking_units_tmpa_prop {#1} \l__cooking_units_tmpa_tl
\__cooking_units_cusinglekeys_parse_input_aux:nn
}
\cs_new:Npn \__cooking_units_cusinglekeys_create_key_prop:n #1
{
\tl_set_eq:cN { l__cooking_units_tmpa_ #1 _tl } \c_one_fp
- \prop_set_eq:cN { l__cooking_units_cukeys_ #1 _prop } \l_tmpa_prop
+ \prop_set_eq:cN { l__cooking_units_cukeys_ #1 _prop } \l__cooking_units_tmpa_prop
\prop_put:cnn { l__cooking_units_cukeys_ #1 _prop } { Erstes Ding } {#1}
- \prop_put:cnV { l__cooking_units_cukeys_ #1 _prop } { Liste } \l_tmpa_clist
- \prop_put:cnV { l__cooking_units_cukeys_ #1 _prop } { prop } \l_tmpa_prop
+ \prop_put:cnV { l__cooking_units_cukeys_ #1 _prop } { Liste } \l__cooking_units_tmpa_seq
+ \prop_put:cnV { l__cooking_units_cukeys_ #1 _prop } { prop } \l__cooking_units_tmpa_prop
}
\cs_new:Npn \__cooking_units_cukeys_define_singlekey:nN #1#2
{
- \clist_put_right:Nn \l__cooking_units_list_of_defined_keys_clist {#1}
+ \seq_if_in:NnF \l__cooking_units_list_of_defined_keys_seq {#1}
+ { \seq_put_right:Nn \l__cooking_units_list_of_defined_keys_seq {#1} }
\keys_define:nn { cooking-units }
{
#1 .choices:Vn =
- \l_tmpa_clist
+ \l__cooking_units_tmpa_clist
{
\__cooking_units_cukeys_define_keys_and_single_key_aux:n {#1}
} ,
@@ -1172,35 +1872,34 @@
#1 .default:n = {#1} ,
#1 .groups:n = { change-unit } ,
}
- \clist_remove_duplicates:N \l__cooking_units_list_of_defined_keys_clist
}
\cs_generate_variant:Nn \__cooking_units_cukeys_define_singlekey:nN { nV }
\NewDocumentCommand \cuaddkeys { m m }
{
\bool_set_false:N \l__cooking_units_single_key_bool
- \tl_set:Nn \l_tmpa_tl {#1}
- \tl_set:Nn \l_tmpb_tl {#2}
- \__cooking_units_cukeys_add_keys_or_single_keys:VV \l_tmpa_tl \l_tmpb_tl
+ \tl_set:Nn \l__cooking_units_tmpa_tl {#1}
+ \tl_set:Nn \l__cooking_units_tmpb_tl {#2}
+ \__cooking_units_cukeys_add_keys_or_single_keys:VV \l__cooking_units_tmpa_tl \l__cooking_units_tmpb_tl
}
\NewDocumentCommand \cuaddsinglekeys { m m }
{
\bool_set_true:N \l__cooking_units_single_key_bool
- \tl_set:Nn \l_tmpa_tl {#1}
- \tl_set:Nn \l_tmpb_tl {#2}
- \__cooking_units_cukeys_add_keys_or_single_keys:VV \l_tmpa_tl \l_tmpb_tl
+ \tl_set:Nn \l__cooking_units_tmpa_tl {#1}
+ \tl_set:Nn \l__cooking_units_tmpb_tl {#2}
+ \__cooking_units_cukeys_add_keys_or_single_keys:VV \l__cooking_units_tmpa_tl \l__cooking_units_tmpb_tl
}
\NewDocumentCommand \cuaddtokeys { m m m }
{
\bool_set_false:N \l__cooking_units_single_key_bool
- \tl_set:Nn \l_tmpa_tl {#1}
- \tl_set:Nn \l_tmpb_tl { {#2} { \fp_eval:n { \c_one_fp / #3 } } }
- \__cooking_units_cukeys_add_keys_or_single_keys:VV \l_tmpa_tl \l_tmpb_tl
+ \tl_set:Nn \l__cooking_units_tmpa_tl {#1}
+ \tl_set:Nn \l__cooking_units_tmpb_tl { {#2} { \fp_eval:n { \c_one_fp / (#3) } } }
+ \__cooking_units_cukeys_add_keys_or_single_keys:VV \l__cooking_units_tmpa_tl \l__cooking_units_tmpb_tl
}
\cs_new:Npn \__cooking_units_cukeys_add_keys_or_single_keys:nn #1#2
{
\__cooking_units_error_if_unit_not_defined:n {#1}
- \clist_if_in:NnF \l__cooking_units_list_of_defined_keys_clist {#1}
- { \msg_error:nnn { cooking-units } { Key - not - defined } {#1} }
+ \seq_if_in:NnF \l__cooking_units_list_of_defined_keys_seq {#1}
+ { \msg_error:nnn { cooking-units } { Key-not-defined } {#1} }
\tl_if_blank:nF {#2}
{
\__cooking_units_cukeys_add_keys_and_single_key_aux:n {#1}
@@ -1212,14 +1911,14 @@
\cs_generate_variant:Nn \__cooking_units_cukeys_add_keys_or_single_keys:nn { VV }
\cs_new:Npn \__cooking_units_cukeys_add_keys_and_single_key_aux:n #1
{
- \prop_get:cnN { l__cooking_units_cukeys_ #1 _prop } { Liste } \l_tmpa_clist
- \prop_get:cnN { l__cooking_units_cukeys_ #1 _prop } { prop } \l_tmpa_prop
- \prop_get:cnN { l__cooking_units_cukeys_ #1 _prop } { Erstes Ding } \l__cooking_units_tmp_unit_tl
- \prop_get:cVN { l__cooking_units_cukeys_ #1 _prop } \l__cooking_units_tmp_unit_tl \l_tmpa_fp
+ \prop_get:cnN { l__cooking_units_cukeys_ #1 _prop } { Liste } \l__cooking_units_tmpa_seq
+ \prop_get:cnN { l__cooking_units_cukeys_ #1 _prop } { prop } \l__cooking_units_tmpa_prop
+ \prop_get:cnN { l__cooking_units_cukeys_ #1 _prop } { Erstes Ding } \l__cooking_units_given_unit_tl
+ \prop_get:cVN { l__cooking_units_cukeys_ #1 _prop } \l__cooking_units_given_unit_tl \l__cooking_units_tmpa_fp
}
\NewDocumentCommand \declarecookingunit { o m }
{
- \clist_if_in:NnTF \g__cooking_units_list_of_defined_units_clist {#2}
+ \seq_if_in:NnTF \g__cooking_units_list_of_defined_units_seq {#2}
{ \msg_info:nnn { cooking-units } { redefine-unit } {#2} }
{ \__cooking_units_new_cooking_unit:nn {#1} {#2} }
\__cooking_units_set_cooking_unit:nn {#1} {#2}
@@ -1231,7 +1930,7 @@
}
\NewDocumentCommand \providecookingunit { o m }
{
- \clist_if_in:NnF \g__cooking_units_list_of_defined_units_clist {#2}
+ \seq_if_in:NnF \g__cooking_units_list_of_defined_units_seq {#2}
{
\__cooking_units_new_cooking_unit:nn {#1} {#2}
\__cooking_units_set_cooking_unit:nn {#1} {#2}
@@ -1239,10 +1938,10 @@
}
\cs_new:Npn \__cooking_units_new_cooking_unit:nn #1#2
{
- \clist_if_in:NnTF \g__cooking_units_list_of_defined_units_clist {#2}
+ \seq_if_in:NnTF \g__cooking_units_list_of_defined_units_seq {#2}
{ \msg_error:nnn { cooking-units } { unit-already-defined } {#2} }
{
- \clist_put_right:Nn \g__cooking_units_list_of_defined_units_clist {#2}
+ \seq_put_right:Nn \g__cooking_units_list_of_defined_units_seq {#2}
\tl_new:c { l__cooking_units_tmpa_ #2 _tl }
\tl_set_eq:cN { l__cooking_units_tmpa_ #2 _tl } \c_one_fp
\clist_new:c { l__cooking_units_predefined_option_#2_clist }
@@ -1253,287 +1952,90 @@
{ \clist_put_right:cn { l__cooking_units_predefined_option_#2_clist } {##1} },
}
\prop_new:c { l__cooking_units_cukeys_ #2 _prop }
- \tl_new:c { l__cooking_units_cu_unit_ #2 _tl }
+ \tl_new:c { l__cooking_units_default_unit_ #2 _tl }
}
}
\cs_new:Npn \__cooking_units_set_cooking_unit:nn #1#2
{
\IfNoValueTF {#1}
{
- \tl_set:cn { l__cooking_units_cu_unit_ #2 _tl } {#2}
- \deftranslation { #2 ( cu-unit ) } {#2}
+ \tl_set:cn { l__cooking_units_default_unit_ #2 _tl } {#2}
+ \__cooking_units_deftranslation_base:xxn {#2} \c__cooking_units_postfix_unit_tl {#2}
}{
- \tl_set:cn { l__cooking_units_cu_unit_ #2 _tl } {#1}
- \deftranslation { #2 ( cu-unit ) } {#1}
+ \tl_set:cn { l__cooking_units_default_unit_ #2 _tl } {#1}
+ \__cooking_units_deftranslation_base:xxn {#2} \c__cooking_units_postfix_unit_tl {#1}
}
- }
-\NewDocumentCommand \cutext { d<> O{} m m }
- {
- \group_begin:
- \__cooking_units_cutext_initialise:nnn {#1} {#2} {#4}
- \bool_if:NTF \l__cooking_units_cutext_to_cunum_bool
- { \cunum {#3} {#4} }
+ \__cooking_units_deftranslation_base:xxn {#2} \c__cooking_units_postfix_unitname_tl { \q__cooking_units_no_translation }
+ \__cooking_units_deftranslation_base:xxn {#2} \c__cooking_units_postfix_unitname_pl_tl { \q__cooking_units_no_translation }
+ \__cooking_units_deftranslation_base:xxn {#2} \c__cooking_units_postfix_gender_tl { m }
+ }
+\tl_new:N \l__cooking_units_sanitise_tl
+\cs_new_protected:Npn \__cooking_units_sanitise_aux:w #1 \q_mark
+ { \tl_set:Nn \l__cooking_units_sanitise_tl {#1} }
+\group_begin:
+ \char_set_catcode_active:n { `\< }
+ \char_set_catcode_active:n { `\> }
+ \cs_new:Npn \__cooking_units_sanitize_open_arrow:
+ {
+ \exp_after:wN \__cooking_units_sanitize_open_arrow_auxi:w \l__cooking_units_sanitise_tl
+ \q_mark < \q_nil <
+ \exp_after:wN \__cooking_units_sanitise_aux:w \l__cooking_units_sanitise_tl
+ }
+ \cs_new_protected:Npn \__cooking_units_sanitize_open_arrow_auxi:w #1 <
+ {
+ \tl_set:Nn \l__cooking_units_sanitise_tl {#1}
+ \__cooking_units_sanitize_open_arrow_auxii:w
+ }
+ \cs_new_protected:Npn \__cooking_units_sanitize_open_arrow_auxii:w #1 <
+ {
+ \quark_if_nil:nF {#1}
{
- \bool_set_false:N \l__cooking_units_cutext_uppercase_word_bool
- \__cooking_units_cutext:nnnn {#1} {#2} {#3} {#4}
+ \tl_set:Nx \l__cooking_units_sanitise_tl
+ {
+ \exp_not:V \l__cooking_units_sanitise_tl
+ \token_to_str:N <
+ \exp_not:n {#1}
+ }
+ \exp_after:wN \__cooking_units_sanitize_open_arrow_auxii:w
}
- \group_end:
- }
-\NewDocumentCommand \Cutext { d<> O{} m m }
- {
- \group_begin:
- \__cooking_units_cutext_initialise:nnn {#1} {#2} {#4}
- \bool_if:NTF \l__cooking_units_cutext_to_cunum_bool
- { \cunum {#3} {#4} }
+ }
+ \cs_new:Npn \__cooking_units_sanitize_close_arrow:
+ {
+ \exp_after:wN \__cooking_units_sanitize_close_arrow_auxi:w \l__cooking_units_sanitise_tl
+ \q_mark > \q_nil >
+ \exp_after:wN \__cooking_units_sanitise_aux:w \l__cooking_units_sanitise_tl
+ }
+ \cs_new_protected:Npn \__cooking_units_sanitize_close_arrow_auxi:w #1 >
+ {
+ \tl_set:Nn \l__cooking_units_sanitise_tl {#1}
+ \__cooking_units_sanitize_close_arrow_auxii:w
+ }
+ \cs_new_protected:Npn \__cooking_units_sanitize_close_arrow_auxii:w #1 >
+ {
+ \quark_if_nil:nF {#1}
{
- \bool_set_true:N \l__cooking_units_cutext_uppercase_word_bool
- \__cooking_units_cutext:nnnn {#1} {#2} {#3} {#4}
+ \tl_set:Nx \l__cooking_units_sanitise_tl
+ {
+ \exp_not:V \l__cooking_units_sanitise_tl
+ \token_to_str:N >
+ \exp_not:n {#1}
+ }
+ \exp_after:wN \__cooking_units_sanitize_close_arrow_auxii:w
}
- \group_end:
- }
-\cs_new_protected:Npn \__cooking_units_cutext_initialise:nnn #1#2#3
- {
- \bool_set_true:N \l__cooking_units_using_cutext_bool
- \__cooking_units_initialise_default:nnn {#1} {#2} {#3}
- \bool_if:NTF \l__cooking_units_cutext_change_unit_bool
- { \__cooking_units_initialise_unit_change:nnn {#1} {#2} {#3} }
- { \tl_set_eq:NN \l__cooking_units_option_unit_tl \l__cooking_units_tmp_unit_tl }
- \__cooking_units_initialise_after_unit_change:nnn {#1} {#2} {#3}
- }
-\cs_new:Npn \__cooking_units_cutext:nnnn #1#2#3#4
- {
- \bool_if:nTF { \l__cooking_units_cutext_old_bool || !\l__cooking_units_parse_input_bool }
- {
- \__cooking_units_cutext_default:nnn {#2} {#3} {#4}
- \__cooking_units_cutext_print_correct_unitname:nnn {#3} {#4} {#4}
- }{
- \__cooking_units_parse_and_evaluate_input:n {#3}
- \__cooking_units_cutext_print_correct_unitname:VVV
- \l__cooking_units_cutext_tmp_tl \l__cooking_units_option_unit_tl \l__cooking_units_tmp_unit_tl
- }
- }
-\cs_new:Npn \__cooking_units_cutext_default:nnn #1#2#3
- {
- \__cooking_units_error_if_unit_not_defined:n {#3}
- \bool_if:NT \l__cooking_units_convert_to_eV_bool
- { \__cooking_units_convert_to_eV: }
- \bool_if:NTF \l__cooking_units_parse_input_bool
- {
- \tl_set:Nn \l_tmpb_tl {#2}
- \tl_if_in:NVTF \l_tmpb_tl \l__cooking_units_input_range_sign_tl
- {
- \tl_replace_once:NVn \l_tmpb_tl \l__cooking_units_input_range_sign_tl { \q__cooking_units_range }
- \__cooking_units_cutext_parse_range:Vn \l_tmpb_tl {#3}
- }{
- \__cooking_units_cutext_print_output:Nn \l_tmpb_tl {#3}
- }
- }
- {#2}
- }
-\cs_new:Npn \__cooking_units_cutext_parse_range:Nn #1 #2
- {
- \__cooking_units_cutext_parse_range_aux:nww {#2} #1 \q_stop
- }
-\cs_generate_variant:Nn \__cooking_units_cutext_parse_range:Nn { V }
-\cs_new:Npn \__cooking_units_cutext_parse_range_aux:nww #1 #2 \q__cooking_units_range #3 \q_stop
- {
- \tl_set:Nn \l__cooking_units_tmpa_tl {#2}
- \tl_set:Nn \l__cooking_units_tmpb_tl {#3}
- \__cooking_units_cutext_print_output:Nn \l__cooking_units_tmpa_tl {#1}
- \tl_use:N \l__cooking_units_cutext_range_sign_tl
- \__cooking_units_cutext_print_output:Nn \l__cooking_units_tmpb_tl {#1}
- }
-\cs_new_protected:Npn \__cooking_units_cutext_print_output:Nn #1#2
- {
- \bool_if:NTF \g__cooking_units_load_if_opt_numeral_bool
- {
- \__cooking_units_if_integer_and_parse:VTF #1
- {
- \fp_compare:nNnTF {#1} < { \l__cooking_units_print_numerals_below_int }
- {
- \fp_compare:nNnTF {#1} = { \c_one_fp }
- {
- \translatelet \l__cooking_units_translation_tmpa_tl { #2 (cu-unitgender) }
- \translatelet \l__cooking_units_translation_tmpa_tl
- { one (\l__cooking_units_translation_tmpa_tl) (cu-unitname) }
- \bool_if:NTF \l__cooking_units_cutext_uppercase_word_bool
- {
- \exp_args:Nf \tl_to_uppercase:n { \tl_head:V \l__cooking_units_translation_tmpa_tl }
- \tl_tail:V \l__cooking_units_translation_tmpa_tl
- }
- { \l__cooking_units_translation_tmpa_tl }
- }{
- \bool_if:NTF \l__cooking_units_cutext_uppercase_word_bool
- { \Numberstringnum {#1} }
- { \numberstringnum {#1} }
- }
- }{ \__cooking_units_print_nummerical_output:N #1 }
- }{ \__cooking_units_print_nummerical_output:N #1 }
- }
- { \__cooking_units_print_nummerical_output:N #1 }
- }
-\cs_generate_variant:Nn \__cooking_units_cutext_print_output:Nn { NV }
-\cs_new:Npn \__cooking_units_cutext_print_correct_unitname:nnn #1#2#3
- {
- \l__cooking_units_cutext_space_tl
- \bool_if:nTF
- {
- ! \l__cooking_units_parse_input_bool ||
- \l__cooking_units_fraction_in_input_bool ||
- \l__cooking_units_special_sign_bool
- }
- { \translate { #3 (cu-unitname pl) } }
- {
- \__cooking_units_if_integer:nTF {#1}
- {
- \fp_compare:nNnTF {#1} = { \c_one_fp }
- { \translate { #2 (cu-unitname) } }
- { \translate { #2 (cu-unitname pl) } }
- }
- { \translate { #2 (cu-unitname pl) } }
- }
- }
-\cs_generate_variant:Nn \__cooking_units_cutext_print_correct_unitname:nnn { VVV }
-\NewDocumentCommand \cufrac { O{} m }
- {
- \msg_error:nnnn { cooking-units } { obsolete-command } { \cufrac } { \cuam }
- \group_begin:
- \tl_if_empty:nF {#1}
- { \keys_set:nn { cooking-units } {#1} }
- \__cooking_units_cufrac:n {#2}
- \group_end:
- }
-\cs_new:Npn \__cooking_units_cufrac:n #1
- {
- \tl_set_rescan:Nnn \l_tmpa_tl
- {
- \char_set_catcode_letter:N \_ %
- \char_set_catcode_ignore:N\ %
- } {#1}
- \__cooking_units_cufrac_parse:V \l_tmpa_tl
- }
-\cs_new:Npn \__cooking_units_cufrac_parse:n #1
- {
- \tl_if_in:nnTF {#1} { / }
- {
- \tl_if_in:nnTF {#1} { _ }
- { \__cooking_units_cufrac_parse_mixed_frac:www #1 \q_stop }
- { \__cooking_units_cufrac_parse_frac:ww #1 \q_stop }
- }{
- \tl_if_in:nnTF {#1} { _ }
- { \msg_error:nnn { cooking-units } { missing-slash } {#1} }
- { \__cooking_units_cufrac_parse_scale:n {#1} }
- }
- }
-\cs_generate_variant:Nn \__cooking_units_cufrac_parse:n { V }
-\cs_new:Npn \__cooking_units_cufrac_parse_scale:n #1 {#1}
-\cs_new:Npn \__cooking_units_cufrac_parse_frac:ww #1/#2 \q_stop
- { \__cooking_units_frac:nn {#1} {#2} }
-\cs_new:Npn \__cooking_units_cufrac_parse_mixed_frac:www #1_#2/#3 \q_stop
- {
- #1
- \hbox_to_wd:nn { \l__cooking_units_mixed_frac_dim } { }
- \__cooking_units_frac:nn {#2} {#3}
- }
-\tl_new:N \l__cooking_units_cuam_marker_tl
-\tl_set:Nn \l__cooking_units_cuam_marker_tl { __cooking_units_cunum }
-\tl_new:c { l__cooking_units_tmpa_ \l__cooking_units_cuam_marker_tl _ tl }
-\tl_set:cn { l__cooking_units_tmpa_ \l__cooking_units_cuam_marker_tl _ tl } { \c_one_fp }
-\clist_new:c { l__cooking_units_predefined_option_ \l__cooking_units_cuam_marker_tl _clist }
-\NewDocumentCommand \cuam { d<> O{} m }
- {
- \group_begin:
- \__cooking_units_cuam_initialise:nnn {#1} {#2} {}
- \bool_if:NTF \l__cooking_units_parse_input_bool
- {
- \bool_if:NTF \l__cooking_units_cuam_old_bool
- { \__cooking_units_cuam_old:n {#3} }
- { \__cooking_units_parse_and_evaluate_input:n {#3} }
- }
- { \__cooking_units_cunum_do_not_parse:nnn {#3} {} {} }
- \group_end:
- }
-\cs_new_protected:Npn \__cooking_units_cuam_initialise:nnn #1#2#3
- {
- \tl_set_eq:NN \l__cooking_units_tmp_unit_tl \l__cooking_units_cuam_marker_tl
- \tl_set_eq:NN \l__cooking_units_option_unit_tl \l__cooking_units_cuam_marker_tl
- \__cooking_units_initialise_after_unit_change:nnn {#1} {#2} {#3}
- }
-\cs_new:Npn \__cooking_units_cuam:n #1
- {
- \tl_set_rescan:Nnn \l_tmpa_tl
- {
- \char_set_catcode_letter:N \_ %
- \char_set_catcode_ignore:N \ %
- \char_set_catcode_other:N ? %
- } {#1}
- \__cooking_units_cuam_parse:V \l_tmpa_tl
- }
-\cs_new:Npn \__cooking_units_cuam_old:n #1
- {
- \tl_set_rescan:Nnn \l_tmpa_tl
- {
- \char_set_catcode_letter:N \_ %
- \char_set_catcode_ignore:N\ %
- } {#1}
- \__cooking_units_cuam_old_parse:V \l_tmpa_tl
- }
-\cs_new_protected:Npn \__cooking_units_cuam_old_parse:n #1
- {
- \tl_if_in:nVTF {#1} \l__cooking_units_input_range_sign_tl
- {
- \tl_set:Nn \l_tmpa_tl {#1}
- \tl_replace_once:NVn \l_tmpa_tl \l__cooking_units_input_range_sign_tl { \q__cooking_units_range }
- \__cooking_units_cuam_old_parse_range:V \l_tmpa_tl
- }{
- \tl_if_in:nnTF {#1} { / }
- {
- \tl_if_in:nnTF {#1} { _ }
- { \__cooking_units_cuam_old_parse_mixed_frac:www #1 \q_stop }
- { \__cooking_units_cuam_old_parse_frac:ww #1 \q_stop }
- }{
- \tl_if_in:nnTF {#1} { _ }
- { \msg_error:nnn { cooking-units } { missing-slash } {#1} }
- { \__cooking_units_cuam_old_parse_scale:n {#1} }
- }
- }
- }
-\cs_generate_variant:Nn \__cooking_units_cuam_old_parse:n { V }
-\cs_new:Npn \__cooking_units_cuam_parse_range:n #1
- {
- \__cooking_units_cuam_parse_range_aux:ww #1 \q_nil
- }
-\cs_generate_variant:Nn \__cooking_units_cuam_parse_range:n { V }
-\cs_new:Npn \__cooking_units_cuam_parse_range_aux:ww #1 \q__cooking_units_range #2 \q_nil
- {
- \__cooking_units_parse_input_and_safe_in:nN {#1} \l_tmpa_tl
- \__cooking_units_parse_input_and_safe_in:nN {#2} \l_tmpb_tl
- \__cooking_units_print_nummerical_output:N \l_tmpa_tl
- \l__cooking_units_cunum_range_sign_tl
- \__cooking_units_print_nummerical_output:N \l_tmpb_tl
- }
-\cs_new:Npn \__cooking_units_cuam_old_parse_range:n #1
- {
- \__cooking_units_cuam_old_parse_range_aux:ww #1 \q_nil
- }
-\cs_generate_variant:Nn \__cooking_units_cuam_old_parse_range:n { V }
-\cs_new:Npn \__cooking_units_cuam_old_parse_range_aux:ww #1 \q__cooking_units_range #2 \q_nil
+ }
+\group_end:
+\cs_new_protected:Npn \__cooking_units_sanitize_arrows:n #1
{
- #1 \l__cooking_units_cunum_range_sign_tl #2
- }
-\cs_new:Npn \__cooking_units_cuam_old_parse_scale:n #1 {#1}
-\cs_new:Npn \__cooking_units_cuam_old_parse_frac:ww #1/#2 \q_stop
- { \__cooking_units_frac:nn {#1} {#2} }
-\cs_new:Npn \__cooking_units_cuam_old_parse_mixed_frac:www #1_#2/#3 \q_stop
- {
- #1
- \hbox_to_wd:nn { \l__cooking_units_mixed_frac_dim } { }
- \__cooking_units_frac:nn {#2} {#3}
+ \tl_set:Nn \l__cooking_units_sanitise_tl {#1}
+ \__cooking_units_sanitize_open_arrow:
+ \__cooking_units_sanitize_close_arrow:
}
\NewDocumentCommand \cudefinename { m m }
{
\tl_set:Nn \l__cooking_units_language_tl {#1}
- \__cooking_units_cuname_parse_input:n #2
+ \__cooking_units_sanitize_arrows:n {#2}
+ \exp_last_unbraced:NV
+ \__cooking_units_cuname_parse_input:n \l__cooking_units_sanitise_tl
\q_recursion_tail \q_recursion_tail \q_recursion_stop
}
\cs_new:Npn \__cooking_units_cuname_parse_input:n #1
@@ -1542,7 +2044,7 @@
{
\__cooking_units_cuname_parse_unit_symbol:nw {#1}
}{
- \clist_if_in:NnTF \g__cooking_units_allowed_unit_phrases_clist {#1}
+ \clist_if_in:NnTF \g__cooking_units_allowed_special_keys_clist {#1}
{ \__cooking_units_cuname_parse_input_aux:nn {#1} }
{ \__cooking_units_cuname_parse_unit_symbol:nw {#1} [ \q_no_value ] }
}
@@ -1555,11 +2057,14 @@
\__cooking_units_error_if_unit_not_defined:n {#1}
\quark_if_no_value:nTF {#2}
{
- \__cooking_units_deftranslation:Vnv
- \l__cooking_units_language_tl { #1 ( cu-unit ) } { l__cooking_units_cu_unit_ #1 _tl }
- }
- {
- \__cooking_units_deftranslation:Vnn \l__cooking_units_language_tl { #1 ( cu-unit ) } {#2}
+ \__cooking_units_deftranslation_to:Vxxv
+ \l__cooking_units_language_tl {#1}
+ \c__cooking_units_postfix_unit_tl
+ { l__cooking_units_default_unit_ #1 _tl }
+ }{
+ \__cooking_units_deftranslation_to:Vxxn
+ \l__cooking_units_language_tl {#1}
+ \c__cooking_units_postfix_unit_tl {#2}
}
\__cooking_units_cuname_parse_input_aux:nn {#1}
}
@@ -1568,26 +2073,32 @@
\quark_if_recursion_tail_stop:n {#1}
\quark_if_recursion_tail_stop_do:nn {#2}
{ \msg_error:nn { cooking-units } { missing-argument } }
- \clist_if_in:NnF \g__cooking_units_allowed_unit_phrases_clist {#1}
+ \clist_if_in:NnF \g__cooking_units_allowed_special_keys_clist {#1}
{ \__cooking_units_error_if_unit_not_defined:n {#1} }
- \__cooking_units_deftranslation:Vnn \l__cooking_units_language_tl { #1 ( cu-unitname ) } {#2}
+ \__cooking_units_deftranslation_to:Vxxn
+ \l__cooking_units_language_tl {#1}
+ \c__cooking_units_postfix_unitname_tl {#2}
\peek_meaning_ignore_spaces:NTF [
{ \__cooking_units_cuname_parse_bracket:nw {#1} }
{ \__cooking_units_cuname_parse_bracket:nw {#1} [#2] }
}
\cs_new:Npn \__cooking_units_cuname_parse_bracket:nw #1 [#2]
{
- \clist_if_in:NnF \g__cooking_units_allowed_unit_phrases_clist {#1}
+ \clist_if_in:NnF \g__cooking_units_allowed_special_keys_clist {#1}
{
- \__cooking_units_deftranslation:Vnn \l__cooking_units_language_tl { #1 ( cu-unitname pl ) } {#2}
+ \__cooking_units_deftranslation_to:Vxxn \l__cooking_units_language_tl {#1}
+ \c__cooking_units_postfix_unitname_pl_tl {#2}
}
\peek_meaning_ignore_spaces:NTF <
- { \__cooking_units_cuname_parse_arrows:nw {#1} }
- { \__cooking_units_cuname_parse_arrows:nw {#1} <m> }
+ { \__cooking_units_cuname_parse_gender:nw {#1} }
+ { \__cooking_units_cuname_parse_gender:nw {#1} <m> }
}
-\cs_new:Npn \__cooking_units_cuname_parse_arrows:nw #1 <#2>
+\cs_new:Npn \__cooking_units_cuname_parse_gender:nw #1 <#2>
{
- \__cooking_units_deftranslation:Vnn \l__cooking_units_language_tl { #1 ( cu-unitgender ) } {#2}
+ \__cooking_units_check_if_correct_gender_input:n {#2}
+ \__cooking_units_deftranslation_to:Vxxn
+ \l__cooking_units_language_tl {#1}
+ \c__cooking_units_postfix_gender_tl {#2}
\__cooking_units_cuname_parse_input:n
}
\NewDocumentCommand \cudefinesymbol { m m }
@@ -1601,15 +2112,120 @@
\quark_if_recursion_tail_stop:n {#1}
\quark_if_recursion_tail_stop_do:nn {#2}
{ \msg_error:nn { cooking-units } { missing-argument } }
- \clist_if_in:NnTF \g__cooking_units_allowed_unit_phrases_clist {#1}
+ \clist_if_in:NnTF \g__cooking_units_allowed_special_keys_clist {#1}
{
- \__cooking_units_deftranslation:Vnn \l__cooking_units_language_tl { #1 ( cu-unitname ) } {#2}
+ \__cooking_units_deftranslation_to:Vxxn \l__cooking_units_language_tl {#1}
+ \c__cooking_units_postfix_unitname_tl {#2}
}{
\__cooking_units_error_if_unit_not_defined:n {#1}
- \__cooking_units_deftranslation:Vnn \l__cooking_units_language_tl { #1 ( cu-unit ) } {#2}
+ \__cooking_units_deftranslation_to:Vxxn
+ \l__cooking_units_language_tl {#1}
+ \c__cooking_units_postfix_unit_tl {#2}
}
\__cooking_units_cuprint_define_printed_unit:nn
}
+\__cooking_units_newtranslation_base:nVn { phrase-list } \c__cooking_units_postfix_phrase_tl { \q__cooking_units_no_translation }
+\prg_new_conditional:Npnn \__cooking_units_phrase_list_get_for:NN #1#2 { TF , T , F }
+ {
+ \__cooking_units_translate_let:VNxx #2 #1 { phrase-list } \c__cooking_units_postfix_phrase_tl
+ \tl_if_eq:NNTF #1 \q__cooking_units_no_translation
+ { \prg_return_false: }
+ { \prg_return_true: }
+ }
+\prg_new_conditional:Npnn \__cooking_units_if_phrase_list_exists:N #1 { TF , T , F }
+ {
+ \__cooking_units_translate_let:Nxx \l_tmpa_tl { phrase-list } \c__cooking_units_postfix_phrase_tl
+ \tl_if_eq:NNTF \l_tmpa_tl \q__cooking_units_no_translation
+ { \prg_return_false: }
+ { \prg_return_true: }
+ }
+\NewDocumentCommand \cudefinephrase { m m }
+ {
+ \__cooking_units_cuphrase:nn {#1} {#2}
+ }
+\cs_new:Npn \__cooking_units_cuphrase:nn #1#2
+ {
+ \tl_set:Nn \l__cooking_units_language_tl {#1}
+ \__cooking_units_phrase_list_get_for:NNTF \l__cooking_units_phrase_prop \l__cooking_units_language_tl
+ {
+ \__cooking_units_translate_let:VNxx \l__cooking_units_language_tl \l__cooking_units_phrase_numbers_clist
+ { phrase-list-list } \c__cooking_units_postfix_phrase_tl
+ }{
+ \prop_clear:N \l__cooking_units_phrase_prop
+ \clist_clear:N \l__cooking_units_phrase_numbers_clist
+ }
+ \__cooking_units_sanitize_arrows:n {#2}
+ \exp_last_unbraced:NV
+ \__cooking_units_cuphrase_parse:n \l__cooking_units_sanitise_tl
+ \q_recursion_tail \q_recursion_tail \q_recursion_stop
+ \clist_sort:Nn \l__cooking_units_phrase_numbers_clist
+ {
+ \int_compare:nNnTF { \int_abs:n {##1} } < { \int_abs:n {##2} }
+ { \sort_return_swapped: }
+ {
+ \int_compare:nNnTF { \int_abs:n {##1} } = { \int_abs:n {##2} }
+ {
+ \int_compare:nNnTF {##1} < {##2}
+ { \sort_return_same: }
+ { \sort_return_swapped: }
+ }{ \sort_return_same: }
+ }
+ }
+ \__cooking_units_deftranslation_to:VxxV
+ \l__cooking_units_language_tl { phrase-list }
+ \c__cooking_units_postfix_phrase_tl
+ \l__cooking_units_phrase_prop
+ \__cooking_units_deftranslation_to:VxxV
+ \l__cooking_units_language_tl { phrase-list-list }
+ \c__cooking_units_postfix_phrase_tl \l__cooking_units_phrase_numbers_clist
+ }
+\cs_new:Npn \__cooking_units_cuphrase_parse:n #1
+ {
+ \quark_if_recursion_tail_stop:n {#1}
+ \__cooking_units_if_integer:nF {#1}
+ { \msg_error:nnn { cooking-units} { phrase-unit-not-an-integer } {#1} }
+ \peek_meaning_remove_ignore_spaces:NTF *
+ {
+ \int_set:Nn \l__cooking_units_tmpa_int {-#1}
+ \__cooking_units_cuphrase_parse_normal:Vn \l__cooking_units_tmpa_int
+ }{
+ \int_set:Nn \l__cooking_units_tmpa_int {#1}
+ \__cooking_units_cuphrase_parse_normal:Vn \l__cooking_units_tmpa_int
+ }
+ }
+\cs_new:Npn \__cooking_units_cuphrase_parse_normal:nn #1#2
+ {
+ \quark_if_recursion_tail_stop_do:nn {#2}
+ { \msg_error:nn { cooking-units } { missing-argument } }
+ \prop_put:Nnn \l__cooking_units_phrase_prop {#1} {#2}
+ \clist_if_in:NnF \l__cooking_units_phrase_numbers_clist {#1}
+ { \clist_put_right:Nn \l__cooking_units_phrase_numbers_clist {#1} }
+ \peek_meaning_ignore_spaces:NTF [
+ {
+ \__cooking_units_chuphrase_parse_plural:nw {#1}
+ }{
+ \__cooking_units_chuphrase_parse_plural:nw {#1} [#2]
+ }
+ }
+\cs_generate_variant:Nn \__cooking_units_cuphrase_parse_normal:nn { V }
+\cs_new:Npn \__cooking_units_chuphrase_parse_plural:nw #1 [#2]
+ {
+ \prop_put:Nnn \l__cooking_units_phrase_prop { #1-pl } {#2}
+ \peek_meaning_ignore_spaces:NTF <
+ {
+ \__cooking_units_chuphrase_parse_gender:nw {#1}
+ }{
+ \__cooking_units_chuphrase_parse_gender:nw {#1} < m >
+ }
+ }
+\cs_new:Npn \__cooking_units_chuphrase_parse_gender:nw #1 <#2>
+ {
+ \__cooking_units_check_if_correct_gender_input:n {#2}
+ \__cooking_units_deftranslation_to:Vxxn
+ \l__cooking_units_language_tl { #1-phrase-gender }
+ \c__cooking_units_postfix_gender_tl {#2}
+ \__cooking_units_cuphrase_parse:n
+ }
\NewDocumentCommand \cusetup { m }
{
\keys_set:nn { cooking-units } {#1}
@@ -1619,9 +2235,10 @@
\newcookingunit { g }
\newcookingunit { oz }
\newcookingunit { lb }
+\newcookingunit { stick }
\newcookingunit [ \ensuremath{ \__cooking_units_frac:nn { eV } { c^2 } } ] { eVc-2 }
-\newcookingunit [ \ensuremath{ {} ^ { \circ } } \kern-\scriptspace C ] { C }
\newcookingunit { K }
+\newcookingunit [ \ensuremath{ {} ^ { \circ } } \kern-\scriptspace C ] { C }
\newcookingunit [ \ensuremath{ {} ^ { \circ } } \kern-\scriptspace F ] { F }
\newcookingunit [ \ensuremath{ {} ^ { \circ } } \kern-\scriptspace R\'{e} ] { Re }
\newcookingunit { d }
@@ -1652,6 +2269,7 @@
\newcookingunit [ csp. ] { csp } %% coffeespoonful
\newcookingunit [ dsp. ] { dsp }
\newcookingunit [ Msp. ] { Msp }
+\DeclareLanguageAlias { AmericanEnglish } { American }
\cudefinename { German }
{
{ kg } { Kilogramm } < n >
@@ -1698,6 +2316,7 @@
{ g } { gramme }
{ oz } { ounce }
{ lb } { pound } [ pounds ]
+ { stick } { stick } [ sticks ]
{ d } { day } [ days ]
{ h } { hour } [ hours ]
{ min } { minute } [ minutes ]
@@ -1720,10 +2339,9 @@
{ J } { joule } [ joules ]
{ kJ } { kilojoule } [ kilojoules ]
{ eV } { electron \space volt }
- { Msp } { Messerspitze } [ Messerspitzen ] <f>
{ pn } [ pinch ] { pinch } [ pinches ]
- { EL } [ tsp. ] { tablespoon } [ tablespoons ]
- { TL } [ tbsp. ] { teaspoon } [ teaspoons ]
+ { EL } [ tbsp. ] { tablespoon } [ tablespoons ]
+ { TL } [ tsp. ] { teaspoon } [ teaspoons ]
{ dsp } { dessertspoonful }
{ csp } { coffeespoonful }
{ ssp } { saltspoonful }
@@ -1747,7 +2365,6 @@
{ dl } { deciliter } [ deciliters ]
{ cl } { centiliter } [ centiliters ]
{ ml } { milliliter } [ milliliters ]
- { Msp } { Messerspitze } [ Messerspitzen ] <f>
{ pn } [ pn. ] { pinch } [ pinches ]
}
\cudefinename { French }
@@ -1792,7 +2409,8 @@
{ dag }{ 100 }
{ g } { 1000 }
{ oz } { 35.27399 }
- { lb } { 2.204 622 6 } %% 2.204 622 6
+ { lb } { 2.2046226 } %% 2.204 622 6
+ { stick } { 8.81849 }
{ eVc-2 } { 560958865.0e+27 } %% 560958865.0 +- 3.5 e+27
}
\cudefinekeys { d }
@@ -1853,6 +2471,10 @@
{ F } { #1 * 2.25 + 32 }
{ eV } { ( #1 * 1.25 + 273.15 ) * \c__cooking_units_kb_eV_fp }
}
+\cudefinephrase { German }
+ {
+ { 12 } { Dutzend } < n >
+ }
\cusetup
{
set-option-for-F = { round-to-int = true } ,