diff options
author | Karl Berry <karl@freefriends.org> | 2016-10-28 20:57:39 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2016-10-28 20:57:39 +0000 |
commit | 8289077694867928d89669029eb58b0f27fed253 (patch) | |
tree | d67f38cb497090686a383932c237450e165a7a1d /Master/texmf-dist/tex | |
parent | f1ef2f648613f3f1de0cb26dfd78a35edf544e74 (diff) |
cooking-units (28oct16)
git-svn-id: svn://tug.org/texlive/trunk@42372 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex')
-rw-r--r-- | Master/texmf-dist/tex/latex/cooking-units/cooking-units.sty | 178 |
1 files changed, 110 insertions, 68 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 index 8fc9a0f6b3c..efbc1d03db3 100644 --- a/Master/texmf-dist/tex/latex/cooking-units/cooking-units.sty +++ b/Master/texmf-dist/tex/latex/cooking-units/cooking-units.sty @@ -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,36 +622,35 @@ \__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 } \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,56 +1146,59 @@ \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 { \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 ] |