texlive[42372] Master/texmf-dist: cooking-units (28oct16)

commits+karl at tug.org commits+karl at tug.org
Fri Oct 28 22:57:39 CEST 2016


Revision: 42372
          http://tug.org/svn/texlive?view=revision&revision=42372
Author:   karl
Date:     2016-10-28 22:57:39 +0200 (Fri, 28 Oct 2016)
Log Message:
-----------
cooking-units (28oct16)

Modified Paths:
--------------
    trunk/Master/texmf-dist/doc/latex/cooking-units/cooking-units.pdf
    trunk/Master/texmf-dist/source/latex/cooking-units/cooking-units.dtx
    trunk/Master/texmf-dist/tex/latex/cooking-units/cooking-units.sty

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

Modified: trunk/Master/texmf-dist/source/latex/cooking-units/cooking-units.dtx
===================================================================
--- trunk/Master/texmf-dist/source/latex/cooking-units/cooking-units.dtx	2016-10-28 20:57:14 UTC (rev 42371)
+++ trunk/Master/texmf-dist/source/latex/cooking-units/cooking-units.dtx	2016-10-28 20:57:39 UTC (rev 42372)
@@ -253,6 +253,91 @@
   { \paragraph{Example:} }
   { }
 
+%: table
+\tl_new:N \l_translation_does_not_exist_tl
+\tl_set:Nn \l_translation_does_not_exist_tl { --- }
+\tl_set_eq:NN \translationdoesnotexisttl \l_translation_does_not_exist_tl
+\tl_new:N \mytablecolumns
+\tl_set:Nn \mytablecolumns { l l l l l }
+\clist_new:N \l_list_of_units_clist
+\clist_new:N \l_list_of_textunits_clist
+\clist_set:Nn \l_list_of_textunits_clist
+  {
+    decimal-mark ,
+    one (m) ,
+    one (f) ,
+    one (n) ,
+  }
+\clist_set:Nx \l_list_of_units_clist
+  {
+    kg , dag , g , oz , lb , space ,
+    C , F , Re , K , space ,
+    d , h , min , s , space ,
+    m , dm , cm , mm , in , space ,
+    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 { , }
+  }
+
+
+\NewDocumentCommand \CreateTableForLanguages { s 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
+    \CreateTableRow {#2} 
+  }
+
+\NewDocumentCommand \CreateTableHeader { m }
+  {
+     \meta{unit-key} & \clist_map_inline:nn {#1} { printed \ unit & unit-name & (plural) & gender  } 
+  }
+\NewDocumentCommand \CreateTableRow { m }
+  {
+    \clist_map_inline:Nn \l_tmpa_clist
+      { 
+        \str_if_eq:nnTF { space } {##1} { \addlinespace }
+          {
+            ##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 }
+                       { \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 }
+                 { \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
+                 { }
+                 { 
+                   \tl_if_in:NnTF \l_tmpb_tl { unitname }
+                     { \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 }
+                 { \l_translation_does_not_exist_tl }
+                 { \l_tmpa_tl }
+              }
+            \\ 
+          }
+      } 
+  }
+
 \ExplSyntaxOff
 
 \lstset
@@ -368,6 +453,11 @@
 % \changes {2016/09/26} {1.03a} {\cs{cuaddsinglekeys} now tests if the unit exists (it didn't before).}
 % \changes {2016/09/26} {1.03b} {Replaced \cs{prop_clear_new:c} by \cs{prop_clear:c}.}
 % \changes {2016/09/26} {1.03b} {Recalculated all electron volt values for conversion (as 'kg' was wrong before). Let's hope they are correct this time.}
+% \changes {2016/09/26} {1.04} {New option: 'round-half'.}
+% \changes {2016/10/19} {1.04} {Use \cs{keys_set:nn} only if second argument is not empty.}
+% \changes {2016/10/19} {1.04} {'convert-to-eV' now also as optional argument available.}
+% \changes {2016/10/19} {1.04} {Option 'load-time-option' now spells 'available' correct.}
+% \changes {2016/10/19} {1.04} {Update of documentation.}
 % 
 %
 % \GetFileInfo{\jobname.sty}
@@ -537,7 +627,7 @@
 % \lstinline|\cuam| works like a more primitive version \mycs{cunum}
 % which doesn't need a unit, but doesn't check the input like \mycs{cunum}. 
 % Like in \lstinline|\cunum| \texttt{\_} and \texttt{/} are used to imply a (mixed) fraction and \texttt{-{}-} is
-% used to print ranges\footnote{Note that since v1.02 \mycs{myfrac} is obsolete.}:
+% used to print ranges\footnote{Note that since v1.02 \mycs{cufrac} is obsolete.}:
 %
 % \begin{cuexamplecode}
 %   \cuam{3} \\
@@ -551,6 +641,7 @@
 % \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.).
@@ -575,7 +666,7 @@
 %   volt} exists just for fun.}
 %   \begin{tabular}{ lll }
 %    \toprule
-%     unit name & unit-key & symbol \\ \midrule
+%     unitname & unit-key & symbol \\ \midrule
 %     \PrintUnit {kg} \\
 %     \PrintUnit {dag} \\
 %     \PrintUnit {g} \\
@@ -607,9 +698,9 @@
 %     \PrintUnit {kcal} \\
 %     \PrintUnit {J} \\
 %     \PrintUnit {kJ} \\ 
-%     \PrintUnit {eV} \\ \addlinespace
+%     \PrintUnit {eV} 
 %
-%     \bottomrule
+%    \\  \bottomrule
 %   \end{tabular}
 %   \label{tab:def-units}
 % \end{table}
@@ -622,7 +713,7 @@
 %     (like german; at least I never heard of it). So please only use units known to you.}
 %   \begin{tabular}{ lll }
 %     \toprule
-%     unit name & unit-key & symbol \\ \midrule
+%     unitname & unit-key & symbol \\ \midrule
 %     \PrintUnit {pn} \\ \addlinespace
 %     \PrintUnit {EL} \\
 %     \PrintUnit {TL} \\
@@ -863,7 +954,7 @@
 % \cunum[st=g]{1}{st} \\
 % \cunum[st=kg]{1}{st} \\
 % \cunum[kg=st]{1}{kg} \\
-% \cunum[st=kg]{16}{st} \\
+% \cunum[st=kg]{16}{st} 
 % \end{cuexamplecode}
 % \end{cuexample}
 %
@@ -889,7 +980,7 @@
 % \end{lstlisting}
 % \begin{cuexamplecode}
 % \cunum{10}{C} \\
-% \cunum[C=Ro]{10}{C} \\
+% \cunum[C=Ro]{10}{C} 
 % \end{cuexamplecode}
 % \end{cuexample}
 %
@@ -921,7 +1012,7 @@
 % \cunum[st=lb]{1}{st} \\
 % \cunum[st=g]{1}{st} \\
 % \cunum[st=kg]{1}{st} \\
-% \cunum[kg=st]{1}{kg} \\
+% \cunum[kg=st]{1}{kg} 
 % \end{cuexamplecode}
 % \end{cuexample}
 %
@@ -930,7 +1021,7 @@
 % \section{Language support}
 % \label{sec:language}
 %
-% The unit names and symbols depend on the language.  To change the
+% 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|.
 %
@@ -1211,10 +1302,39 @@
 %   \cunum{1.23456789}{kg} \\
 %   \cunum{12.58}{kg} \\
 %   \cunum[g=kg]{194--294}{g} \\
-%   \cunum[kg=g]{1.23456789}{kg} \\
+%   \cunum[kg=g]{1.23456789}{kg}
 % \end{cuexamplecode}
 %
+% \begin{function}{round-half}
+%   \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.
 %
+% 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.
+% \end{function}
+%
+%
+% \begin{cuexamplecode}
+%   \cusetup{round-half=default} @
+%   \cunum{0.005}{kg} \\
+%   \cunum{-0.005}{kg} \\
+%   \cunum{1.245}{kg} \\
+%   \cusetup{round-half=commercial} @
+%   \cunum{0.005}{kg} \\
+%   \cunum{-0.005}{kg} \\
+%   \cunum{1.245}{kg} 
+% \end{cuexamplecode}
+%
+%
 % \begin{function}{range-sign}
 %   \begin{syntax}
 %     range-sign = \meta{string}
@@ -1238,23 +1358,23 @@
 % \begin{cuexamplecode}
 %   \cusetup{cunum-range-sign={~to~}} @
 %   \cunum{1--2}{kg} \\
-%   \cuam{1--2}{kg} \\
+%   \cuam{1--2} \\
 %   \cutext{1--2}{kg} \\
-%   \Cutext{1--2}{kg} \\
+%   \Cutext{1--2}{kg} 
 % \end{cuexamplecode}
 % \begin{cuexamplecode}
 %   \cusetup{cutext-range-sign={~to~}} @
 %   \cunum{1--2}{kg} \\
-%   \cuam{1--2}{kg} \\
+%   \cuam{1--2} \\
 %   \cutext{1--2}{kg} \\
-%   \Cutext{1--2}{kg} \\
+%   \Cutext{1--2}{kg} 
 % \end{cuexamplecode}
 % \begin{cuexamplecode}
 %   \cusetup{range-sign={~to~}} @
 %   \cunum{1--2}{kg} \\
-%   \cuam{1--2}{kg} \\
+%   \cuam{1--2} \\
 %   \cutext{1--2}{kg} \\
-%   \Cutext{1--2}{kg} \\
+%   \Cutext{1--2}{kg} 
 % \end{cuexamplecode}
 %
 %
@@ -1312,7 +1432,7 @@
 %     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}.
+%   default is \texttt{0.1em} (because I said so).
 % \end{function}
 %
 % \begin{cuexamplecode}
@@ -1326,7 +1446,7 @@
 %   \cusetup{mixed-fraction-space=0em } @
 %   \cuam{1_2/3}{kg} \\
 %   \cunum{1_2/3}{kg} \\
-%   \cunum{10_2/3}{kg} \\
+%   \cunum{10_2/3}{kg} 
 % \end{cuexamplecode}
 %
 %
@@ -1348,7 +1468,7 @@
 %   \cunum{X--?}{kg} \\
 %   \cusetup{set-special-sign={} } @
 %   \cunum{1}{kg} \\
-%   \cunum{1--2}{kg} \\
+%   \cunum{1--2}{kg} 
 % \end{cuexamplecode}
 %
 %
@@ -1378,7 +1498,7 @@
 %   \cunum{qwertzuiop}{kg} \\
 %   \cutext{1}{kg} \\
 %   \cutext{100}{kg} \\
-%   \cutext{gjfak}{kg} \\
+%   \cutext{gjfak}{kg}
 % \end{cuexamplecode}
 %
 %
@@ -1410,7 +1530,7 @@
 %   \cutext{1}{kg} \\
 %   \cutext{2}{kg} \\
 %   \cutext{12}{kg} \\
-%   \cutext{13}{kg} \\
+%   \cutext{13}{kg}
 % \end{cuexamplecode}
 % \cusetup{ use-numerals-below=0 } 
 %
@@ -1457,7 +1577,7 @@
 %
 %   For example, this package implements the allowed minimum values for the
 %  temperatures \texttt{C}, \texttt{F}, \texttt{K} and \texttt{Re} to be checked if
-%  \opt{check-temperature} is active:
+%  \opt{check-temperature} is active using:
 % \begin{lstlisting}
 %   \cusetup
 %     {
@@ -1510,7 +1630,7 @@
 %   \cunum{1}{J} \\
 %   \cunum{1}{m} \\
 %   \cunum{1}{C} \\
-%   \cunum{1}{s} \\
+%   \cunum{1}{s}
 % \end{cuexamplecode}
 %
 %
@@ -1535,7 +1655,7 @@
 % 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}. I would need 
+% \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, 
@@ -1547,6 +1667,60 @@
 %
 %
 %
+% \clearpage
+% \appendix
+%
+% \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
+% (printed if \mycs{cutext} or \mycs{Cutext} is used)  and
+% the plural form (if different from the singular form).
+%
+% If a translation is not available a \enquote{\translationdoesnotexisttl} is
+% shown.
+%
+% \small
+%
+% 
+% \begin{function}{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.
+%
+% \begin{tabular}{ l l l l l }
+%   \toprule
+%   \CreateTableForLanguages{ AmericanEnglish  }
+%   \\\bottomrule
+% \end{tabular}
+% \end{function}
+%
+% \begin{function}{German}
+% \begin{tabular}{ l l l l l }
+%   \toprule
+%   \CreateTableForLanguages{ German  }
+%   \\\bottomrule
+% \end{tabular}
+% \end{function}
+%
+% \begin{function}{French}
+% \begin{tabular}{ l l l l l }
+%   \toprule
+%   \CreateTableForLanguages{ French }
+%   \\\bottomrule
+% \end{tabular}
+% \end{function}
+%
+%
+% \clearpage
+%
+%
 %^^A \section{Notes and other stuff}
 %^^A This section contains stuff which might or might not be interesting.
 %^^A
@@ -1673,8 +1847,8 @@
 %    \begin{macrocode}
 \ProvidesExplPackage
   {cooking-units}
-  {2016/09/26}
-  {1.03b}
+  {2016/10/19}
+  {1.04}
   {Ein Paket fuer Kocheinheiten}
 %    \end{macrocode}
 % Chekcing if \pkg{expl3} is uptodate, otherwise abort the loading of the package.
@@ -1742,7 +1916,7 @@
 \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 }
 %    \end{macrocode}
 % \end{macro}
 %
@@ -1894,6 +2068,7 @@
 % \end{macro}
 %
 %
+%
 % \begin{macro}{ \l_@@_list_of_defined_keys_clist , \g_@@_list_of_defined_units_clist }
 %   List of defined units and keys.
 %    \begin{macrocode}
@@ -1918,7 +2093,6 @@
 % Stores units which should be tested if \opt{check-temperature} equals true.
 %    \begin{macrocode}
 \clist_new:N \l_@@_temperatures_to_check_clist
-%\clist_set:Nn \l_@@_temperatures_to_check_clist { C , F , K , Re }
 %    \end{macrocode}
 % \end{macro}
 %
@@ -1936,7 +2110,8 @@
 %     \l_@@_convert_to_eV_bool,
 %     \l_@@_cutext_uppercase_word_bool,
 %     \l_@@_error_for_unknown_value_bool,
-%     \l_@@_parse_range_bool
+%     \l_@@_parse_range_bool,
+% ^^A    \l_@@_round_special_bool
 %   }
 % Some booleans we need later.
 %    \begin{macrocode}
@@ -1953,6 +2128,7 @@
 \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_@@_round_special_bool
 %\bool_new:N \l_@@_unit_is_singlekey_bool
 %    \end{macrocode}
 % \end{macro}
@@ -2147,6 +2323,7 @@
 %    \begin{macrocode}
     convert-to-eV .bool_set:N = \l_@@_convert_to_eV_bool ,
     convert-to-eV .default:n = { true } ,
+    convert-to-eV .groups:n = { change-unit } ,
 %    \end{macrocode}
 %\end{macro}
 %
@@ -2184,7 +2361,43 @@
           }
         },
 %    \end{macrocode}
