diff options
author | Karl Berry <karl@freefriends.org> | 2022-06-14 20:20:47 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2022-06-14 20:20:47 +0000 |
commit | 7b6c297bf35995d5387284690ff8adfefc50e4d3 (patch) | |
tree | e32d8a3beea0aaaefbe4e66f967acf396338ed6b /Master/texmf-dist/tex | |
parent | 536930901a8cffcf701badf84f6f83613810404c (diff) |
diffcoeff (14jun22)
git-svn-id: svn://tug.org/texlive/trunk@63590 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex')
-rw-r--r-- | Master/texmf-dist/tex/latex/diffcoeff/diffcoeff.sty | 81 |
1 files changed, 41 insertions, 40 deletions
diff --git a/Master/texmf-dist/tex/latex/diffcoeff/diffcoeff.sty b/Master/texmf-dist/tex/latex/diffcoeff/diffcoeff.sty index 8ecaf599508..4d2015a6b0e 100644 --- a/Master/texmf-dist/tex/latex/diffcoeff/diffcoeff.sty +++ b/Master/texmf-dist/tex/latex/diffcoeff/diffcoeff.sty @@ -9,7 +9,7 @@ % \RequirePackage{expl3} \RequirePackage{xparse,l3keys2e,xtemplate} -\ProvidesExplPackage {diffcoeff} {2021/12/24} {4.0} +\ProvidesExplPackage {diffcoeff} {2022/06/14} {4.1} {Write differential coefficients consistently and easily.} % \keys_define:nn { diffcoeff } @@ -34,7 +34,6 @@ \tl_new:N \l__diffcoeff_curr_num_tl \tl_new:N \l__diffcoeff_curr_var_tl \tl_new:N \l__diffcoeff_paren_tl -\tl_new:N \l__diffcoeff_trailing_tl \tl_const:Nn \c__diffcoeff_digits_tl { 1234567890 } @@ -60,10 +59,10 @@ \int_new:N \l__diffcoeff_parenvar_int %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -\DeclareObjectType { derivative } { 5 } +\DeclareObjectType { derivative } { 3 } % defaults: ordinary deriv. values -\DeclareTemplateInterface { derivative } { DERIV } { 5 } +\DeclareTemplateInterface { derivative } { DERIV } { 3 } { op-symbol : tokenlist = d , op-symbol-alt : tokenlist = \KeyValue { op-symbol }, @@ -92,21 +91,21 @@ % #1 order spec(seqvar); #2 order override(tlvar) % #3 derivand(tlvar); #4 denominator(seqvar) % #5 subscript(tlvar) -\DeclareTemplateCode { derivative } { DERIV } { 5 } +\DeclareTemplateCode { derivative } { DERIV } { 3 } { op-symbol = \l__diffcoeff_op_tl, op-symbol-alt = \l__diffcoeff_op_alt_tl, op-order-sep = \l__diffcoeff_oporder_muskip, derivand-sep = \l__diffcoeff_derivsep_muskip, long-var-wrap = { - dv = \cs_set:Npn \__diffcoeff_wrap_longvars:nn #1#2 - { \l__diffcoeff_op_alt_tl {#2}^{#1} }, - d(v) = \cs_set:Npn \__diffcoeff_wrap_longvars:nn #1#2 - { \l__diffcoeff_op_alt_tl {(#2)}^{#1} }, - (dv) = \cs_set:Npn \__diffcoeff_wrap_longvars:nn #1#2 - { (\l__diffcoeff_op_alt_tl {#2)}^{#1} }, - unknown = \cs_set:Npn \__diffcoeff_wrap_longvars:nn #1#2 - { \l__diffcoeff_op_alt_tl {(#2)}^{#1} } + dv = \cs_set_eq:NN \__diffcoeff_wrap_longvars:nn + \__diffcoeff_wrap_longvars_dv:nn, + d(v) = \cs_set_eq:NN \__diffcoeff_wrap_longvars:nn + \__diffcoeff_wrap_longvars_dvi:nn, + (dv) = \cs_set_eq:NN \__diffcoeff_wrap_longvars:nn + \__diffcoeff_wrap_longvars_dvii:nn, + unknown = \cs_set_eq:NN \__diffcoeff_wrap_longvars:nn + \__diffcoeff_wrap_longvars_dvi:nn }, denom-term-sep = \l__diffcoeff_varsep_muskip, term-sep-adjust = \l__diffcoeff_sep_adj_muskip, @@ -133,7 +132,7 @@ { \int_compare:nNnT { \l__diffcoeff_format_int } > { 1 } { \__diffcoeff_slash_vals: } - \__diffcoeff_build:NNNNN #1#2#3#4#5 + \__diffcoeff_build:nnn { #1 } { #2 } { #3 } } } %%%%%%%%%% @@ -145,8 +144,11 @@ \tl_set:NV \l__diffcoeff_ldelim_tl \l__diffcoeff_ldelimi_tl \tl_set:NV \l__diffcoeff_rdelim_tl \l__diffcoeff_rdelimi_tl } -\cs_new:Npn \__diffcoeff_build:NNNNN #1#2#3#4#5 +% #1 diff'and; #2 vars clist; #3 trailing arg +\cs_new:Npn \__diffcoeff_build:nnn #1#2#3 { + \tl_set:Nn \l__diffcoeff_derivand_tl { #1 } + \seq_set_from_clist:Nn \l__diffcoeff_vars_seq { #2 } \bool_if:nT { !\l__diffcoeff_opwrap_bool && @@ -161,25 +163,27 @@ } { \__diffcoeff_derivsep: } { \tl_put_left:Nn \l__diffcoeff_derivand_tl { \mskip 0 mu } } - \exp_args:NV\tl_if_novalue:nF #5 + \tl_if_novalue:nF { #3 } { \l__diffcoeff_ldelim_tl \mskip \l__diffcoeff_elbowrm_muskip } \bool_if:NTF \l__diffcoeff_single_var_bool { - \tl_set:Nx \l_tmpa_tl { \seq_use:Nn #4 { , } } - \__diffcoeff_single:NNN #2 #3 \l_tmpa_tl + \tl_set:Nx \l_tmpa_tl { \seq_use:Nn \l__diffcoeff_vars_seq { , } } + \__diffcoeff_single:NNN \l__diffcoeff_tot_order_tl \l__diffcoeff_derivand_tl \l_tmpa_tl } { \int_zero:N \l_tmpa_int - \seq_mapthread_function:NNN #1 #4 \__diffcoeff_map_orders:nn - \__diffcoeff_mixed:NNN #2 #3 \l__diffcoeff_denom_seq + \seq_mapthread_function:NNN \l__diffcoeff_orders_seq + \l__diffcoeff_vars_seq \__diffcoeff_map_orders:nn + \__diffcoeff_mixed:NNN \l__diffcoeff_tot_order_tl + \l__diffcoeff_derivand_tl \l__diffcoeff_denom_seq } - \exp_args:NV\tl_if_novalue:nF #5 + \tl_if_novalue:nF { #3 } { \mskip \l__diffcoeff_elbowrm_muskip \l__diffcoeff_rdelim_tl - \exp_args:NV\tl_if_empty:nF #5 + \tl_if_empty:nF { #3 } { \c_math_subscript_token - { \mskip \l__diffcoeff_subnudge_muskip #5 } + { \mskip \l__diffcoeff_subnudge_muskip { #3 } } } } } @@ -213,16 +217,22 @@ } } } -% (ptl) form denom from #1 orders seq & #2 vars seq +\cs_new:Npn \__diffcoeff_wrap_longvars_dv:nn #1#2 + { \l__diffcoeff_op_alt_tl { {}#2 }^{ #1 } } +\cs_new:Npn \__diffcoeff_wrap_longvars_dvi:nn #1#2 + { \l__diffcoeff_op_alt_tl { {}(#2) }^{ #1 } } +\cs_new:Npn \__diffcoeff_wrap_longvars_dvii:nn #1#2 + { (\l__diffcoeff_op_alt_tl { {}#2) }^{ #1 } } +% (ptl) form denom #1 from orders seq & #2 from vars seq \cs_new_protected:Npn \__diffcoeff_map_orders:nn #1#2 { \tl_if_eq:nnTF { #1 } { 1 } - { \seq_put_right:Nn \l__diffcoeff_denom_seq { \l__diffcoeff_op_alt_tl #2 } } + { \seq_put_right:Nn \l__diffcoeff_denom_seq { \l__diffcoeff_op_alt_tl { #2 } } } { \int_compare:nNnTF { \tl_count:n { #2 } } = { 1 } { \seq_put_right:Nn \l__diffcoeff_denom_seq - { \l__diffcoeff_op_alt_tl #2^{ #1 } } + { \l__diffcoeff_op_alt_tl { #2 }^{ #1 } } } { \seq_put_right:Nn \l__diffcoeff_denom_seq @@ -288,10 +298,10 @@ \cs_new_protected:Npn \__diffcoeff_denom_single:NN #1#2 { \tl_if_eq:nVTF { 1 } #1 - { \l__diffcoeff_op_alt_tl #2 } + { \l__diffcoeff_op_alt_tl {}#2 } { \int_compare:nNnTF { \tl_count:N #2 } = { 1 } - { \l__diffcoeff_op_alt_tl #2^{ #1 } } + { \l__diffcoeff_op_alt_tl {}#2^{ #1 } } { \__diffcoeff_wrap_longvars:nn { #1\vphantom) } { #2 } } } } @@ -344,13 +354,9 @@ \IfBooleanTF #5 { \bool_set_true:N \l__diffcoeff_altsep_bool } { \bool_set_false:N \l__diffcoeff_altsep_bool } - \tl_set:Nn \l__diffcoeff_derivand_tl { #6 } - \tl_set:Nn \l__diffcoeff_trailing_tl { #9 } - \seq_set_from_clist:Nn \l__diffcoeff_vars_seq { #8 } \seq_set_from_clist:Nn \l__diffcoeff_orders_seq { #3 } - \int_set:Nn \l__diffcoeff_vars_int - { \seq_count:N \l__diffcoeff_vars_seq } \int_set:Nn \l_tmpb_int { \seq_count:N \l__diffcoeff_orders_seq } + \int_set:Nn \l__diffcoeff_vars_int { \clist_count:n { #8 } } \int_compare:nNnTF { \l__diffcoeff_vars_int } = { 1 } { \bool_set_true:N \l__diffcoeff_single_var_bool } { @@ -359,7 +365,7 @@ \msg_error:nnxxxx { diffcoeff } { numbers-conflict } { \int_use:N \l__diffcoeff_vars_int } { \int_use:N \l_tmpb_int } { \seq_use:Nn \l__diffcoeff_orders_seq { , } } - { \seq_use:Nn \l__diffcoeff_vars_seq { , } } + { \clist_use:nn { #8 } { , } } } { % pad orders seq if nec. \int_step_inline:nnnn @@ -385,12 +391,7 @@ \int_zero:N \l__diffcoeff_format_int \IfBooleanT #2 { \int_incr:N \l__diffcoeff_format_int } \IfBooleanT #7 { \int_add:Nn \l__diffcoeff_format_int { 2 } } - \UseInstance { derivative } { ord\l__diffcoeff_type_tl } - \l__diffcoeff_orders_seq - \l__diffcoeff_tot_order_tl - \l__diffcoeff_derivand_tl - \l__diffcoeff_vars_seq - \l__diffcoeff_trailing_tl + \UseInstance { derivative } { ord\l__diffcoeff_type_tl } {#6}{#8}{#9} \group_end: } % end of \diff %%%%%%%%%%%%%%%%%%% |