summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/cooking-units/cooking-units.sty
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/tex/latex/cooking-units/cooking-units.sty')
-rw-r--r--Master/texmf-dist/tex/latex/cooking-units/cooking-units.sty1373
1 files changed, 1373 insertions, 0 deletions
diff --git a/Master/texmf-dist/tex/latex/cooking-units/cooking-units.sty b/Master/texmf-dist/tex/latex/cooking-units/cooking-units.sty
new file mode 100644
index 00000000000..af9dbde6fbf
--- /dev/null
+++ b/Master/texmf-dist/tex/latex/cooking-units/cooking-units.sty
@@ -0,0 +1,1373 @@
+%%
+%% This is file `cooking-units.sty',
+%% generated with the docstrip utility.
+%%
+%% The original source files were:
+%%
+%% cooking-units.dtx (with options: `package')
+%% Copyright (C) 2016 by Ben Vitecek (current Maintainer)
+%%
+%% This file may be distributed and/or modified under the
+%% conditions of the LaTeX Project Public License, either
+%% version 1.3 of this license or (at your option) any later
+%% 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
+%% LaTeX version 2008-05-04 or later.
+%%
+%% This work has the LPPL maintenance status `maintained'.
+%%
+%% This work consists of the files README, cooking-units.dtx and cooking-units.ins
+%% and the derived file cooking-units.sty.
+%%
+\@ifpackageloaded {xparse}
+ { }
+ { \RequirePackage {xparse} }
+\@ifpackageloaded {expl3}
+ { }
+ { \RequirePackage {expl3} }
+\ProvidesExplPackage
+ {cooking-units}
+ {2016/08/31}
+ {1.00}
+ {Ein Paket fuer Kocheinheiten}
+\@ifpackagelater { expl3 } { 2016/05/18 }
+ { }
+ {
+ \PackageError { cooking-units } { Support~package~expl3~too~old }
+ {
+ You~need~to~update~your~installation~of~the~bundles~'l3kernel'~and~
+ 'l3packages'.\MessageBreak
+ Loading~cooking-units~will~abort!
+ }
+ \tex_endinput:D
+ }
+\@ifpackageloaded { translator } { } { \RequirePackage { translator } }
+\@ifpackageloaded { xfrac } { } { \RequirePackage { xfrac } }
+\@ifpackageloaded { l3keys2e } { } { \RequirePackage { l3keys2e } }
+\bool_new:N \g__cooking_units_load_if_opt_numeral_bool
+\keys_define:nn { cooking-units }
+ {
+ use-numerals .bool_gset:N = \g__cooking_units_load_if_opt_numeral_bool ,
+ use-numerals .default:n = { false },
+ }
+\ProcessKeysOptions { cooking-units }
+\bool_if:NT \g__cooking_units_load_if_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 } ,
+ }
+\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:nnT { nVT }
+\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_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
+\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_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_range_sign_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_set:Nn \l__cooking_units_input_digits_tl { 0123456789 }
+\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
+ { \char_set_catcode_letter:N \# } {#1}
+\AtBeginDocument {
+ \cs_if_free:cT { T@TS1 }
+ {
+ \DeclareFontEncoding { TS1 } { } { }
+ \DeclareFontSubstitution { TS1 } { cmr } { m } { n }
+ }
+}
+\DeclareTextSymbolDefault \c__cooking_units_minus_tl { TS1 }
+\DeclareTextSymbol \c__cooking_units_minus_tl { TS1 } { 61 }
+\AtBeginDocument {
+ \@ifpackageloaded { fontspec }
+ {
+ \@ifpackageloaded { eulervm }
+ { }
+ {
+ \int_const:Nn \c__cooking_units_minus_int { 8722 }
+ \tl_set:Nn \c__cooking_units_minus_tl
+ { \tex_char:D \c__cooking_units_minus_int }
+ }
+ }
+ { }
+}
+\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_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 }
+\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
+\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_set_true:N \l__cooking_units_parse_input_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 }
+\keys_define:nn { cooking - units }
+ {
+ eval-fraction .bool_set:N = \l__cooking_units_eval_fractions_bool ,
+ eval-fraction .default:n = { false } ,
+ round-precision .code:n =
+ {
+ \int_set:Nn \l__cooking_units_significant_figures_int {#1}
+ \int_set:Nn \l__cooking_units_significant_figures_plus_one_int { #1 + \c_one }
+ } ,
+ round-precision .default:n = { 2 } ,
+ round-to-int .bool_set:N = \l__cooking_units_round_to_int_bool ,
+ round-to-int .default:n = { false } ,
+ range-sign .meta:n =
+ {
+ cunum-range-sign = {#1} ,
+ cutext-range-sign = {#1}
+ } ,
+ range-sign .default:n = { -- } ,
+ cunum-range-sign .tl_set:N = \l__cooking_units_cunum_range_sign_tl ,
+ 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 } ,
+ 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} } ,
+ 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 .default:n = { } ,
+ set-special-sign .tl_set:N = \l__cooking_units_allowed_special_signs_tl ,
+ 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 ,
+ check-temperature .default:n = { true } ,
+ convert-to-eV .bool_set:N = \l__cooking_units_convert_to_eV_bool ,
+ convert-to-eV .default:n = { true } ,
+ use-numerals-below .int_set:N = \l__cooking_units_print_numerals_below_int ,
+ use-numerals-below .default:n = { 13 } ,
+ set-unknown-message .choices:nn =
+ { error , warning , none }
+ {
+ \msg_redirect_name:nnn { cooking-units } { amount-not-known }
+ { \l_keys_choice_tl }
+ } ,
+ set-unknown-message .default:n = { warning } ,
+ erase-all-options .code:n =
+ {
+ \clist_map_inline:Nn \g__cooking_units_list_of_defined_units_clist
+ {
+ \clist_clear:c { l__cooking_units_predefined_option_##1_clist }
+ }
+ },
+ }
+\msg_new:nnnn { cooking-units } { fraction-not-allowed-with-range }
+ {
+ 'You' \ cannot \ use \ '/' \ ( and \ '_' )\ in \ combination \
+ with \ '\l__cooking_units_input_range_sign_tl' \ in \ '#1'.
+ }{
+ You \ cannot \ use \ fractions \ with \ a \ range.
+ \msg_see_documentation_text:n { cooking-units }
+ }
+\msg_new:nnnn { cooking-units } { missing-slash }
+ {
+ You \ cannot \ use \ '_' \ without \
+ '/' in '#1'.
+ }{
+ You \ cannot \ have \ a \ mixed \ fraction \ ('_') \ without \
+ a \ normal \ fraction \ ('/').
+ \msg_see_documentation_text:n { cooking-units }
+ }
+\msg_new:nnnn { cooking-units } { unknown - unit }
+ {
+ The \ unit \ '#1' \ is \ not \ defined. \ Use \
+ \newcookingunit \ to \ define \ new \ units.
+ }{
+ Define \ units \ before \ using \ or \ check \ if \ the \
+ unit-key \ is \ written \ correctly.
+ \msg_see_documentation_text:n { cooking-units }
+ }
+\msg_new:nnnn { cooking - units } { unit-already-defined }
+ { The\ unit \ '#1' \ is \ already \ defined. }
+ {
+ The \ unit-key \ is \ already \ defined. \ Please \ use \ a \ different \
+ key \ for \ a \ new \ unit.
+ \msg_see_documentation_text:n {cooking-units}
+ }
+\msg_new:nnnn { cooking - units } { missing-argument }
+ { There \ is \ an \ missing \ argument. }
+ {
+ You \ probably \ have \ forgotten \ a \ curly-brace \ pair.
+ \msg_see_documentation_text:n {cooking-units}
+ }
+\msg_new:nnnn { cooking - units } { Division-by-zero }
+ { Division\ by \ zero \ is \ not \ allowed. }
+ { See \ a \ math \ book \ of \ your \ choice \ or \ for \ example \ Wikipedia. }
+\msg_new:nnnn { cooking - units } { Token-not-allowed }
+ { The \ token \ '#1' \ is \ not \ allowed. }
+ {
+ 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 }
+ { 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 }
+ {
+ The \ key \ '#1' \ is \ not \ defined. \ Use \ \cudefinekeys or \
+ \cudefinesinglekey to \ define \ keys.
+ }
+ {
+ This \ key \ is \ not \ defined, \ perhaps \ you \ misspelled \ it.
+ \msg_see_documentation_text:n {cooking-units}
+ }
+\msg_new:nnnn { cooking - units } { Temperature-to-low }
+ {
+ The \ temperature \ '#1' \ is \ to \ low.\ It \ cannot \ be \
+ below \ the \ absolute \ zero - point \ of \ '#2'. \ Note \ that \
+ by \ default \ the \ temperatures \ 'C', \ 'F' , \ 'K' \ and \ 'Re' \
+ are \ rounded \ to \ integers.
+ \\\\
+ You \ can \ disable \ the \ option \ 'check-temperature' \ to \
+ disable \ this \ error.
+ }
+ { See \ for \ example \ Wikipedia. }
+\msg_new:nnnn { cooking - units } { key-choice-unknown }
+ {
+ The \ key \ '#1' \ only \ accepts \ only \
+ '#3' \ as \ a \ set \ of \ choices \ and \ '#2' \ is \ non \ of \ these.
+ }
+ {
+ The \ key \ accepts \ accepts\ only \ a \ fixed \ set \ of \ choices. \
+ You \ can \ add \ new \ choices \ via \ \cuaddkeys, \ \cuaddsinglekeys \
+ and \ \cuaddtokeys.
+ \msg_see_documentation_text:n {cooking-units}
+ }
+\msg_new:nnnn { cooking - units } { amount-not-known }
+ {
+ The \ amount \ of \ #1 \ is \ not \ known \ at \ line \
+ \msg_line_number: .
+ }
+ {
+ You \ used\ a\ special\ sign\ indicating\ that\ the\ true\ amount\ of\ the\
+ 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. \
+ Please \ set \ it \ as \ a \ package \ option.
+ }
+ {
+ You \ cannot \ set \ this \ option \ using \ \cusetup \
+ but \ only \ as \ a \ package \ option.
+ \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}
+ { \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_and_parse:n #1 { TF }
+ {
+ \bool_if:NTF \l__cooking_units_parse_input_bool
+ {
+ \tl_map_inline:nn {#1}
+ {
+ \tl_if_in:NnF \l__cooking_units_input_digits_tl {##1}
+ {
+ \tl_map_break:n { \use_iii:nnn }
+ }
+ }
+ \use_i:nn \prg_return_true: \prg_return_false:
+ }
+ { \prg_return_false: }
+ }
+\cs_generate_variant:Nn \__cooking_units_if_integer_and_parse:nTF { V }
+\cs_new:Npn \__cooking_units_convert_to_eV:
+ {
+ \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 ,
+ }
+ \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_filter:nnv
+ { cooking-units }
+ { change-unit }
+ { l__cooking_units_predefined_option_ \l__cooking_units_option_unit_tl _clist }
+ }
+\cs_new:Npn \__cooking_units_cunum_parse_input:N #1
+ {
+ \tl_if_in:nnTF {#1} { \q__cooking_units_range }
+ { \__cooking_units_parse_range_in_input:ww #1 \q_stop }
+ {
+ \tl_if_in:nnTF {#1} { / }
+ {
+ \tl_if_in:nnTF {#1} { _ }
+ { \__cooking_units_parse_fraction_in_input:www #1 \q_stop }
+ { \__cooking_units_parse_fraction_in_input:ww #1 \q_stop }
+ }
+ { \__cooking_units_parse_number_in_input:n {#1} }
+ }
+ }
+\cs_generate_variant:Nn \__cooking_units_cunum_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
+ }
+\cs_new:Npn \__cooking_units_parse_range_in_input:ww #1 \q__cooking_units_range #2 \q_stop
+ {
+ \bool_set_true:N \l__cooking_units_parse_range_bool
+ \__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
+ \tl_use:N \l__cooking_units_cunum_range_sign_tl
+ \__cooking_units_calculate_and_print_input:N \l__cooking_units_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_eval_fractions_bool
+ {
+ \__cooking_units_calculate_and_print_input:n
+ { \l__cooking_units_tmpa_tl / \l__cooking_units_tmpb_tl }
+ }{
+ \__cooking_units_formatiere_fractions:nnn
+ { }
+ { \l__cooking_units_tmpa_tl }
+ { \l__cooking_units_tmpb_tl }
+ }
+ }
+\cs_new:Npn \__cooking_units_parse_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
+ \bool_if:NTF \l__cooking_units_eval_fractions_bool
+ {
+ \__cooking_units_calculate_and_print_input:n
+ {
+ \l__cooking_units_mixed_fraction_tl
+ \fp_compare:nNnTF
+ { \l__cooking_units_mixed_fraction_tl } < { \c_zero_fp }
+ { - }
+ { + }
+ \l__cooking_units_tmpa_tl / \l__cooking_units_tmpb_tl
+ }
+ }{
+ \__cooking_units_formatiere_fractions:nnn
+ { \l__cooking_units_mixed_fraction_tl }
+ { \l__cooking_units_tmpa_tl }
+ { \l__cooking_units_tmpb_tl }
+ }
+ }
+\cs_new:Npn \__cooking_units_parse_input_and_safe_in:nN #1 #2
+ {
+ \tl_clear:N \l_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 }
+ }
+\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_map_function:nN {#1} \__cooking_units_parse_input_for_safety_aux:N
+ }
+ \bool_if:NF \l__cooking_units_error_bool
+ { \tl_map_function:nN {#2} \__cooking_units_parse_input_for_safety_aux:N }
+ }
+\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_if_in:NnTF \l__cooking_units_decimal_mark_tl {#1}
+ {
+ \bool_if:NT \l__cooking_units_decimal_in_input_bool
+ {
+ \msg_error:nn { cooking-units }
+ { Second - decimal -sign - not - allowed }
+ }
+ \bool_set_true:N \l__cooking_units_decimal_in_input_bool
+ \tl_put_right:Nn \l_tmpa_tl { . }
+ }{
+ \tl_if_in:NnTF \l__cooking_units_allowed_special_signs_tl {#1}
+ {
+ \bool_set_true:N \l__cooking_units_special_sign_bool
+ \tl_put_right:Nn \l_tmpa_tl {#1}
+ }{
+ \bool_if:NTF \l__cooking_units_parse_range_bool
+ {
+ \tl_if_in:nnTF { / _ } {#1}
+ { \msg_error:nnn { cooking-units } { fraction-not-allowed-with-range } {#1} }
+ { \msg_error:nnn { cooking-units } { Token-not-allowed } {#1} }
+ }
+ {
+ \tl_if_in:nnTF { _ } {#1}
+ { \msg_error:nnn { cooking-units } { missing-slash } {#1} }
+ { \msg_error:nnn { cooking-units } { Token-not-allowed } {#1} }
+ }
+ \bool_set_true:N \l__cooking_units_error_bool
+ \tl_map_break:
+ }
+ }
+ }
+ }
+\cs_new:Npn \__cooking_units_calculate_and_print_input:n #1
+ {
+ \bool_if:NTF \l__cooking_units_error_bool
+ {#1}
+ {
+ \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
+ }
+ {
+ \__cooking_units_calculate_input_and_store_in:nN {#1} \l_tmpa_tl
+ \__cooking_units_check_temperature_limit:N \l_tmpa_tl
+ }
+ \__cooking_units_print_nummerical_output:N \l_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 }
+ {
+ \tl_set:Nf #2
+ {
+ \fp_eval:c { l__cooking_units_tmpa_ \l__cooking_units_tmp_unit_tl _ tl }
+ }
+ }{
+ \tl_set:Nf #2
+ {
+ \fp_eval:n
+ {
+ \l_tmpa_fp *
+ \tl_use:c { l__cooking_units_tmpa_ \l__cooking_units_tmp_unit_tl _ tl }
+ }
+ }
+ }
+ \__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
+ {
+ \__cooking_units_get_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 .
+ {
+ \quark_if_recursion_tail_stop_do:nn {#2}
+ { \bool_set_false:N \l_tmpa_bool }
+ \int_compare:nNnTF { \tl_count:n {#2} } < {\l__cooking_units_significant_figures_plus_one_int }
+ { \bool_set_false:N \l_tmpa_bool }
+ { \bool_set_true:N \l_tmpa_bool }
+ \use_none_delimit_by_q_recursion_stop:w
+ }
+\cs_new:Npn \__cooking_units_round_calculated_input:NN #1#2
+ {
+ \__cooking_units_get_number_after_dot:n {#2}
+ \tl_set:Nf #1
+ {
+ \bool_if:nTF { \l_tmpa_bool || \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}
+ }
+ }
+\cs_generate_variant:Nn \__cooking_units_round_calculated_input:NN { NV }
+\cs_new:Npn \__cooking_units_formatiere_fractions:nnn #1#2#3
+ {
+ \bool_set_true:N \l__cooking_units_fraction_in_input_bool
+ \tl_if_blank:nF {#1}
+ {
+ #1
+ \hbox_to_wd:nn { \l__cooking_units_mixed_frac_dim } { }
+ }
+ \__cooking_units_frac:nn {#2} {#3}
+ }
+\cs_new:Npn \__cooking_units_check_temperature_limit:N #1
+ {
+ \bool_if:NT \l__cooking_units_check_temperature_bool
+ {
+ \clist_if_in:nVT { C , F , K , Re } \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 }
+ { #1 \space \l__cooking_units_option_unit_tl }
+ {
+ \fp_use:c { c__cooking_units_ \l__cooking_units_option_unit_tl _min_fp }
+ \space \l__cooking_units_option_unit_tl
+ }
+ }
+ }
+ }
+ }
+\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 ) }
+ \tl_replace_once:NnV #1 { . } \l__cooking_units_tmpa_tl
+ \tl_replace_once:NnV #1 { - } \c__cooking_units_minus_tl
+ #1
+ }
+\NewDocumentCommand \cunum { O{} m O{} m }
+ {
+ \group_begin:
+ \__cooking_units_cunum_initialise:nnnn {#1} {#2} {#3} {#4}
+ \bool_if:NTF \l__cooking_units_parse_input_bool
+ { \__cooking_units_cunum:nnVV {#2} {#3} \l__cooking_units_option_unit_tl \l__cooking_units_tmp_unit_tl }
+ { \__cooking_units_cunum_do_not_parse:nnn {#2} {#3} {#4} }
+ \group_end:
+ }
+\cs_new_protected:Npn \__cooking_units_cunum_initialise:nnnn #1#2#3#4
+ {
+ \tl_set:Nn \l__cooking_units_tmp_unit_tl {#4}
+ \__cooking_units_error_if_unit_not_defined:V \l__cooking_units_tmp_unit_tl
+ \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
+ {
+ \tl_set_eq:NN \l__cooking_units_option_unit_tl \l__cooking_units_tmp_unit_tl
+ }
+ \keys_set_filter:nnv
+ { 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}
+ }
+ \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
+ }
+\cs_new:Npn \__cooking_units_cunum_do_not_parse:nnn #1#2#3
+ {
+ \tl_set_rescan:Nnn \l_tmpa_tl
+ {
+ \char_set_catcode_letter:N \_ %
+ \char_set_catcode_ignore:N \ %
+ } {#1}
+ \l_tmpa_tl
+ \__cooking_units_cunum_print_correct_unit:nnn {#2} {#3} {#3}
+ }
+\cs_new:Npn \__cooking_units_cunum:nnNN #1#2#3#4
+ {
+ \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_in:NVT \l_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 } }
+ \__cooking_units_cunum_parse_input:V \l_tmpa_tl
+ }
+ \__cooking_units_cunum_print_correct_unit:nnn {#2} {#3} {#4}
+ }
+\cs_generate_variant:Nn \__cooking_units_cunum:nnNN { nnVV }
+\cs_new:Npn \__cooking_units_cunum_print_correct_unit:nnn #1#2#3
+ {
+ \phantom {#1}
+ \tl_use:N \l__cooking_units_value_unit_space_tl
+ \bool_if:nTF
+ {
+ \l__cooking_units_fraction_in_input_bool ||
+ \l__cooking_units_special_sign_bool
+ }
+ { \translate { #3 ( cu-unit ) } }
+ { \translate { #2 ( cu-unit ) } }
+ }
+\NewDocumentCommand \cudefinekeys { m m }
+ {
+ \bool_set_false:N \l__cooking_units_single_key_bool
+ \cukeys_define_keys_and_single_keys:nn {#1} {#2}
+ }
+\NewDocumentCommand \cudefinesinglekey { m m }
+ {
+ \bool_set_true:N \l__cooking_units_single_key_bool
+ \cukeys_define_keys_and_single_keys:nn {#1} {#2}
+ }
+\cs_new:Npn \cukeys_define_keys_and_single_keys:nn #1#2
+ {
+ \__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
+ \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}
+ \__cooking_units_cukeys_parse_and_create_keys:nn {#1}
+ {
+ {#1} { \c_one_fp } #2
+ }
+ }
+ }
+ }
+\cs_new:Npn \__cooking_units_cukeys_parse_and_create_keys:nn #1#2
+ {
+ \__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
+ }
+\cs_new:Npn \__cooking_units_cukeys_parse_input: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 } }
+ \__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 } }
+ \__cooking_units_cukeys_parse_input:nn
+ }
+\cs_new:Npn \__cooking_units_cukeys_create_key_prop:n #1
+ {
+ \clist_map_inline:Nn \l_tmpa_clist
+ {
+ \prop_clear_new:c { l__cooking_units_cukeys_ ##1 _prop }
+ \tl_clear_new:c { l__cooking_units_tmpa_ ##1 _tl }
+ \tl_set_eq:cN { l__cooking_units_tmpa_ ##1 _tl } \c_one_fp
+ \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 } { Erstes Ding } \l__cooking_units_tmp_unit_tl
+ \clist_map_inline:Nn \l_tmpa_clist
+ {
+ \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} }
+ }
+ }
+ }
+ }
+\cs_new:Npn \__cooking_units_cukeys_define_keys:N #1
+ {
+ \clist_map_inline:Nn \l_tmpa_clist
+ {
+ \clist_put_right:Nn \l__cooking_units_list_of_defined_keys_clist {##1}
+ \keys_define:nn { cooking-units }
+ {
+ ##1 .choices:Vn =
+ \l_tmpa_clist
+ {
+ \__cooking_units_cukeys_define_keys_and_single_key_aux:n {##1}
+ } ,
+ ##1 / unknown .code:n=
+ {
+ \seq_set_split:Nnn \l_tmpa_seq { , } {#1}
+ \msg_error:nnxxx
+ { cooking-units }
+ { key-choice-unknown }
+ {##1}
+ {####1}
+ { \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
+ {
+ \prop_get:cVN
+ { 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
+ \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
+ {
+ \tl_set_rescan:Nnn \l_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_create_key_prop:n {#1}
+ \__cooking_units_cukeys_define_singlekey:nV {#1} \l_tmpa_clist
+ }
+\cs_new:Npn \__cooking_units_cusinglekeys_parse_input:n #1
+ {
+ \__cooking_units_cusinglekeys_parse_input_aux:nn #1
+ \q_recursion_tail \q_recursion_tail \q_recursion_stop
+ }
+\cs_generate_variant:Nn \__cooking_units_cusinglekeys_parse_input:n { V }
+\cs_new:Npn \__cooking_units_cusinglekeys_parse_input_aux: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_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
+ \__cooking_units_cusinglekeys_parse_input_aux:nn
+ }
+\cs_new:Npn \__cooking_units_cusinglekeys_create_key_prop:n #1
+ {
+ \prop_clear_new:c { l__cooking_units_cukeys_ #1 _prop }
+ \tl_set_eq:cN { l__cooking_units_tmpa_ #1 _tl } \c_one_fp
+ \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
+ {
+ \clist_put_right:Nn \l__cooking_units_list_of_defined_keys_clist {#1}
+ \keys_define:nn { cooking-units }
+ {
+ #1 .choices:Vn =
+ \l_tmpa_clist
+ {
+ \__cooking_units_cukeys_define_keys_and_single_key_aux:n {#1}
+ } ,
+ #1 / unknown .code:n=
+ {
+ \seq_set_split:Nnn \l_tmpa_seq { , } {#2}
+ \msg_error:nnxxx
+ { cooking-units }
+ { key-choice-unknown }
+ {#1}
+ {##1}
+ { \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_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
+ }
+\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
+ }
+\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
+ }
+\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} }
+ \tl_if_blank:nF {#2}
+ {
+ \__cooking_units_cukeys_add_keys_and_single_key_aux:n {#1}
+ \bool_if:NTF \l__cooking_units_single_key_bool
+ { \__cooking_units_cukeys_parse_and_create_single_key:nn {#1} {#2} }
+ { \__cooking_units_cukeys_parse_and_create_keys:nn {#1} {#2} }
+ }
+ }
+\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
+ }
+\NewDocumentCommand \newcookingunit { o m }
+ {
+ \__cooking_units_new_cooking_unit:nn {#1} {#2}
+ }
+\cs_new:Npn \__cooking_units_new_cooking_unit:nn #1#2
+ {
+ \clist_if_in:NnTF \g__cooking_units_list_of_defined_units_clist {#2}
+ { \msg_error:nnn { cooking-units } { unit-already-defined } {#2} }
+ {
+ \tl_new:c { l__cooking_units_tmpa_ #2 _tl }
+ \tl_set_eq:cN { l__cooking_units_tmpa_ #2 _tl } \c_one_fp
+ \clist_put_right:Nn \g__cooking_units_list_of_defined_units_clist {#2}
+ \clist_new:c { l__cooking_units_predefined_option_#2_clist }
+ \keys_define:nn { cooking - units }
+ {
+ set-option-for-#2 .clist_set:c = { l__cooking_units_predefined_option_#2_clist } ,
+ add-option-for-#2 .code:n =
+ { \clist_put_right:cn { l__cooking_units_predefined_option_#2_clist } {##1} },
+ }
+ \prop_new:c { l__cooking_units_cukeys_ #2 _prop }
+ \IfNoValueTF {#1}
+ {
+ \newtranslation { #2 ( cu-unit ) } {#2}
+ }{
+ \newtranslation { #2 ( cu-unit ) } {#1}
+ }
+ }
+ }
+\NewDocumentCommand \cutext { O{} m m }
+ {
+ \group_begin:
+ \__cooking_units_cutext_default:nnn {#1} {#2} {#3}
+ \__cooking_units_cutext_print_correct_unitname:nn {#2} {#3}
+ \group_end:
+ }
+\NewDocumentCommand \Cutext { O{} m m }
+ {
+ \group_begin:
+ \bool_set_true: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:
+ }
+\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}
+ \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_replace_once:Nnn \l_tmpb_tl { -- } { \q__cooking_units_range }
+ \tl_if_in:NnTF \l_tmpb_tl \q__cooking_units_range
+ { \__cooking_units_cunum_parse_range:Vn \l_tmpb_tl {#3} }
+ { \__cooking_units_cutext_print_nummerical_output:Nn \l_tmpb_tl {#3} }
+ }
+ {#2}
+ }
+\cs_new:Npn \__cooking_units_cunum_parse_range:Nn #1 #2
+ {
+ \__cooking_units_cunum_parse_range_aux:nww {#2} #1 \q_stop
+ }
+\cs_generate_variant:Nn \__cooking_units_cunum_parse_range:Nn { V }
+\cs_new:Npn \__cooking_units_cunum_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_nummerical_output:Nn \l__cooking_units_tmpa_tl {#1}
+ \tl_use:N \l__cooking_units_cutext_range_sign_tl
+ \__cooking_units_cutext_print_nummerical_output:Nn \l__cooking_units_tmpb_tl {#1}
+ }
+\cs_new:Npn \__cooking_units_cutext_just_print_number_correctly:N #1
+ {
+ \translatelet \l_tmpa_tl { decimal-mark ( cu-unit name ) }
+ \tl_replace_once:NnV #1 { . } \l_tmpa_tl
+ \tl_replace_once:NnV #1 { - } \c__cooking_units_minus_tl
+ #1
+ }
+\cs_new_protected:Npn \__cooking_units_cutext_print_nummerical_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_tmpa_tl { #2 (cu-unitgender) }
+ \translatelet \l_tmpa_tl { one (\l_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_tmpa_tl }
+ \tl_tail:V \l_tmpa_tl
+ }
+ { \l_tmpa_tl }
+ }{
+ \bool_if:NTF \l__cooking_units_cutext_uppercase_word_bool
+ { \Numberstringnum {#1} }
+ { \numberstringnum {#1} }
+ }
+ }{ \__cooking_units_cutext_just_print_number_correctly:N #1 }
+ }{ \__cooking_units_cutext_just_print_number_correctly:N #1 }
+ }
+ { \__cooking_units_cutext_just_print_number_correctly:N #1 }
+ }
+\cs_new:Npn \__cooking_units_cutext_print_correct_unitname:nn #1#2
+ {
+ \space
+ \__cooking_units_if_integer_and_parse:nTF {#1}
+ {
+ \fp_compare:nNnTF {#1} = { \c_one_fp }
+ { \translate { #2 (cu-unitname) } }
+ { \translate { #2 (cu-unitname pl) } }
+ }{
+ \translate { #2 (cu-unitname pl) }
+ }
+ }
+\NewDocumentCommand \cufrac { O{} m }
+ {
+ \group_begin:
+ \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}
+ }
+\NewDocumentCommand \cudefinename { m m }
+ {
+ \tl_set:Nn \l__cooking_units_language_tl {#1}
+ \__cooking_units_cuname_parse_input:n #2
+ \q_recursion_tail \q_recursion_tail \q_recursion_stop
+ }
+\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} }
+ }
+\cs_new:Npn \__cooking_units_cuname_parse_unit_symbol:nw #1 [#2]
+ {
+ \quark_if_recursion_tail_stop:n {#1}
+ \quark_if_recursion_tail_stop_do:nn {#2}
+ { \msg_error:nn { cooking-units } { missing-argument } }
+ \__cooking_units_error_if_unit_not_defined:n {#1}
+ \deftranslation [ to=\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
+ {
+ \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} }
+ \deftranslation [ to=\l__cooking_units_language_tl ] { #1 (cu-unitname) } {#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]
+ {
+ \deftranslation [ to=\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> }
+ }
+\cs_new:Npn \__cooking_units_cuname_parse_arrows:nw #1 <#2>
+ {
+ \deftranslation [ to=\l__cooking_units_language_tl ] { #1 ( cu-unitgender ) } {#2}
+ \__cooking_units_cuname_parse_input:n
+ }
+\NewDocumentCommand \cudefinesymbol { m m }
+ {
+ \tl_set:Nn \l__cooking_units_language_tl {#1}
+ \__cooking_units_cuprint_define_printed_unit:nn #2
+ \q_recursion_tail \q_recursion_tail \q_recursion_stop
+ }
+\cs_new:Npn \__cooking_units_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:NnF \g__cooking_units_allowed_unit_phrases_clist {#1}
+ { \__cooking_units_error_if_unit_not_defined:n {#1} }
+ \deftranslation [ to=\l__cooking_units_language_tl ] { #1 ( cu-unit ) } {#2}
+ \__cooking_units_cuprint_define_printed_unit:nn
+ }
+\NewDocumentCommand \cusetup { m }
+ {
+ \keys_set:nn { cooking-units } {#1}
+ }
+\newcookingunit { kg }
+\newcookingunit { dag }
+\newcookingunit { g }
+\newcookingunit { oz }
+\newcookingunit { lb }
+\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 F ] { F }
+\newcookingunit [ \ensuremath{ {} ^ { \circ } } \kern-\scriptspace R\'{e} ] { Re }
+\newcookingunit { d }
+\newcookingunit { h }
+\newcookingunit { min }
+\newcookingunit { s }
+\newcookingunit [ \ensuremath{ \__cooking_units_frac:nn { \hbar } { eV } } ] { hbareV-1 }
+\newcookingunit { m }
+\newcookingunit { cm }
+\newcookingunit { dm }
+\newcookingunit { mm }
+\newcookingunit { in }
+\newcookingunit [ \ensuremath{ \__cooking_units_frac:nn { c\hbar } { eV } } ] { chbareV-1 }
+\newcookingunit { l }
+\newcookingunit { dl }
+\newcookingunit { cl }
+\newcookingunit { ml }
+\newcookingunit [ \ensuremath { \__cooking_units_frac:nn { c^3 \hbar^3 } { eV^3 } } ] { (chbareV-1)3 }
+\newcookingunit { cal }
+\newcookingunit { kcal }
+\newcookingunit { J }
+\newcookingunit { kJ }
+\newcookingunit { eV }
+\newcookingunit [ Msp. ] { Msp }
+\newcookingunit { EL }
+\newcookingunit { TL }
+\cudefinename { German }
+ {
+ { kg } { Kilogramm } < n >
+ { dag } { Dekagramm } < n >
+ { g } { Gramm } < n >
+ { oz } { Unze } < f >
+ { lb } { Pfund } < n >
+ { d } { Tag } [ Tage ]
+ { h } { Stunde } [ Stunden ] < f >
+ { min } { Minute } [ Minuten ] < f >
+ { s } { Sekunde } [ Sekunden ] < f >
+ { C } { Grad \space Celsius }
+ { K } { Kelvin } < n >
+ { F } { Grad \space Fahrenheit }
+ { Re } { Grad \space R\'{e}amur }
+ { m } { Meter } < n >
+ { dm } { Dezimeter } < n >
+ { cm } { Centimeter } < n >
+ { mm } { Millimeter } < n >
+ { in } { Zoll }
+ { l } { Liter }
+ { dl } { Deziliter }
+ { cl } { Centiliter }
+ { ml } { Milliliter }
+ { cal } { Kalorie } [ Kalorien ] < f >
+ { kcal } { Kilokalorie } [ Kilokalorien ] < f >
+ { J } { Joule }
+ { kJ } { Kilojoule }
+ { eV } { ELektronenvolt } < n >
+ { Msp } [ Msp. ] { Messerspitze } [ Messerspitzen ] < f >
+ { EL } [ EL ] { Essl{\"o}ffel }
+ { TL } [ TL ] { Teel{\"o}ffel }
+ { decimal-mark } { , }
+ { one (m) } { ein }
+ { one (f) } { eine }
+ { one (n) } { ein }
+ }
+\cudefinename { English }
+ {
+ { kg } { kilogramme }
+ { dag } { decagramme }
+ { g } { gramme }
+ { oz } { ounce }
+ { lb } { pound } [ pounds ]
+ { d } { day } [ days ]
+ { h } { hour } [ hours ]
+ { min } { minute } [ minutes ]
+ { s } { second } [ seconds ]
+ { C } { degree \space Celsius } [ degrees \space Celsius ]
+ { F } { degree \space Fahrenheit } [ degrees \space Fahrenheit ]
+ { K } { kelvin }
+ { Re } { degree \space R\'{e}aumur } [ degrees \space R\'{e}aumur ]
+ { m } { metre } [ metres ]
+ { dm } { decimetre } [ decimetres ]
+ { cm } { centimetre } [ centimetres ]
+ { mm } { millimitre } [ millimitres ]
+ { in } { inch } [ inches ]
+ { l } { litre } [ litres ]
+ { dl } { decilitre } [ decilitres ]
+ { cl } { centilitre } [ centilitres ]
+ { ml } { millilitre } [ millilitres ]
+ { cal } { calorie } [ calories ]
+ { kcal } { kilocalorie } [ kilocalories ]
+ { J } { joule } [ joules ]
+ { kJ } { kilojoule } [ kilojoules ]
+ { eV } { electron \space volt }
+ { Msp } [ pn ] { pinch } [ pinches ]
+ { EL } [ tsp. ] { tablespoon } [ tablespoons ]
+ { TL } [ tbsp. ] { teaspoon } [ teaspoons ]
+ { decimal-mark } { . }
+ { one (m) } { one }
+ { one (f) } { one }
+ { one (n) } { one }
+ }
+\cudefinename { AmericanEnglish }
+ {
+ { kg } { kilogram }
+ { dag } { decagram }
+ { g } { gram }
+ { oz } { ounce }
+ { m } { meter } [ meters ]
+ { dm } { decimeter } [ decimeters ]
+ { cm } { centimeter } [ centimeters ]
+ { mm } { millimiter } [ millimiters ]
+ { in } { inch } [ inches ]
+ { l } { liter } [ liters ]
+ { dl } { deciliter } [ deciliters ]
+ { cl } { centiliter } [ centiliters ]
+ { ml } { milliliter } [ milliliters ]
+ }
+\cudefinename { French }
+ {
+ { kg } { kilogramme } [ kilogrammes ]
+ { dag } { d\'{e}cagramme } [ d\'{e}cagrammes]
+ { g } { gramme } [ gramme ]
+ { oz } { once } < f >
+ { lb } { livre } [ livres ] < f >
+ { d } { jour } [ jours ]
+ { h } { heure } [ heures ] < f >
+ { min } { minute } [ minutes ] < f >
+ { s } { seconde } [ secondes ] < f >
+ { C } { degr\'{e} \space Celsius } [ degr\'{e}s \space Celsius ]
+ { K } { degr\'{e} \space Fahrenheit } [ degr\'{e}s \space Fahrenheit ]
+ { F } { kelvin } [ kelvins ]
+ { Re } { \'{e}chelle \space R\'{e}aumur } [ degr\'{e}s \space R\'{e}aumur ]
+ { 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 ]
+ { l } [ L ] { litre } [ litres ]
+ { dl } [ dL ] { d\'{e}cilitre } [ d\'{e}cilitres ]
+ { cl } [ cL ] { centilitre } [ centilitres ]
+ { ml } [ mL ] { millilitre } [ millilitres ]
+ { cal } { calorie } [ calorie ]
+ { kcal } { kilocalorie } [ kilocalories ]
+ { J } { joule } [ joules ]
+ { kJ } { kilojoule } [ kilojoules ]
+ { eV } { \'{e}lectron-volt } [ \'{e}lectron-volts ]
+ { Msp } { pinc\'{e}e } < f >
+ { EL } { cuill\'{e}re \space \`{a} \space soupe } < f >
+ { TL } { cuill\'{e}re \space \`{a} \space caf\'{e} } < f >
+ { decimal-mark } { . }
+ { one (m) } { un }
+ { one (f) } { une }
+ { one (n) } { un }
+ }
+\cudefinekeys { kg }
+ {
+ { dag }{ 100 }
+ { g } { 1000 }
+ { oz } { 35.27399 }
+ { lb } { 2.204 622 6 } %% 2.204 622 6
+ }
+\cuaddtokeys { kg } { eVc-2 } { 1.78266173e-16 }
+\cudefinekeys { d }
+ {
+ { h } { 24 }
+ { min }{ 1440 }
+ { s } { 86400 }
+ }
+\cuaddtokeys { s } { hbareV-1 } { 6.582119514e-16 }
+\cudefinekeys { m }
+ {
+ { dm } { 10 }
+ { cm } { 100 }
+ { mm } { 1000 }
+ { in } { 39.370079 }
+ }
+\cuaddtokeys { m } { chbareV-1 } { 1.97326972e-7 }
+\cudefinekeys { l }
+ {
+ { dl } { 10 }
+ { cl } { 100 }
+ { ml }{ 1000 }
+ { (chbareV-1)3 } { 1.30148943e+17 }
+ }
+\cudefinekeys { J }
+ {
+ { kJ }{ 1e-3 }
+ { cal }{ 0.2388459 }
+ { kcal }{ 0.2388459e-3 }
+ }
+\cuaddtokeys { J } { eV } { 1.6021766208e-19 }
+\fp_const:Nn \c__cooking_units_kb_eV_fp { 8.617 330 3 e-5 }
+\cudefinesinglekey { C }
+ {
+ { F } { #1 * 1.8 + 32 }
+ { K } { #1 + 273.15 }
+ { Re } { #1 * 0.8 }
+ { eV } { ( #1 + 273.15 ) * \c__cooking_units_kb_eV_fp }
+ }
+\cudefinesinglekey { F }
+ {
+ { C } { ( #1 - 32 ) * 5/9 }
+ { K } { ( #1 + 459.67 ) * 5/9 }
+ { Re } { ( #1 - 32 ) * 4/9 }
+ { eV } {( #1 + 459.67 ) * 5/9 * \c__cooking_units_kb_eV_fp }
+ }
+\cudefinesinglekey { K }
+ {
+ { C } { #1 - 273.15 }
+ { F } { #1 * 1.8 - 459.67 }
+ { Re } { ( #1 - 273.15 ) * 0.8 }
+ { eV } { #1 * \c__cooking_units_kb_eV_fp }
+ }
+\cudefinesinglekey { Re }
+ {
+ { K } { #1 * 1.25 + 273.15 }
+ { C } { #1 * 1.25 }
+ { F } { #1 * 2.25 + 32 }
+ { eV } { ( #1 - 273.15 ) * 1.25 * \c__cooking_units_kb_eV_fp }
+ }
+\fp_const:Nn \c__cooking_units_K_min_fp { 0 }
+\fp_const:Nn \c__cooking_units_C_min_fp { -273.15 }
+\fp_const:Nn \c__cooking_units_F_min_fp { -459.67 }
+\fp_const:Nn \c__cooking_units_Re_min_fp { -218.52 }
+\cusetup
+ {
+ set-option-for-F = { round-to-int = true } ,
+ set-option-for-C = { round-to-int = true } ,
+ set-option-for-K = { round-to-int = true } ,
+ set-option-for-Re = { round-to-int = true } ,
+ }
+
+\endinput
+%%
+%% End of file `cooking-units.sty'.