-% Ending the definiton of keys.
+%
+%
+% \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.
+%    \begin{macrocode}
+    round-half .choices:nn =
+      { default , commercial }
+      {
+%        \bool_set_true:N \l_@@_round_special_bool
+        \cs_set:Npx \@@_round_setup:n ####1
+          {
+            \exp_not:N \l_@@_significant_figures_int
+            \int_case:nn { \l_keys_choice_int }
+              {
+                { 1 } { } 
+                { 2 } { \exp_not:N, ####1 }
+              }
+          }
+      },
+    round-half .default:n = { default },
+%    \end{macrocode}
+%
+%
+% \begin{macro}{ label }
+%    \begin{macrocode}
+    label .code:n = { \label{cooking-units-#1} } ,
+%    \end{macrocode}
+%
+% \begin{macro}{ for-persons }
+%    \begin{macrocode}
+    for-persons .int_set:N = \l_@@_number_of_persons_int ,
+    for-persons .default:n = { 4 } ,
+%    \end{macrocode}
+%
+% Ending the definition of keys.
 % \end{macro}
   }
 %    \begin{macrocode}
@@ -2330,7 +2543,7 @@
   } 
   {
     You \ used\  a\  special\  sign\  indicating\  that\  the\  true\  amount\  of\  the\ 
-    specific\  ingredient\  is\  (was) not\  known\  to\  you. This\  message\ 
+    specific\  ingredient\  is\  (was) \ not\  known\  to\  you. This\  message\ 
     reminds\  you\  about\  that\  fact.
     \msg_see_documentation_text:n {cooking-units}
   }
@@ -2341,7 +2554,7 @@
 %    \begin{macrocode}
 \msg_new:nnnn { cooking - units } { load-time-option } 
   { 
-    The \ option \ '#1' \ is \ only \ avaiable \ as \ a \ load-time-option. \
+    The \ option \ '#1' \ is \ only \ available \ as \ a \ load-time-option. \
     Please \ set \ it \ as \ a \ package \ option.
   } 
   { 
@@ -2373,6 +2586,8 @@
     'check-temperature'.
   } 
   { 
+    A \ minimum \ value \ is \ needed \ for \ testing \ if \
+    'check-temperature' \ is \ active.
     \msg_see_documentation_text:n { cooking-units } 
   }
 %    \end{macrocode}
@@ -2404,7 +2619,6 @@
 \cs_new:Npn \@@_error_if_unit_not_defined:n #1
   {
     \clist_if_in:NnF \g_@@_list_of_defined_units_clist {#1} 
-%     \tl_if_exist:cF { l_@@_tmpa_ #1 _tl }
       { \msg_error:nnn { cooking-units } { unknown-unit } {#1} }
   }
 \cs_generate_variant:Nn \@@_error_if_unit_not_defined:n { V }
@@ -2497,7 +2711,7 @@
   {
     \deftranslation [ to=#1 ] { #2 } {#3}
   }
-\cs_generate_variant:Nn \@@_deftranslation:Nnn { Vnn }
+\cs_generate_variant:Nn \@@_deftranslation:Nnn { Vnn , Vnv }
 %    \end{macrocode}
 % \end{macro}
 %
@@ -2524,6 +2738,16 @@
 %    \end{macrocode}
 % \end{macro}
 %
+% \begin{macro}{\@@_deftranslation:Nnn}
+% 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 
+% constant is defined.
+%    \begin{macrocode}
+\cs_new:Npn \@@_round_setup:n #1 { \l_@@_significant_figures_int }
+%    \end{macrocode}
+% \end{macro}
+%
 % \subsection {Parsing and cheking numbers}
 %
 % This section contains macros helping an checking the input.
@@ -2782,15 +3006,6 @@
 \cs_new:Npn \@@_calculate_input_and_store_in:nN #1#2
   {
     \fp_set:Nn \l_tmpa_fp {#1}
-%    \tl_set:Nf #2 
-%      { 
-%        \fp_eval:n
-%          {
-%            \bool_if:NF \l_@@_unit_is_singlekey_bool
-%              { \l_tmpa_fp * }
-%            \tl_use:c { l_@@_tmpa_ \l_@@_tmp_unit_tl  _ tl }
-%          }
-%      }
     \tl_if_in:cnTF { l_@@_tmpa_ \l_@@_tmp_unit_tl  _ tl } { \l_tmpa_fp }
       { 
         \tl_set:Nf #2 
@@ -2815,23 +3030,24 @@
 %
 %
 %
-% \begin{macro}{\@@_get_number_after_dot:n,\@@_get_number_after_dot_aux:w}
+% \begin{macro}{\@@_check_number_after_dot: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
 %   tokens is greater than significant\_figures\_plus\_one the bool is
 %   set to true (which tells the package later that the number should
-%   be rounded).
+%   be rounded). This should be safe as the input was already checked.
 %    \begin{macrocode}
-\cs_new:Npn \@@_get_number_after_dot:n #1
+\cs_new:Npn \@@_check_number_after_dot:n #1
   {
-    \@@_get_number_after_dot_aux:w #1 . \q_recursion_tail .
+    \@@_check_number_after_dot_aux:w #1 . \q_recursion_tail .
     \q_recursion_stop
   }
-\cs_new:Npn \@@_get_number_after_dot_aux:w #1. #2 .
+\cs_new:Npn \@@_check_number_after_dot_aux:w #1. #2 .
   {
     \quark_if_recursion_tail_stop:n {#2}
-    \int_compare:nNnF { \tl_count:n {#2} } < { \l_@@_significant_figures_plus_one_int }
+    \int_compare:nNnF 
+      { \tl_count:n {#2} } < { \l_@@_significant_figures_plus_one_int }
       { \bool_set_true:N \l_tmpa_bool }
     \use_none_delimit_by_q_recursion_stop:w
   }
@@ -2847,21 +3063,31 @@
 \cs_new:Npn \@@_round_calculated_input:NN #1#2
   {
     \bool_set_false:N \l_tmpa_bool
-    \@@_get_number_after_dot:n {#2}
+    \@@_check_number_after_dot:n {#2}
     \tl_set:Nf #1 
       {  
-        \bool_if:nTF { \l_tmpa_bool || \l_@@_round_to_int_bool }
-          { 
-           \fp_eval:n
-             {
-               \bool_if:NTF \l_@@_round_to_int_bool
-                 { round (#2) }
-                 {
-                   round( #2 , \l_@@_significant_figures_int )
-                 }
-             }
-         }
-         {#2}
+        \bool_if:NTF \l_@@_round_to_int_bool
+          {
+            \fp_eval:n { round (#2) }
+          }{
+            \bool_if:NTF \l_tmpa_bool
+              {
+                \fp_eval:n { round( #2 ,  \@@_round_setup:n {#2} ) }
+              }
+              {#2}
+          }
+%        \bool_if:nTF { \l_tmpa_bool || \l_@@_round_to_int_bool }
+%          { 
+%           \fp_eval:n
+%             {
+%               \bool_if:NTF \l_@@_round_to_int_bool
+%                 { round (#2) }
+%                 {
+%                   round( #2 ,  \@@_round_setup:n {#2} )
+%                 }
+%             }
+%         }
+%         {#2}
      }
   }
 \cs_generate_variant:Nn \@@_round_calculated_input:NN { NV }
@@ -2927,7 +3153,7 @@
 \cs_new_protected:Npn \@@_print_nummerical_output:N #1
   {
 %%    \l_@@_tmpa_tl is sehr gefaehrlich hier.
-    \translatelet \l_@@_tmpa_tl { decimal-mark ( cu-unit name ) }
+    \translatelet \l_@@_tmpa_tl { decimal-mark ( cu-unitname ) }
     \tl_replace_once:NnV #1 { . } \l_@@_tmpa_tl
     \tl_replace_once:NnV #1 { - } \c_@@_minus_tl
     #1
@@ -2971,10 +3197,11 @@
   {
     \tl_set:Nn \l_@@_tmp_unit_tl {#4}
     \@@_error_if_unit_not_defined:V \l_@@_tmp_unit_tl
+    \tl_if_empty:nF {#1}
+      { \keys_set_groups:nnn { cooking-units } { change-unit } {#1} }
     \bool_if:NTF \l_@@_convert_to_eV_bool
       { \@@_convert_to_eV: }
       {
-        \keys_set_groups:nnn { cooking-units } { change-unit } {#1}
         \prop_get:NVN \l_@@_change_unit_prop \l_@@_tmp_unit_tl \l_@@_option_unit_tl
         \quark_if_no_value:NT \l_@@_option_unit_tl  
           { 
@@ -2984,7 +3211,8 @@
           { cooking-units } 
           { change-unit } 
           { l_@@_predefined_option_ \l_@@_option_unit_tl _clist }
-        \keys_set_filter:nnn { cooking-units } { change-unit } {#1}
+        \tl_if_empty:nF {#1}
+          { \keys_set_filter:nnn { cooking-units } { change-unit } {#1} }
       }
     \bool_set_false:N \l_@@_special_sign_bool
     \bool_set_false:N \l_@@_error_bool
@@ -3173,7 +3401,7 @@
 %  \SI{1}{\kg}&=  \SI{1}{\kg} \\
 %  \SI{1}{\kg}&=  \SI{100}{\deka\gram} \\
 %  \SI{1}{\kg}&=  \SI{1000}{\g} \\
-%  \SI{1}{\kg}&=  \SI{35.27399}{oz} \\
+%  \SI{1}{\kg}&=  \SI{35.27399}{oz} 
 % \end{align*}
 %
 % Therefore the property list for \lstinline|kg| contains the keys and values: 
@@ -3188,7 +3416,7 @@
 %  \SI{1}{\deka\gram}&=  \SI{0.01}{\kg} \\
 %  \SI{1}{\deka\gram}&=  \SI{1}{\deka\gram} \\
 %  \SI{1}{\deka\gram}&=  \SI{10}{\g} \\
-%  \SI{1}{\deka\gram}&=  \SI{0.3527399}{\oz} \\
+%  \SI{1}{\deka\gram}&=  \SI{0.3527399}{\oz} 
 % \end{align*}
 %
 % Same for \texttt{g}:
@@ -3197,7 +3425,7 @@
 %  \SI{1}{\g}&=  \SI{0.001}{\kg} \\
 %  \SI{1}{\g}&=  \SI{0.1}{\deka\gram} \\
 %  \SI{1}{\g}&=  \SI{1}{\g} \\
-%  \SI{1}{\g}&=  \SI{0.03527399}{oz} \\
+%  \SI{1}{\g}&=  \SI{0.03527399}{oz} 
 % \end{align*}
 %
 % and \texttt{oz}
@@ -3206,7 +3434,7 @@
 %  \SI{1}{oz}&=  \SI{0.0283495}{\kg} \\
 %  \SI{1}{oz}&=  \SI{2.83495}{\deka\gram} \\
 %  \SI{1}{oz}&=  \SI{28.3495}{\g} \\
-%  \SI{1}{oz}&=  \SI{1}{oz} \\
+%  \SI{1}{oz}&=  \SI{1}{oz} 
 % \end{align*}
 %
 %    \begin{macrocode}
@@ -3218,7 +3446,6 @@
     \prop_put:NnV \l_tmpb_prop { Erstes Ding } \l_@@_tmp_unit_tl
     \clist_map_inline:Nn \l_tmpa_clist 
       {
-        \prop_clear:c { l_@@_cukeys_ ##1 _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
@@ -3271,17 +3498,19 @@
 %    \end{macrocode}
 % \end{macro}
 %
+% \begin{macro}{\@@_cukeys_define_keys_and_single_key_aux:n}
+% 
 %    \begin{macrocode}
 \cs_new:Npn \@@_cukeys_define_keys_and_single_key_aux:n #1
   {
-    \prop_get:cVN 
+    \prop_get:cVc 
       { l_@@_cukeys_#1_prop } 
       \l_keys_choice_tl 
-      \l_tmpa_tl
-    \tl_set:cV { l_@@_tmpa_ #1_tl } \l_tmpa_tl
+      { l_@@_tmpa_ #1_tl }
     \prop_put:NnV \l_@@_change_unit_prop {#1} \l_keys_choice_tl
   }
 %    \end{macrocode}
+% \end{macro}
 %
 %
 %    \begin{macrocode}
@@ -3323,18 +3552,12 @@
 %    \begin{macrocode}
 \cs_new:Npn \@@_cusinglekeys_create_key_prop:n #1
   {
-    \prop_clear:c { l_@@_cukeys_ #1 _prop }
     \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_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:cnn { l_@@_cukeys_ #1 _prop } { Erstes Ding } {#1}
-    \prop_map_inline:Nn \l_tmpa_prop
-      {
-        \prop_put:cnn { l_@@_cukeys_ #1 _prop } 
-          {##1} 
-          {##2} 
-      }
   }
 %    \end{macrocode}
 %
@@ -3370,7 +3593,7 @@
 %
 % \section {Adding Keys}
 %
-%
+% Question to me: Why do we need \cs{l_tmpa(b)_tl}?
 %    \begin{macrocode}
 \NewDocumentCommand \cuaddkeys { m m }
   {
@@ -3462,10 +3685,13 @@
               { \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 }
         \IfNoValueTF {#1}
           {
+            \tl_set:cn { l_@@_cu_unit_ #2 _tl } {#2}
             \newtranslation { #2 ( cu-unit ) } {#2}
           }{
+            \tl_set:cn { l_@@_cu_unit_ #2 _tl } {#1}
             \newtranslation { #2 ( cu-unit ) } {#1}
           }
       }
@@ -3482,6 +3708,7 @@
 \NewDocumentCommand \cutext { O{} m m }
   {
     \group_begin:
+      \bool_set_false:N \l_@@_cutext_uppercase_word_bool
       \@@_cutext_default:nnn {#1} {#2} {#3}
       \@@_cutext_print_correct_unitname:nn {#2} {#3}
     \group_end:
@@ -3505,7 +3732,8 @@
 \cs_new:Npn \@@_cutext_default:nnn #1#2#3
   {
     \@@_error_if_unit_not_defined:n {#3}
-    \keys_set:nn { cooking-units } {#1}
+    \tl_if_empty:nF {#1}
+      { \keys_set:nn { cooking-units } {#1} }
     \bool_if:NT \l_@@_convert_to_eV_bool
       { \@@_convert_to_eV: }
     \bool_if:NTF \l_@@_parse_input_bool
@@ -3515,7 +3743,6 @@
           { 
             \tl_replace_once:NVn \l_tmpb_tl \l_@@_input_range_sign_tl { \q_@@_range } 
             \@@_cutext_parse_range:Vn \l_tmpb_tl {#3} 
-%            \bool_set_true:N \l_@@_parse_range_bool            
           }{
             \@@_cutext_print_nummerical_output:Nn \l_tmpb_tl {#3}
           }
@@ -3544,7 +3771,7 @@
 %    \begin{macrocode}
 \cs_new:Npn \@@_cutext_just_print_number_correctly:N #1
   {
-    \translatelet \l_tmpa_tl { decimal-mark ( cu-unit name ) }
+    \translatelet \l_tmpa_tl { decimal-mark ( cu-unitname ) }
     \tl_replace_once:NnV #1 { . } \l_tmpa_tl
     \tl_replace_once:NnV #1 { - } \c_@@_minus_tl
     #1
@@ -3608,10 +3835,10 @@
 %    \begin{macrocode}
 \NewDocumentCommand \cufrac { O{} m }
   {
-    \msg_error:nnnn { cooking-units } { obsolete-command } { \cufrac }
-      { \cuam }
+    \msg_error:nnnn { cooking-units } { obsolete-command } { \cufrac } { \cuam }
     \group_begin:
-    \keys_set:nn { cooking-units } {#1}
+    \tl_if_empty:nF {#1}
+      { \keys_set:nn { cooking-units } {#1} }
     \@@_cufrac:n {#2}
     \group_end:
   }
@@ -3670,11 +3897,14 @@
 % Replaces and extends \mycs{cufrac}.
 % \begin{macro}{\cuam}
 %    \begin{macrcode}
-\NewDocumentCommand \cuam { O{} m }
+\NewDocumentCommand \cuam { s O{} m }
   {
     \group_begin:
-    \keys_set:nn { cooking-units } {#1}
-    \@@_cuam:n {#2}
+    \tl_if_empty:nF {#2}
+      { \keys_set:nn { cooking-units } {#2} }
+    \IfBooleanTF {#1}
+      { \@@_cuam_star:n {#3} }
+      { \@@_cuam_star:n {#3} }
     \group_end:
   }
 %    \end{macrcode}
@@ -3682,7 +3912,7 @@
 %
 % \begin{macro}{\@@_cuam:n}
 %    \begin{macrocode}
-\cs_new:Npn \@@_cuam:n #1
+\cs_new:Npn \@@_cuam_star:n #1
   {
     \tl_set_rescan:Nnn \l_tmpa_tl
       {
@@ -3689,42 +3919,42 @@
         \char_set_catcode_letter:N \_ %
         \char_set_catcode_ignore:N\ %
       } {#1}
-    \@@_cuam_parse:V \l_tmpa_tl
+    \@@_cuam_star_parse:V \l_tmpa_tl
   }
 %    \end{macrocode}
 % \end{macro}
 %
 %    \begin{macrocode}
-\cs_new_protected:Npn \@@_cuam_parse:n #1
+\cs_new_protected:Npn \@@_cuam_star_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_parse_range:V \l_tmpa_tl
+        \@@_cuam_star_parse_range:V \l_tmpa_tl
       }{
         \tl_if_in:nnTF {#1} { / }
           {
             \tl_if_in:nnTF {#1} { _ }
-              { \@@_cuam_parse_mixed_frac:www #1 \q_stop }
-              { \@@_cuam_parse_frac:ww #1 \q_stop }
+              { \@@_cuam_star_parse_mixed_frac:www #1 \q_stop }
+              { \@@_cuam_star_parse_frac:ww #1 \q_stop }
           }{ 
             \tl_if_in:nnTF {#1} { _ }
               { \msg_error:nnn { cooking-units } { missing-slash } {#1} }
-              { \@@_cuam_parse_scale:n {#1} }
+              { \@@_cuam_star_parse_scale:n {#1} }
           }
       }
   }
-\cs_generate_variant:Nn \@@_cuam_parse:n { V }
+\cs_generate_variant:Nn \@@_cuam_star_parse:n { V }
 %    \end{macrocode}
 %
 %    \begin{macrocode}
-\cs_new:Npn \@@_cuam_parse_range:n #1
+\cs_new:Npn \@@_cuam_star_parse_range:n #1
   {
-    \@@_cuam_parse_range_aux:ww #1 \q_nil
+    \@@_cuam_star_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
+\cs_generate_variant:Nn \@@_cuam_star_parse_range:n { V }
+\cs_new:Npn \@@_cuam_star_parse_range_aux:ww #1 \q_@@_range #2 \q_nil
   {
     #1 \l_@@_cunum_range_sign_tl #2
   }
@@ -3732,16 +3962,16 @@
 %
 %
 %    \begin{macrocode}
-\cs_new:Npn \@@_cuam_parse_scale:n #1 {#1}
+\cs_new:Npn \@@_cuam_star_parse_scale:n #1 {#1}
 %    \end{macrocode}
 %
 %    \begin{macrocode}
-\cs_new:Npn \@@_cuam_parse_frac:ww #1/#2 \q_stop
+\cs_new:Npn \@@_cuam_star_parse_frac:ww #1/#2 \q_stop
   { \@@_frac:nn {#1} {#2} }
 %    \end{macrocode}
 %
 %    \begin{macrocode}
-\cs_new:Npn \@@_cuam_parse_mixed_frac:www #1_#2/#3 \q_stop
+\cs_new:Npn \@@_cuam_star_parse_mixed_frac:www #1_#2/#3 \q_stop
   { 
     #1 
     \hbox_to_wd:nn { \l_@@_mixed_frac_dim } { } 
@@ -3766,8 +3996,13 @@
 \cs_new:Npn \@@_cuname_parse_input:n #1
   {
     \peek_meaning_ignore_spaces:NTF [
-      { \@@_cuname_parse_unit_symbol:nw {#1} }
-      { \@@_cuname_parse_input_aux:nn {#1} }
+      { 
+        \@@_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}
 %
@@ -3778,8 +4013,14 @@
     \quark_if_recursion_tail_stop_do:nn {#2} 
       { \msg_error:nn { cooking-units } { missing-argument } }
     \@@_error_if_unit_not_defined:n {#1}
-%    \deftranslation [ to=\l_@@_language_tl ] { #1 ( cu-unit ) } {#2}
-    \@@_deftranslation:Vnn \l_@@_language_tl { #1 ( cu-unit ) } {#2}
+    \quark_if_no_value:nTF {#2}
+      {
+        \@@_deftranslation:Vnv 
+          \l_@@_language_tl { #1 ( cu-unit ) } { l_@@_cu_unit_ #1 _tl }
+      }
+      { 
+        \@@_deftranslation:Vnn \l_@@_language_tl { #1 ( cu-unit ) } {#2} 
+      }
     \@@_cuname_parse_input_aux:nn {#1}
   }
 %    \end{macrocode}
@@ -3793,7 +4034,6 @@
       { \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 [ to=\l_@@_language_tl ] { #1 (cu-unitname) }  {#2}
     \@@_deftranslation:Vnn \l_@@_language_tl { #1 ( cu-unitname ) } {#2}
     \peek_meaning_ignore_spaces:NTF [
       { \@@_cuname_parse_bracket:nw {#1} }
@@ -3805,7 +4045,10 @@
 \cs_new:Npn \@@_cuname_parse_bracket:nw #1 [#2]
   {
 %    \deftranslation [ to=\l_@@_language_tl ] { #1 ( cu-unitname pl ) } {#2}
-    \@@_deftranslation:Vnn \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}
+      }
     \peek_meaning_ignore_spaces:NTF <
       { \@@_cuname_parse_arrows:nw {#1} }
       { \@@_cuname_parse_arrows:nw {#1} <m> }
@@ -3841,10 +4084,13 @@
     \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 [ to=\l_@@_language_tl ] { #1 ( cu-unit ) } {#2}
-    \@@_deftranslation:Vnn \l_@@_language_tl { #1 ( cu-unit ) } {#2}
+    \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}
@@ -4093,7 +4339,8 @@
     { m } { m\`{e}tre } [ m\`{e}tres ]
     { dm } { d\'{e}cim\`{e}tre } [ d\'{e}cim\`{e}tres ]
     { cm } { centim\`{e}tre } [ centim\`{e}tres ]
-    { mm } { millim\`{e}tre } [ millim\`{e}tre ]
+    { mm } { millim\`{e}tre } [ millim\`{e}tres ]
+    { in } [ po ] { pouce } [ pouces ]
 %    \end{macrocode}
 %    \begin{macrocode}
     { l } [ L ] { litre } [ litres ]

Modified: trunk/Master/texmf-dist/tex/latex/cooking-units/cooking-units.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/cooking-units/cooking-units.sty	2016-10-28 20:57:14 UTC (rev 42371)
+++ trunk/Master/texmf-dist/tex/latex/cooking-units/cooking-units.sty	2016-10-28 20:57:39 UTC (rev 42372)
@@ -30,8 +30,8 @@
   { \RequirePackage {expl3} }
 \ProvidesExplPackage
   {cooking-units}
-  {2016/09/26}
-  {1.03b}
+  {2016/10/19}
+  {1.04}
   {Ein Paket fuer Kocheinheiten}
 \@ifpackagelater { expl3 } { 2016/05/18 }
   { }
@@ -69,7 +69,7 @@
 \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_new_eq:NN \__cooking_units_frac:nn \sfrac
 \prop_new:N \l__cooking_units_change_unit_prop
 \tl_new:N \l__cooking_units_tmpa_tl
@@ -210,6 +210,7 @@
     temperature-to-check .value_required:n = { true } ,
     convert-to-eV .bool_set:N = \l__cooking_units_convert_to_eV_bool ,
     convert-to-eV .default:n = { true } ,
+    convert-to-eV .groups:n = { change-unit } ,
     use-numerals-below .int_set:N = \l__cooking_units_print_numerals_below_int ,
     use-numerals-below .default:n = { 13 } ,
     set-unknown-message .choices:nn =
@@ -226,6 +227,23 @@
             \clist_clear:c { l__cooking_units_predefined_option_##1_clist }
           }
         },
+    round-half .choices:nn =
+      { default , commercial }
+      {
+        \cs_set:Npx \__cooking_units_round_setup:n ####1
+          {
+            \exp_not:N \l__cooking_units_significant_figures_int
+            \int_case:nn { \l_keys_choice_int }
+              {
+                { 1 } { }
+                { 2 } { \exp_not:N, ####1 }
+              }
+          }
+      },
+    round-half .default:n = { default },
+    label .code:n = { \label{cooking-units-#1} } ,
+    for-persons .int_set:N = \l__cooking_units_number_of_persons_int ,
+    for-persons .default:n = { 4 } ,
   }
 \msg_new:nnnn { cooking-units } { fraction-not-allowed-with-range }
   {
@@ -319,13 +337,13 @@
   }
   {
     You \ used\  a\  special\  sign\  indicating\  that\  the\  true\  amount\  of\  the\
-    specific\  ingredient\  is\  (was) not\  known\  to\  you. This\  message\
+    specific\  ingredient\  is\  (was) \ not\  known\  to\  you. This\  message\
     reminds\  you\  about\  that\  fact.
     \msg_see_documentation_text:n {cooking-units}
   }
 \msg_new:nnnn { cooking - units } { load-time-option }
   {
-    The \ option \ '#1' \ is \ only \ avaiable \ as \ a \ load-time-option. \
+    The \ option \ '#1' \ is \ only \ available \ as \ a \ load-time-option. \
     Please \ set \ it \ as \ a \ package \ option.
   }
   {
@@ -347,6 +365,8 @@
     'check-temperature'.
   }
   {
+    A \ minimum \ value \ is \ needed \ for \ testing \ if \
+    'check-temperature' \ is \ active.
     \msg_see_documentation_text:n { cooking-units }
   }
 \msg_new:nnnn { cooking - units } { Minimum-already-defined }
@@ -424,7 +444,7 @@
   {
     \deftranslation [ to=#1 ] { #2 } {#3}
   }
-\cs_generate_variant:Nn \__cooking_units_deftranslation:Nnn { Vnn }
+\cs_generate_variant:Nn \__cooking_units_deftranslation:Nnn { Vnn , Vnv }
 \cs_new:Npn \__cooking_units_temperature_to_check_print_error:n #1
   {
     \msg_error:nn { cooking-units } { No-Value-given }
@@ -439,6 +459,7 @@
         \fp_const:cn { c__cooking_units_ #1 _min_fp } {#2}
       }
   }
+\cs_new:Npn \__cooking_units_round_setup:n #1 { \l__cooking_units_significant_figures_int }
 \cs_new:Npn \__cooking_units_cunum_parse_input:N #1
   {
     \bool_if:NTF \l__cooking_units_parse_range_bool
@@ -601,15 +622,16 @@
     \__cooking_units_round_calculated_input:NV #2 #2
   }
 \cs_generate_variant:Nn \__cooking_units_calculate_input_and_store_in:nN { V }
-\cs_new:Npn \__cooking_units_get_number_after_dot:n #1
+\cs_new:Npn \__cooking_units_check_number_after_dot:n #1
   {
-    \__cooking_units_get_number_after_dot_aux:w #1 . \q_recursion_tail .
+    \__cooking_units_check_number_after_dot_aux:w #1 . \q_recursion_tail .
     \q_recursion_stop
   }
-\cs_new:Npn \__cooking_units_get_number_after_dot_aux:w #1. #2 .
+\cs_new:Npn \__cooking_units_check_number_after_dot_aux:w #1. #2 .
   {
     \quark_if_recursion_tail_stop:n {#2}
-    \int_compare:nNnF { \tl_count:n {#2} } < { \l__cooking_units_significant_figures_plus_one_int }
+    \int_compare:nNnF
+      { \tl_count:n {#2} } < { \l__cooking_units_significant_figures_plus_one_int }
       { \bool_set_true:N \l_tmpa_bool }
     \use_none_delimit_by_q_recursion_stop:w
   }
@@ -616,21 +638,19 @@
 \cs_new:Npn \__cooking_units_round_calculated_input:NN #1#2
   {
     \bool_set_false:N \l_tmpa_bool
-    \__cooking_units_get_number_after_dot:n {#2}
+    \__cooking_units_check_number_after_dot:n {#2}
     \tl_set:Nf #1
       {
-        \bool_if:nTF { \l_tmpa_bool || \l__cooking_units_round_to_int_bool }
+        \bool_if:NTF \l__cooking_units_round_to_int_bool
           {
-           \fp_eval:n
-             {
-               \bool_if:NTF \l__cooking_units_round_to_int_bool
-                 { round (#2) }
-                 {
-                   round( #2 , \l__cooking_units_significant_figures_int )
-                 }
-             }
-         }
-         {#2}
+            \fp_eval:n { round (#2) }
+          }{
+            \bool_if:NTF \l_tmpa_bool
+              {
+                \fp_eval:n { round( #2 ,  \__cooking_units_round_setup:n {#2} ) }
+              }
+              {#2}
+          }
      }
   }
 \cs_generate_variant:Nn \__cooking_units_round_calculated_input:NN { NV }
@@ -667,7 +687,7 @@
 \cs_new_protected:Npn \__cooking_units_print_nummerical_output:N #1
   {
 %%    \l_@@_tmpa_tl is sehr gefaehrlich hier.
-    \translatelet \l__cooking_units_tmpa_tl { decimal-mark ( cu-unit name ) }
+    \translatelet \l__cooking_units_tmpa_tl { decimal-mark ( cu-unitname ) }
     \tl_replace_once:NnV #1 { . } \l__cooking_units_tmpa_tl
     \tl_replace_once:NnV #1 { - } \c__cooking_units_minus_tl
     #1
@@ -685,10 +705,11 @@
   {
     \tl_set:Nn \l__cooking_units_tmp_unit_tl {#4}
     \__cooking_units_error_if_unit_not_defined:V \l__cooking_units_tmp_unit_tl
+    \tl_if_empty:nF {#1}
+      { \keys_set_groups:nnn { cooking-units } { change-unit } {#1} }
     \bool_if:NTF \l__cooking_units_convert_to_eV_bool
       { \__cooking_units_convert_to_eV: }
       {
-        \keys_set_groups:nnn { cooking-units } { change-unit } {#1}
         \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
           {
@@ -698,7 +719,8 @@
           { cooking-units }
           { change-unit }
           { l__cooking_units_predefined_option_ \l__cooking_units_option_unit_tl _clist }
-        \keys_set_filter:nnn { cooking-units } { change-unit } {#1}
+        \tl_if_empty:nF {#1}
+          { \keys_set_filter:nnn { cooking-units } { change-unit } {#1} }
       }
     \bool_set_false:N \l__cooking_units_special_sign_bool
     \bool_set_false:N \l__cooking_units_error_bool
@@ -801,7 +823,6 @@
     \prop_put:NnV \l_tmpb_prop { Erstes Ding } \l__cooking_units_tmp_unit_tl
     \clist_map_inline:Nn \l_tmpa_clist
       {
-        \prop_clear:c { l__cooking_units_cukeys_ ##1 _prop }
         \prop_set_eq:cN { l__cooking_units_cukeys_ ##1 _prop } \l_tmpb_prop
         \tl_set_eq:cN   { l__cooking_units_tmpa_ ##1 _tl } \c_one_fp
         \clist_map_inline:Nn \l_tmpa_clist
@@ -846,11 +867,10 @@
 \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
   {
-    \prop_get:cVN
+    \prop_get:cVc
       { l__cooking_units_cukeys_#1_prop }
       \l_keys_choice_tl
-      \l_tmpa_tl
-    \tl_set:cV { l__cooking_units_tmpa_ #1_tl } \l_tmpa_tl
+      { l__cooking_units_tmpa_ #1_tl }
     \prop_put:NnV \l__cooking_units_change_unit_prop {#1} \l_keys_choice_tl
   }
 \cs_new:Npn \__cooking_units_cukeys_parse_and_create_single_key:nn #1#2
@@ -884,17 +904,11 @@
   }
 \cs_new:Npn \__cooking_units_cusinglekeys_create_key_prop:n #1
   {
-    \prop_clear:c { l__cooking_units_cukeys_ #1 _prop }
     \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_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:cnn { l__cooking_units_cukeys_ #1 _prop } { Erstes Ding } {#1}
-    \prop_map_inline:Nn \l_tmpa_prop
-      {
-        \prop_put:cnn { l__cooking_units_cukeys_ #1 _prop }
-          {##1}
-          {##2}
-      }
   }
 \cs_new:Npn \__cooking_units_cukeys_define_singlekey:nN #1#2
   {
@@ -984,10 +998,13 @@
               { \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 }
         \IfNoValueTF {#1}
           {
+            \tl_set:cn { l__cooking_units_cu_unit_ #2 _tl } {#2}
             \newtranslation { #2 ( cu-unit ) } {#2}
           }{
+            \tl_set:cn { l__cooking_units_cu_unit_ #2 _tl } {#1}
             \newtranslation { #2 ( cu-unit ) } {#1}
           }
       }
@@ -995,6 +1012,7 @@
 \NewDocumentCommand \cutext { O{} m m }
   {
     \group_begin:
+      \bool_set_false:N \l__cooking_units_cutext_uppercase_word_bool
       \__cooking_units_cutext_default:nnn {#1} {#2} {#3}
       \__cooking_units_cutext_print_correct_unitname:nn {#2} {#3}
     \group_end:
@@ -1010,7 +1028,8 @@
 \cs_new:Npn \__cooking_units_cutext_default:nnn #1#2#3
   {
     \__cooking_units_error_if_unit_not_defined:n {#3}
-    \keys_set:nn { cooking-units } {#1}
+    \tl_if_empty:nF {#1}
+      { \keys_set:nn { cooking-units } {#1} }
     \bool_if:NT \l__cooking_units_convert_to_eV_bool
       { \__cooking_units_convert_to_eV: }
     \bool_if:NTF \l__cooking_units_parse_input_bool
@@ -1041,7 +1060,7 @@
   }
 \cs_new:Npn \__cooking_units_cutext_just_print_number_correctly:N #1
   {
-    \translatelet \l_tmpa_tl { decimal-mark ( cu-unit name ) }
+    \translatelet \l_tmpa_tl { decimal-mark ( cu-unitname ) }
     \tl_replace_once:NnV #1 { . } \l_tmpa_tl
     \tl_replace_once:NnV #1 { - } \c__cooking_units_minus_tl
     #1
@@ -1088,10 +1107,10 @@
   }
 \NewDocumentCommand \cufrac { O{} m }
   {
-    \msg_error:nnnn { cooking-units } { obsolete-command } { \cufrac }
-      { \cuam }
+    \msg_error:nnnn { cooking-units } { obsolete-command } { \cufrac } { \cuam }
     \group_begin:
-    \keys_set:nn { cooking-units } {#1}
+    \tl_if_empty:nF {#1}
+      { \keys_set:nn { cooking-units } {#1} }
     \__cooking_units_cufrac:n {#2}
     \group_end:
   }
@@ -1127,14 +1146,17 @@
     \hbox_to_wd:nn { \l__cooking_units_mixed_frac_dim } { }
     \__cooking_units_frac:nn {#2} {#3}
   }
-\NewDocumentCommand \cuam { O{} m }
+\NewDocumentCommand \cuam { s O{} m }
   {
     \group_begin:
-    \keys_set:nn { cooking-units } {#1}
-    \__cooking_units_cuam:n {#2}
+    \tl_if_empty:nF {#2}
+      { \keys_set:nn { cooking-units } {#2} }
+    \IfBooleanTF {#1}
+      { \__cooking_units_cuam_star:n {#3} }
+      { \__cooking_units_cuam_star:n {#3} }
     \group_end:
   }
-\cs_new:Npn \__cooking_units_cuam:n #1
+\cs_new:Npn \__cooking_units_cuam_star:n #1
   {
     \tl_set_rescan:Nnn \l_tmpa_tl
       {
@@ -1141,42 +1163,42 @@
         \char_set_catcode_letter:N \_ %
         \char_set_catcode_ignore:N\ %
       } {#1}
-    \__cooking_units_cuam_parse:V \l_tmpa_tl
+    \__cooking_units_cuam_star_parse:V \l_tmpa_tl
   }
-\cs_new_protected:Npn \__cooking_units_cuam_parse:n #1
+\cs_new_protected:Npn \__cooking_units_cuam_star_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_parse_range:V \l_tmpa_tl
+        \__cooking_units_cuam_star_parse_range:V \l_tmpa_tl
       }{
         \tl_if_in:nnTF {#1} { / }
           {
             \tl_if_in:nnTF {#1} { _ }
-              { \__cooking_units_cuam_parse_mixed_frac:www #1 \q_stop }
-              { \__cooking_units_cuam_parse_frac:ww #1 \q_stop }
+              { \__cooking_units_cuam_star_parse_mixed_frac:www #1 \q_stop }
+              { \__cooking_units_cuam_star_parse_frac:ww #1 \q_stop }
           }{
             \tl_if_in:nnTF {#1} { _ }
               { \msg_error:nnn { cooking-units } { missing-slash } {#1} }
-              { \__cooking_units_cuam_parse_scale:n {#1} }
+              { \__cooking_units_cuam_star_parse_scale:n {#1} }
           }
       }
   }
-\cs_generate_variant:Nn \__cooking_units_cuam_parse:n { V }
-\cs_new:Npn \__cooking_units_cuam_parse_range:n #1
+\cs_generate_variant:Nn \__cooking_units_cuam_star_parse:n { V }
+\cs_new:Npn \__cooking_units_cuam_star_parse_range:n #1
   {
-    \__cooking_units_cuam_parse_range_aux:ww #1 \q_nil
+    \__cooking_units_cuam_star_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
+\cs_generate_variant:Nn \__cooking_units_cuam_star_parse_range:n { V }
+\cs_new:Npn \__cooking_units_cuam_star_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_parse_scale:n #1 {#1}
-\cs_new:Npn \__cooking_units_cuam_parse_frac:ww #1/#2 \q_stop
+\cs_new:Npn \__cooking_units_cuam_star_parse_scale:n #1 {#1}
+\cs_new:Npn \__cooking_units_cuam_star_parse_frac:ww #1/#2 \q_stop
   { \__cooking_units_frac:nn {#1} {#2} }
-\cs_new:Npn \__cooking_units_cuam_parse_mixed_frac:www #1_#2/#3 \q_stop
+\cs_new:Npn \__cooking_units_cuam_star_parse_mixed_frac:www #1_#2/#3 \q_stop
   {
     #1
     \hbox_to_wd:nn { \l__cooking_units_mixed_frac_dim } { }
@@ -1191,8 +1213,13 @@
 \cs_new:Npn \__cooking_units_cuname_parse_input:n #1
   {
     \peek_meaning_ignore_spaces:NTF [
-      { \__cooking_units_cuname_parse_unit_symbol:nw {#1} }
-      { \__cooking_units_cuname_parse_input_aux:nn {#1} }
+      {
+        \__cooking_units_cuname_parse_unit_symbol:nw {#1}
+      }{
+        \clist_if_in:NnTF \g__cooking_units_allowed_unit_phrases_clist {#1}
+          { \__cooking_units_cuname_parse_input_aux:nn {#1} }
+          { \__cooking_units_cuname_parse_unit_symbol:nw {#1} [ \q_no_value ] }
+      }
   }
 \cs_new:Npn \__cooking_units_cuname_parse_unit_symbol:nw #1 [#2]
   {
@@ -1200,7 +1227,14 @@
     \quark_if_recursion_tail_stop_do:nn {#2}
       { \msg_error:nn { cooking-units } { missing-argument } }
     \__cooking_units_error_if_unit_not_defined:n {#1}
-    \__cooking_units_deftranslation:Vnn \l__cooking_units_language_tl { #1 ( cu-unit ) } {#2}
+    \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_cuname_parse_input_aux:nn {#1}
   }
 \cs_new:Npn \__cooking_units_cuname_parse_input_aux:nn #1#2
@@ -1217,7 +1251,10 @@
   }
 \cs_new:Npn \__cooking_units_cuname_parse_bracket:nw #1 [#2]
   {
-    \__cooking_units_deftranslation:Vnn \l__cooking_units_language_tl { #1 ( cu-unitname pl ) } {#2}
+    \clist_if_in:NnF \g__cooking_units_allowed_unit_phrases_clist {#1}
+      {
+        \__cooking_units_deftranslation:Vnn \l__cooking_units_language_tl { #1 ( cu-unitname pl ) } {#2}
+      }
     \peek_meaning_ignore_spaces:NTF <
       { \__cooking_units_cuname_parse_arrows:nw {#1} }
       { \__cooking_units_cuname_parse_arrows:nw {#1} <m> }
@@ -1238,9 +1275,13 @@
     \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}
-      { \__cooking_units_error_if_unit_not_defined:n {#1} }
-    \__cooking_units_deftranslation:Vnn \l__cooking_units_language_tl { #1 ( cu-unit ) } {#2}
+    \clist_if_in:NnTF \g__cooking_units_allowed_unit_phrases_clist {#1}
+      {
+        \__cooking_units_deftranslation:Vnn \l__cooking_units_language_tl { #1 ( cu-unitname ) } {#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_cuprint_define_printed_unit:nn
   }
 \NewDocumentCommand \cusetup { m }
@@ -1401,7 +1442,8 @@
     { m } { m\`{e}tre } [ m\`{e}tres ]
     { dm } { d\'{e}cim\`{e}tre } [ d\'{e}cim\`{e}tres ]
     { cm } { centim\`{e}tre } [ centim\`{e}tres ]
-    { mm } { millim\`{e}tre } [ millim\`{e}tre ]
+    { mm } { millim\`{e}tre } [ millim\`{e}tres ]
+    { in } [ po ] { pouce } [ pouces ]
     { l } [ L ] { litre } [ litres ]
     { dl } [ dL ] { d\'{e}cilitre } [ d\'{e}cilitres ]
     { cl } [ cL ] { centilitre } [ centilitres ]



More information about the tex-live-commits mailing list