summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2023-01-11 20:44:28 +0000
committerKarl Berry <karl@freefriends.org>2023-01-11 20:44:28 +0000
commit78c27a80858022b12e7a0eadbf2d00de38305467 (patch)
tree4dac91e691607fbc8602eed6df3c41af5a7a4716 /Master/texmf-dist/tex
parentd949d89ed8366eb57b5dfb42cd5ecab2d6915564 (diff)
diffcoeff (11jan23)
git-svn-id: svn://tug.org/texlive/trunk@65523 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex')
-rw-r--r--Master/texmf-dist/tex/latex/diffcoeff/diffcoeff-doc.def6
-rw-r--r--Master/texmf-dist/tex/latex/diffcoeff/diffcoeff.sty1051
-rw-r--r--Master/texmf-dist/tex/latex/diffcoeff/diffcoeff4.sty744
-rw-r--r--Master/texmf-dist/tex/latex/diffcoeff/diffcoeff5.def136
4 files changed, 1498 insertions, 439 deletions
diff --git a/Master/texmf-dist/tex/latex/diffcoeff/diffcoeff-doc.def b/Master/texmf-dist/tex/latex/diffcoeff/diffcoeff-doc.def
index 884d41760bf..879285dea09 100644
--- a/Master/texmf-dist/tex/latex/diffcoeff/diffcoeff-doc.def
+++ b/Master/texmf-dist/tex/latex/diffcoeff/diffcoeff-doc.def
@@ -114,4 +114,8 @@
left-delim = \left ( ,
right-delim = \right ),
subscr-nudge = -6 mu
- } \ No newline at end of file
+ }
+
+ %%%%%%%%%% differential %%%%%%%%%%
+ \diffdef { up }
+ { op-symbol = \mathrm{d} } \ No newline at end of file
diff --git a/Master/texmf-dist/tex/latex/diffcoeff/diffcoeff.sty b/Master/texmf-dist/tex/latex/diffcoeff/diffcoeff.sty
index 4d2015a6b0e..d7a541c78dc 100644
--- a/Master/texmf-dist/tex/latex/diffcoeff/diffcoeff.sty
+++ b/Master/texmf-dist/tex/latex/diffcoeff/diffcoeff.sty
@@ -7,96 +7,163 @@
%
% Andrew Parsloe ajparsloe@gmail.com
%
-\RequirePackage{expl3}
-\RequirePackage{xparse,l3keys2e,xtemplate}
-\ProvidesExplPackage {diffcoeff} {2022/06/14} {4.1}
- {Write differential coefficients consistently and easily.}
-%
+\DeclareRelease{v4}{}{diffcoeff4.sty}
+\DeclareCurrentRelease{}{2023/01/02}
+
+\RequirePackage{xtemplate,mleftright}
+\ProvidesExplPackage {diffcoeff} {2023/01/02} {5.0}
+ {Write differential coefficients easily and consistently.}
\keys_define:nn { diffcoeff }
{
- ISO .bool_set:N = \l__diffcoeff_ISO_bool,
- spaced .int_set:N = \l__diffcoeff_spaced_int,
- spaced .default:n = 1,
- spaced .initial:n = 0,
- def-file .tl_gset:N = \g__diffcoeff_def_tl,
- def-file .initial:n = diffcoeff,
- def-file .default:n = diffcoeff
+ spaced .int_set:N = \l__diffcoeff_spaced_int,
+ spaced .default:n = 1,
+ spaced .initial:n = 0,
+ mleftright .bool_set:N = \l__diffcoeff_mLR_bool,
+ mleftright .default:n = true,
+ mleftright .initial:n = false,
+ def-file .tl_gset:N = \g__diffcoeff_def_tl,
+ DIF .clist_set:N = \l__diffcoeff_dif_clist
+ }
+\IfFormatAtLeastTF {2020-10-01} {}
+ { \RequirePackage { xparse } }
+\IfFormatAtLeastTF {2022-06-01}
+ { \ProcessKeyOptions [ diffcoeff ] }
+ {
+ \RequirePackage { l3keys2e }
+ \ProcessKeysOptions { diffcoeff }
}
-\ProcessKeysPackageOptions { diffcoeff }
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-\cs_generate_variant:Nn \tl_if_eq:nnTF { nV }
-
-\tl_new:N \l__diffcoeff_oporder_tl
+\bool_if:NT \l__diffcoeff_mLR_bool
+ { \mleftright }
+%%%%%%%%%% messages %%%%%%%%%
+\cs_new:Npn \__diffcoeff_msg_autocalc:n #1
+ {
+ in~the~order~spec.~[#1]~\msg_line_context:.~Calculation~of~the~
+ total~order~of~differentiation~fails~in~this~case.~
+ Use~the~\tl_to_str:n { \difoverride }command~to~enter~the~total~order.~
+ \msg_see_documentation_text:n {diffcoeff}
+ }
+\cs_new:Npn \__diffcoeff_msg_style:nnn #1#2#3
+ {
+ The~style~specified~in~the~current~instance,~#1,~
+ \msg_line_context:,~#3~Reverting~to~default~style~#2.
+ }
+\tl_const:Nn \c__diffcoeff_msg_vcon_tl
+ { Version~5~of~diffcoeff~does~not~support~the~use~of~ }
+\tl_const:Nn \c__diffcoeff_msg_revert_tl
+ { Or~revert~to~version~4~by~appending~[=v4]~to~the~preamble~call;~
+ for~example,~\tl_to_str:n{\usepackage}{diffcoeff}[=v4] }
+\msg_new:nnn { diffcoeff } { file-not-found } { File~#1.def~not~found. }
+\msg_new:nnn { diffcoeff } { order-spec-general }
+ { #3~followed~by~#2~\__diffcoeff_msg_autocalc:n { #1 } }
+\msg_new:nnn { diffcoeff } { unknown-style }
+ { \__diffcoeff_msg_style:nnn {#1} {#2} { is~unknown. } }
+\msg_new:nnn { diffcoeff } { wrong-style }
+ { \__diffcoeff_msg_style:nnn {#1} {#2} { conflicts~with~its~template. } }
+\msg_new:nnn { diffcoeff } { version-conflict }
+ {
+ \c__diffcoeff_msg_vcon_tl #1~\msg_line_context:.~\tl_to_str:n { #2 }
+ \msg_see_documentation_text:n {diffcoeff}~\c__diffcoeff_msg_revert_tl
+ }
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+\bool_new:N \l__diffcoeff_multitok_bool
+\bool_new:N \l__diffcoeff_append_bool
+\bool_new:N \l__diffcoeff_op_left_bool
+\bool_new:N \l__diffcoeff_dl_bool
+\bool_new:N \l__diffcoeff_exponent_bool
+\tl_new:N \l__diffcoeff_override_tl
+\tl_new:N \l__diffcoeff_frac_tl
\tl_new:N \l__diffcoeff_derivand_tl
-\tl_new:N \l__diffcoeff_type_tl
-\tl_new:N \l__diffcoeff_tot_order_tl
+\tl_new:N \l__diffcoeff_instance_tl
+\tl_new:N \l__diffcoeff_ord_tl
+\tl_new:N \l__diffcoeff_var_tl
+\tl_new:N \l__diffcoeff_tot_ord_tl
+\tl_new:N \l__diffcoeff_vph_tl
+\tl_new:N \l__diffcoeff_exponent_tl
\tl_new:N \l__diffcoeff_curr_num_tl
\tl_new:N \l__diffcoeff_curr_var_tl
\tl_new:N \l__diffcoeff_paren_tl
-
-\tl_const:Nn \c__diffcoeff_digits_tl { 1234567890 }
-
-\seq_new:N \l__diffcoeff_orders_seq
+\seq_new:N \l__diffcoeff_ords_seq
\seq_new:N \l__diffcoeff_vars_seq
-\seq_new:N \l__diffcoeff_denom_seq
\seq_new:N \l__diffcoeff_paren_seq
-
-\prop_new:N \l__diffcoeff_vars_prop
-
-\bool_new:N \l__diffcoeff_op_left_bool
-\bool_new:N \l__diffcoeff_single_var_bool
-\bool_new:N \l__diffcoeff_opwrap_bool
-\bool_new:N \l__diffcoeff_integ_bool
-\bool_new:N \l__diffcoeff_spaced_bool
-\bool_new:N \l__diffcoeff_altsep_bool
-
-\int_new:N \l__diffcoeff_vars_int
-\int_new:N \l__diffcoeff_format_int
+\int_new:N \l__diffcoeff_group_int
+\int_new:N \l__diffcoeff_style_int
\int_new:N \l__diffcoeff_curr_tok_int
\int_new:N \l__diffcoeff_curr_state_int
\int_new:N \l__diffcoeff_nos_int
\int_new:N \l__diffcoeff_parenvar_int
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-\DeclareObjectType { derivative } { 3 }
-
-% defaults: ordinary deriv. values
-\DeclareTemplateInterface { derivative } { DERIV } { 3 }
+\prop_new:N \l__diffcoeff_vars_prop
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+\DeclareObjectType { diffcoeff } { 5 }
+% #1 append boolean; #2 order spec(clist); #3 derivand(tl);
+% #4 diff variables(clist); #5 pt of eval(tl)
+\DeclareTemplateInterface { diffcoeff } { DIF } { 5 }
{
- op-symbol : tokenlist = d ,
+ style-group : choice { f, s, c, j, l } = f,
+ style : choice { frac, tfrac, dfrac,
+ /, auto, big, Big, bigg, Bigg,
+ _, dl
+ } = frac ,
+ slash-tok : tokenlist = / ,
+ slash-sep : tokenlist = 0 mu,
+ derivand-sep : tokenlist = 3 mu plus 1 mu minus 2 mu,
+ op-symbol : tokenlist = \mathrm{d},
op-symbol-alt : tokenlist = \KeyValue { op-symbol },
- op-order-sep : muskip = 1 mu ,
- derivand-sep : muskip = 3 mu plus 1 mu minus 2 mu,
+ op-order-nudge : tokenlist = 0 mu ,
+ var-sup-nudge : tokenlist = 1 mu ,
+ multi-term-sep : tokenlist = 2 mu plus 1 mu minus 1 mu,
+ term-sep-adjust : tokenlist = -1 mu,
long-var-wrap : choice { dv, d(v), (dv) }
- = d(v) ,
- denom-term-sep : muskip = 2 mu ,
- term-sep-adjust : muskip = -1 mu ,
- left-delim : tokenlist = \left . ,
- right-delim : tokenlist = \right |,
- elbowroom : muskip = 0 mu ,
- subscr-nudge : muskip = 0 mu ,
- *-derivand-sep : muskip = \KeyValue { derivand-sep },
- *-op-left : boolean = false ,
- *-italic-nudge : muskip = 3 mu ,
- /-derivand-sep : muskip = \KeyValue { derivand-sep },
- /-denom-term-sep : muskip = 1 mu ,
- /-left-delim : tokenlist = ( ,
- /-right-delim : tokenlist = ) ,
- /-elbowroom : muskip = 0 mu ,
- /-subscr-nudge : muskip = 0 mu ,
- */-derivand-sep : muskip = \KeyValue { /-derivand-sep },
- */-op-wrap : boolean = true
- }
-% #1 order spec(seqvar); #2 order override(tlvar)
-% #3 derivand(tlvar); #4 denominator(seqvar)
-% #5 subscript(tlvar)
-\DeclareTemplateCode { derivative } { DERIV } { 3 }
+ = d(v) ,
+ lvwrap-Ldelim : tokenlist = \mleft (,
+ lvwrap-Rdelim : tokenlist = \mright ),
+ lvwrap-sup-nudge : tokenlist = -2 mu,
+ outer-Ldelim : tokenlist = \left ( ,
+ outer-Rdelim : tokenlist = \right ),
+ elbowroom : tokenlist = 0 mu ,
+ sub-nudge : tokenlist = -5 mu,
+ op-sub-nudge : tokenlist = 0 mu ,
+ *derivand-sep : tokenlist = \KeyValue { derivand-sep },
+ *op-set-left : boolean = false,
+ *italic-nudge : tokenlist = 0 mu ,
+ *inner-wrap : boolean = false,
+ *inner-Ldelim : tokenlist = (,
+ *inner-Rdelim : tokenlist = ),
+ *outer-Ldelim : tokenlist = \bigl [,
+ *outer-Rdelim : tokenlist = \bigr ],
+ *sub-nudge : tokenlist = 0 mu
+ }
+\DeclareTemplateCode { diffcoeff } { DIF } { 5 }
{
- 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,
+ style-group = {
+ f = \int_set:Nn \l__diffcoeff_group_int { 0 },
+ s = \int_set:Nn \l__diffcoeff_group_int { 1 },
+ c = \int_set:Nn \l__diffcoeff_group_int { 2 },
+ j = \int_set:Nn \l__diffcoeff_group_int { 3 },
+ l = \int_set:Nn \l__diffcoeff_group_int { 4 }
+ },
+ style = {
+ frac = \__diffcoeff_style:nn { 0 } {},
+ tfrac = \__diffcoeff_style:nn { 1 } {},
+ dfrac = \__diffcoeff_style:nn { 2 } {},
+ / = \__diffcoeff_style:nn { 3 } {},
+ auto = \__diffcoeff_style:nn { 4 } {},
+ big = \__diffcoeff_style:nn { 5 } { big },
+ Big = \__diffcoeff_style:nn { 5 } { Big },
+ bigg = \__diffcoeff_style:nn { 5 } { bigg },
+ Bigg = \__diffcoeff_style:nn { 5 } { Bigg },
+ _ = \__diffcoeff_style:nn { 6 } {},
+ dl = \__diffcoeff_style:nn { 7 } {},
+ unknown = \__diffcoeff_style:nn { 9 } {}
+ },
+ slash-tok = \l__diffcoeff_slashtok_tl,
+ slash-sep = \l__diffcoeff_slashsep_tl,
+ derivand-sep = \l__diffcoeff_derivsep_tl,
+ op-symbol = \l__diffcoeff_opi_tl,
+ op-symbol-alt = \l__diffcoeff_opii_tl,
+ op-order-nudge = \l__diffcoeff_opordsep_tl,
+ var-sup-nudge = \l__diffcoeff_varsupnudge_tl,
+ multi-term-sep = \l__diffcoeff_termsep_tl,
+ term-sep-adjust = \l__diffcoeff_sep_adj_tl,
long-var-wrap = {
dv = \cs_set_eq:NN \__diffcoeff_wrap_longvars:nn
\__diffcoeff_wrap_longvars_dv:nn,
@@ -105,307 +172,164 @@
(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
+ \__diffcoeff_wrap_longvars_dvi:nn
},
- denom-term-sep = \l__diffcoeff_varsep_muskip,
- term-sep-adjust = \l__diffcoeff_sep_adj_muskip,
- left-delim = \l__diffcoeff_ldelim_tl,
- right-delim = \l__diffcoeff_rdelim_tl,
- elbowroom = \l__diffcoeff_elbowrm_muskip ,
- subscr-nudge = \l__diffcoeff_subnudge_muskip,
- *-derivand-sep = \l__diffcoeff_derivsepi_muskip,
- *-op-left = \l__diffcoeff_op_left_bool,
- *-italic-nudge = \l__diffcoeff_opnudge_muskip,
- /-derivand-sep = \l__diffcoeff_derivsepii_muskip,
- /-denom-term-sep = \l_tmpb_muskip,
- /-left-delim = \l__diffcoeff_ldelimi_tl,
- /-right-delim = \l__diffcoeff_rdelimi_tl,
- /-elbowroom = \l_tmpc_muskip,
- /-subscr-nudge = \l_tmpd_muskip,
- */-derivand-sep = \l__diffcoeff_derivsepiii_muskip,
- */-op-wrap = \l__diffcoeff_opwrap_bool
+ lvwrap-Ldelim = \l__diffcoeff_lvw_ldelim_tl,
+ lvwrap-Rdelim = \l__diffcoeff_lvw_rdelim_tl,
+ lvwrap-sup-nudge = \l__diffcoeff_lvsupnudge_tl,
+ outer-Ldelim = \l__diffcoeff_ldelim_tl,
+ outer-Rdelim = \l__diffcoeff_rdelim_tl,
+ elbowroom = \l__diffcoeff_elbowrm_tl ,
+ sub-nudge = \l__diffcoeff_subnudge_tl,
+ op-sub-nudge = \l__diffcoeff_opsubnudge_tl,
+ *derivand-sep = \l__diffcoeff_derivsepi_tl,
+ *op-set-left = \l__diffcoeff_op_left_bool,
+ *italic-nudge = \l__diffcoeff_opleftnudge_tl,
+ *inner-wrap = \l__diffcoeff_innerwrap_bool,
+ *inner-Ldelim = \l__diffcoeff_lopwrap_tl,
+ *inner-Rdelim = \l__diffcoeff_ropwrap_tl,
+ *outer-Ldelim = \l__diffcoeff_ldelimapp_tl,
+ *outer-Rdelim = \l__diffcoeff_rdelimapp_tl,
+ *sub-nudge = \l__diffcoeff_subnudgeapp_tl
}
{
\AssignTemplateKeys
-
- \bool_if:NF\l__diffcoeff_integ_bool
- {
- \int_compare:nNnT { \l__diffcoeff_format_int } > { 1 }
- { \__diffcoeff_slash_vals: }
- \__diffcoeff_build:nnn { #1 } { #2 } { #3 }
- }
+ \__diffcoeff_check_style:nn
+ { \l__diffcoeff_group_int } { \l__diffcoeff_style_int }
+ \__diffcoeff_append:n { #1 }
+ \exp_args:Nx \__diffcoeff_orders:nn { \clist_count:n {#4} } { #2 }
+ \__diffcoeff_override:N \l__diffcoeff_override_tl
+ \__diffcoeff_derivand:n { #3 }
+ \__diffcoeff_build:nn { #4 } { #5 }
}
%%%%%%%%%%
-\cs_new:Npn \__diffcoeff_slash_vals:
- {
- \muskip_set:Nn \l__diffcoeff_varsep_muskip \l_tmpb_muskip
- \muskip_set:Nn \l__diffcoeff_elbowrm_muskip \l_tmpc_muskip
- \muskip_set:Nn \l__diffcoeff_subnudge_muskip \l_tmpd_muskip
- \tl_set:NV \l__diffcoeff_ldelim_tl \l__diffcoeff_ldelimi_tl
- \tl_set:NV \l__diffcoeff_rdelim_tl \l__diffcoeff_rdelimi_tl
- }
-% #1 diff'and; #2 vars clist; #3 trailing arg
-\cs_new:Npn \__diffcoeff_build:nnn #1#2#3
+\cs_new_protected:Npn \__diffcoeff_style:nn #1#2
{
- \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 &&
- \int_compare_p:nNn { \l__diffcoeff_format_int } > { 1 }
- }
- { \int_set:Nn \l__diffcoeff_format_int { 4 } }
- \__diffcoeff_spaced:n { \l__diffcoeff_spaced_int }
- \bool_if:nTF
- {
- ( \l__diffcoeff_altsep_bool && !\l__diffcoeff_spaced_bool )
- || ( !\l__diffcoeff_altsep_bool && \l__diffcoeff_spaced_bool )
- }
- { \__diffcoeff_derivsep: }
- { \tl_put_left:Nn \l__diffcoeff_derivand_tl { \mskip 0 mu } }
- \tl_if_novalue:nF { #3 }
- { \l__diffcoeff_ldelim_tl \mskip \l__diffcoeff_elbowrm_muskip }
- \bool_if:NTF \l__diffcoeff_single_var_bool
+ \int_set:Nn \l__diffcoeff_style_int { #1 }
+ \tl_set:Nn \l__diffcoeff_frac_tl { \prg_do_nothing: }
+ \int_case:nn { #1 }
{
- \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 \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
- }
- \tl_if_novalue:nF { #3 }
- {
- \mskip \l__diffcoeff_elbowrm_muskip \l__diffcoeff_rdelim_tl
- \tl_if_empty:nF { #3 }
- {
- \c_math_subscript_token
- { \mskip \l__diffcoeff_subnudge_muskip { #3 } }
+ { 0 } { \tl_set:Nn \l__diffcoeff_frac_tl { \frac } }
+ { 1 } { \tl_set:Nn \l__diffcoeff_frac_tl { \tfrac } }
+ { 2 } { \tl_set:Nn \l__diffcoeff_frac_tl { \dfrac } }
+ { 3 } { \tl_set:Nn \l__diffcoeff_frac_tl { \difstfrac } }
+ { 4 } { \tl_set:Nn \l__diffcoeff_frac_tl { \difsafrac } }
+ { 5 } { \tl_set:Nn \l__diffcoeff_frac_tl { \difsbfrac[#2] } }
+ { 6 } { \tl_set:Nn \l__diffcoeff_frac_tl {} }
+ { 7 } { \bool_set_true:N \l__diffcoeff_dl_bool }
+ { 9 }
+ {
+ \msg_error:nnxx { diffcoeff } { unknown-style }
+ { \l__diffcoeff_instance_tl }
+ { \__diffcoeff_style_group:n { \l__diffcoeff_group_int } }
}
}
}
-%%%%%%%%%%%%%%%%%%%%
-\cs_new_protected:Npn \__diffcoeff_spaced:n #1
- {
- \int_case:nn { \int_sign:n { #1 } }
- {
- { 1 } { \bool_set_true:N \l__diffcoeff_spaced_bool }
- { 0 } { \bool_set_false:N \l__diffcoeff_spaced_bool }
- { -1 }
- {
- \int_compare:nNnTF { 1 } <
- { \tl_count:N \l__diffcoeff_derivand_tl }
- { \bool_set_true:N \l__diffcoeff_spaced_bool }
- { \bool_set_false:N \l__diffcoeff_spaced_bool }
- }
- }
- }
-\cs_new_protected:Npn \__diffcoeff_derivsep:
- {
- \tl_put_left:Nx \l__diffcoeff_derivand_tl
- {
- \int_case:nn { \l__diffcoeff_format_int }
- {
- { 0 } { \mskip \l__diffcoeff_derivsep_muskip }
- { 1 } { \mskip \l__diffcoeff_derivsepi_muskip }
- { 2 } { \mskip \l__diffcoeff_derivsepii_muskip }
- { 3 } { \mskip \l__diffcoeff_derivsepiii_muskip }
- { 4 } { \mskip \l__diffcoeff_derivsepiii_muskip }
- }
+% #1 group int; #2 style int
+\cs_new_protected:Npn \__diffcoeff_check_style:nn #1#2
+ {
+ \bool_if:nF
+ {
+ ( \int_compare_p:nNn { \int_div_truncate:nn {#2} {3} } = { #1 }
+ && \int_compare_p:nNn { #1 } < { 3 } ) % f,s,c
+ || ( \int_compare_p:nNn { \int_div_truncate:nn {#2} {2} } < { #1 }
+ && \int_compare_p:nNn { #1 } = { 3 } ) % j
+ || \int_compare_p:nNn { #1 + #2 } = { 11 } % l
}
- }
-\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 } } }
{
- \int_compare:nNnTF { \tl_count:n { #2 } } = { 1 }
+ \msg_warning:nnxx { diffcoeff } { wrong-style }
+ { \l__diffcoeff_instance_tl }
+ { \__diffcoeff_style_group:n { #1 } }
+ \int_compare:nNnTF { #1 } = { 3 }
+ { \__diffcoeff_style:nn { 0 } {} }
{
- \seq_put_right:Nn \l__diffcoeff_denom_seq
- { \l__diffcoeff_op_alt_tl { #2 }^{ #1 } }
- }
- {
- \seq_put_right:Nn \l__diffcoeff_denom_seq
- { \__diffcoeff_wrap_longvars:nn { #1\vphantom{)} } { #2 } }
+ \int_compare:nNnTF { #1 } = { 4 }
+ { \__diffcoeff_style:nn { 7 } {} }
+ { \__diffcoeff_style:nn { 3*#1 } {} }
}
}
- }
-% #1 order(tlvar) ; #2 diff'iand(tlvar); #3 denom(tlvar)
-\cs_new:Npn \__diffcoeff_single:NNN #1#2#3
- {
- \__diffcoeff_numer:N { #1 }
- \__diffcoeff_form_deriv:NNn
- \l__diffcoeff_oporder_tl
- \l__diffcoeff_derivand_tl
- { \__diffcoeff_denom_single:NN #1 #3 }
- }
-% #1 total order; #2 derivand; #3 denom seq
-\cs_new_protected:Npn \__diffcoeff_mixed:NNN #1#2#3
- {
- \__diffcoeff_numer:N #1
- \__diffcoeff_form_deriv:NNn
- \l__diffcoeff_oporder_tl
- \l__diffcoeff_derivand_tl
- { \__diffcoeff_denom_sep:N #3 }
- }
-\cs_new:Npn \__diffcoeff_denom_sep:N #1
+ \bool_if:nT
+ { \int_compare_p:nNn { #1 } > { 0 } && \int_if_even_p:n { #1 } }
+ { \tl_set_eq:NN \l__diffcoeff_opii_tl \l__diffcoeff_opi_tl }
+ \int_compare:nNnF { #1 } = { 1 }
+ { \bool_set_false:N \l__diffcoeff_innerwrap_bool }
+ }
+\cs_new:Npn \__diffcoeff_style_group:n #1
+ { \clist_item:nn { frac, /, _, frac, dl } { #1 + 1 } }
+\cs_new:Npn \__diffcoeff_style_aux:n #1
{
- \int_zero:N \l_tmpa_int
- \seq_map_inline:Nn #1
- {
- \int_incr:N \l_tmpa_int ##1
- \int_compare:nNnT { \l_tmpa_int } < { \l__diffcoeff_vars_int }
- {
- \seq_pop:NN \l__diffcoeff_orders_seq \l_tmpa_tl
- \str_if_eq:VnTF \l_tmpa_tl { 1 }
- { \mskip \l__diffcoeff_varsep_muskip }
- {
- \mskip \muskip_eval:n { \l__diffcoeff_varsep_muskip +
- \l__diffcoeff_sep_adj_muskip }
- }
- }
+ \int_compare:nNnTF { #1 } = { 3 } { { 0 } {} }
+ {
+ \int_compare:nNnTF { #1 } = { 4 } { { 7 } {} }
+ { { 3*#1 } {} }
}
}
-% #1(tl) total order
-\cs_new_protected:Npn \__diffcoeff_numer:N #1
- {
- \bool_if:NTF \l__diffcoeff_op_left_bool
+%%%%%%%%% append? (& wrap slash diff operator?)
+\cs_new_protected:Npn \__diffcoeff_append:n #1
+ {
+ \bool_if:nTF
+ { #1 || \int_compare_p:nNn { \l__diffcoeff_group_int } = {2} }
{
- \tl_set:Nn \l__diffcoeff_oporder_tl
- { \mskip \l__diffcoeff_opnudge_muskip }
+ \bool_set_true:N \l__diffcoeff_append_bool
+ \bool_if:NT \l__diffcoeff_innerwrap_bool
+ { \tl_put_right:Nn \l__diffcoeff_frac_tl { * } }
}
- { \tl_clear:N \l__diffcoeff_oporder_tl }
- \tl_put_right:No \l__diffcoeff_oporder_tl \l__diffcoeff_op_tl
- \exp_args:NnV \tl_if_eq:nnF { 1 } #1
+ { \bool_set_false:N \l__diffcoeff_append_bool }
+ }
+%%%%%%%%%
+% #1(int) no. of vars; #2(clist) orders spec
+\cs_new_protected:Npn \__diffcoeff_orders:nn #1#2
+ {
+ \bool_if:NTF \l__diffcoeff_exponent_bool
{
- \tl_put_right:Nn \l__diffcoeff_oporder_tl
- { \mskip \l__diffcoeff_oporder_muskip ^ { #1 } }
+ \exp_args:NNx \seq_set_from_clist:Nn \l__diffcoeff_ords_seq
+ { \prg_replicate:nn { #1 } { \l__diffcoeff_exponent_tl, } }
}
- \bool_if:NT \l__diffcoeff_op_left_bool
- { \tl_put_right:Nn \l__diffcoeff_oporder_tl { \hfill } }
- }
-% #1 order; #2 var
-\cs_new_protected:Npn \__diffcoeff_denom_single:NN #1#2
- {
- \tl_if_eq:nVTF { 1 } #1
- { \l__diffcoeff_op_alt_tl {}#2 }
{
- \int_compare:nNnTF { \tl_count:N #2 } = { 1 }
- { \l__diffcoeff_op_alt_tl {}#2^{ #1 } }
- { \__diffcoeff_wrap_longvars:nn { #1\vphantom) } { #2 } }
+ \seq_set_from_clist:Nn \l__diffcoeff_ords_seq { #2 }
+ \exp_args:Nnx\__diffcoeff_adj_ords_seq:nn { #1 }
+ { \seq_count:N \l__diffcoeff_ords_seq }
}
+ \tl_set:Nx \l__diffcoeff_vph_tl {\seq_use:Nn\l__diffcoeff_ords_seq {} }
}
-% #1 op+order; #2 diff'iand; #3 denom
-% 0 frac; 1 frac append; 2 slash ; 3 ( slash ) append; 4 slash append
-\cs_new:Npn \__diffcoeff_form_deriv:NNn #1#2#3
+\cs_new_protected:Npn \__diffcoeff_adj_ords_seq:nn #1#2
{
- \int_case:nn { \l__diffcoeff_format_int }
- {
- { 0 } { \frac { #1 #2 } { #3 } }
- { 1 } { \frac { #1 } { #3 } #2 }
- { 2 } { #1 #2 / #3 }
- { 3 } { ( #1 / #3 ) #2 }
- { 4 } { #1 / #3 #2 }
+ \int_compare:nNnTF { #1 } < { #2 }
+ { % truncate
+ \int_step_inline:nn { #2 - #1 }
+ { \seq_pop_right:NN \l__diffcoeff_ords_seq \l_tmpa_tl }
+ }
+ { % pad
+ \int_step_inline:nnnn { 1 + #2 } { 1 } { #1 }
+ { \seq_put_right:Nn \l__diffcoeff_ords_seq { 1 } }
}
}
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-% differential
-% #1 variant; #2 = space in mu before d (0--9)
-% note \group_end placement for \vec{x} etc
-\NewDocumentCommand \dl { d.. t- m }
- {
- \group_begin:
- \bool_set_true:N \l__diffcoeff_integ_bool
- \bool_set_true:N \l__diffcoeff_single_var_bool
- \seq_set_from_clist:Nn \l__diffcoeff_orders_seq { 1 }
- \tl_set:Nn \l__diffcoeff_tot_order_tl { 1 }
- \IfValueTF { #1 }
- { \tl_set:Nn \l__diffcoeff_type_tl { .#1 } }
- { \tl_set:Nn \l__diffcoeff_type_tl { } }
- \UseInstance { derivative } { ord\l__diffcoeff_type_tl }
- \l__diffcoeff_orders_seq \l__diffcoeff_tot_order_tl
- \c_empty_tl \c_empty_seq \c_empty_tl
- \tl_if_in:NnTF \c__diffcoeff_digits_tl { #3 }
- { \mskip \IfBooleanT #2 { - }#3 mu \l__diffcoeff_op_tl \group_end: }
- { \l__diffcoeff_op_tl \group_end: {} #3 }
- }
-\NewDocumentCommand \negmu {} { \mskip -1 mu }
-\NewDocumentCommand \nilmu {} { \mskip 0 mu }
-\NewDocumentCommand \onemu {} { \mskip 1 mu }
-\NewDocumentCommand \twomu {} { \mskip 2 mu }
-% derivative
-% #1(tl) = name of variant; #2(*)= append diff'iand boolean
-% #3(clist) = orders of diff. in each var.; #4(tl) = order override
-% #5(bool) spacing switch; #6(tl) = diff'iand; #7( / ) = slash boolean
-% #8(clist) = vars of diff.; #9(tl) = pt of eval./vars held const
-\NewDocumentCommand \diff { d.. s O{1} o t! >{\TrimSpaces} m t/ m !o }
+\cs_new_protected:Npn \__diffcoeff_override:N #1
{
- \group_begin:
- \IfBooleanTF #5
- { \bool_set_true:N \l__diffcoeff_altsep_bool }
- { \bool_set_false:N \l__diffcoeff_altsep_bool }
- \seq_set_from_clist:Nn \l__diffcoeff_orders_seq { #3 }
- \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 }
- {
- \int_compare:nNnTF { \l__diffcoeff_vars_int } < { \l_tmpb_int }
- {
- \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 { , } }
- { \clist_use:nn { #8 } { , } }
- }
- { % pad orders seq if nec.
- \int_step_inline:nnnn
- { 1 + \l_tmpb_int } { 1 } { \l__diffcoeff_vars_int }
- { \seq_put_right:Nn \l__diffcoeff_orders_seq { 1 } }
- }
- }
- % override/calc total order
- \IfValueTF { #4 }
- { \tl_set:Nn \l__diffcoeff_tot_order_tl { #4 } }
+ \tl_if_empty:NTF { #1 }
{
- \bool_if:NTF \l__diffcoeff_single_var_bool
- { \tl_set:Nn \l__diffcoeff_tot_order_tl { #3 } }
- {
- \__diffcoeff_calc_tot_order:NN \l__diffcoeff_orders_seq
- \l__diffcoeff_tot_order_tl
- }
+ \__diffcoeff_calc_tot_order:NN \l__diffcoeff_ords_seq
+ \l__diffcoeff_tot_ord_tl
}
- \IfValueTF { #1 }
- { \tl_set:Nn \l__diffcoeff_type_tl { .#1 } }
- { \tl_set:Nn \l__diffcoeff_type_tl { } }
- % append? slash?
- \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 } {#6}{#8}{#9}
- \group_end:
- } % end of \diff
-%%%%%%%%%%%%%%%%%%%
-% #2(seq) expr in; #1(tlv) expr out
-\cs_new:Npn \__diffcoeff_calc_tot_order:NN #1 #2
+ { \tl_set:Nn \l__diffcoeff_tot_ord_tl { #1 } }
+ \seq_pop_right:NN \l__diffcoeff_ords_seq \l__diffcoeff_ord_tl
+ }
+%%%%%%%%%% calc. total order %%%%%%%%%%
+% #1(seq) expr in; #2(tl) expr out
+\cs_new_protected:Npn \__diffcoeff_calc_tot_order:NN #1 #2
{
\tl_clear:N \l__diffcoeff_nos_tl
- \exp_args:Nx\__diffcoeff_digest_expr:n { \seq_use:Nn #1 { + } }
+ \exp_args:Nx \__diffcoeff_digest_expr:n { \seq_use:Nn #1 { + } }
\prop_if_empty:NTF \l__diffcoeff_vars_prop
{ \tl_set:NV #2 \l__diffcoeff_nos_tl }
- { \__diffcoeff_evaluate:NN \l__diffcoeff_vars_prop #2 }
+ {
+ \int_compare:nNnT { \l__diffcoeff_nos_int } = { 0 }
+ { \tl_clear:N \l__diffcoeff_nos_tl }
+ \__diffcoeff_evaluate:NN \l__diffcoeff_vars_prop #2
+ }
}
-\cs_new:Npn \__diffcoeff_digest_expr:n #1
- {
+\cs_new_protected:Npn \__diffcoeff_digest_expr:n #1
+ {
\tl_set:Nn \l__diffcoeff_curr_num_tl { + }
\tl_set:Nn \l__diffcoeff_paren_tl { +1 }
\tl_set:Nn \l__diffcoeff_nos_tl { 0 }
@@ -419,13 +343,11 @@
}
\int_set:Nn \l__diffcoeff_nos_int { \l__diffcoeff_nos_tl }
\tl_set:Nx \l__diffcoeff_nos_tl { \int_use:N \l__diffcoeff_nos_int }
- \int_compare:nNnT { \l__diffcoeff_nos_int } = { 0 }
- { \tl_clear:N \l__diffcoeff_nos_tl }
}
% #1 curr tok (tl); #2 <== curr tok ndx (int)
\cs_new_protected:Npn \__diffcoeff_get_curr_ndx:nN #1#2
{
- \tl_if_in:NnTF \c__diffcoeff_digits_tl { #1 }
+ \tl_if_in:nnTF { 1234567890 } { #1 }
{ \int_set:Nn #2 { 1 } } % digit
{
\str_case:nnF { #1 }
@@ -461,7 +383,7 @@
{
{ 0 } % tok = s
{
- \tl_if_eq:nVTF { #1 } \l__diffcoeff_curr_num_tl
+ \str_if_eq:nVTF { #1 } \l__diffcoeff_curr_num_tl
{ \tl_set:Nn \l__diffcoeff_curr_num_tl { + } }
{ \tl_set:Nn \l__diffcoeff_curr_num_tl { - } }
}
@@ -497,11 +419,11 @@
{ 1 } % tok = d
{ \tl_put_right:Nn \l__diffcoeff_curr_num_tl { #1 } }
{ 2 } % tok = v
- {
- \tl_if_in:nnTF { ^ \times * / \div } { #1 }
- {
- \msg_error:nnxxx { diffcoeff } { order-specification }
- { \seq_use:Nn \l__diffcoeff_orders_seq { , } }
+ {
+ \tl_if_in:nnTF { ^ \times * / } { #1 }
+ {
+ \msg_error:nnxxx { diffcoeff } { order-spec-general }
+ { \seq_use:Nn \l__diffcoeff_ords_seq { , } }
{ #1 } { number }
}
{ \tl_set:Nn \l__diffcoeff_curr_var_tl { #1 } }
@@ -511,7 +433,7 @@
\seq_push:NV \l__diffcoeff_paren_seq \l__diffcoeff_paren_tl
\tl_put_left:Nn \l__diffcoeff_paren_tl { * }
\tl_put_left:NV \l__diffcoeff_paren_tl \l__diffcoeff_curr_num_tl
- \tl_set:Nn \l__diffcoeff_curr_num_tl { + }
+ \tl_set:Nn \l__diffcoeff_curr_num_tl { + }
\int_set:Nn #3 { 0 }
}
{ 4 } % tok = )
@@ -584,8 +506,8 @@
\int_set_eq:NN #2 #3
}
{
- \msg_error:nnxxx { diffcoeff } { order-specification }
- { \seq_use:Nn \l__diffcoeff_orders_seq { , } } { #1 } { ) }
+ \msg_error:nnxxx { diffcoeff } { order-spec-general }
+ { \seq_use:Nn \l__diffcoeff_ords_seq { , } } { #1 } { ) }
}
}
% #1 is var. (tlvar); #2 is num. (tlvar); #3 num. coeff. (tlvar)
@@ -598,7 +520,7 @@
}
% #1 (propv) key=var, val=coeff; #2 <= total order
\cs_new_protected:Npn \__diffcoeff_evaluate:NN #1#2
- {
+ {
\prop_map_inline:Nn #1 { \seq_put_left:Nn \l_tmpa_seq { ##1 } }
\seq_sort:Nn \l_tmpa_seq
{
@@ -610,15 +532,17 @@
\prop_pop:NnN #1 { ##1 } \l_tmpb_tl
\seq_put_right:Nx \l_tmpb_seq { \int_eval:n \l_tmpb_tl }
}
- \tl_clear:N \l_tmpa_tl
- \seq_mapthread_function:NNN \l_tmpa_seq \l_tmpb_seq
- \__diffcoeff_tot_order:nn
+ \tl_set:Nx \l_tmpa_tl
+ {
+ \seq_mapthread_function:NNN \l_tmpa_seq \l_tmpb_seq
+ \__diffcoeff_tot_order:nn
+ }
\exp_args:NV \tl_if_head_eq_charcode:nNTF \l_tmpa_tl +
{
\tl_set:Nx \l_tmpb_tl { \tl_tail:N \l_tmpa_tl }
\int_compare:nNnT { \l__diffcoeff_nos_int } > { 0 }
{ \tl_put_left:Nn \l__diffcoeff_nos_tl { + } }
- \tl_concat:NNN #2 \l_tmpb_tl \l__diffcoeff_nos_tl
+ \tl_concat:NNN #2 \l_tmpb_tl \l__diffcoeff_nos_tl
}
{
\int_compare:nNnTF { \l__diffcoeff_nos_int } > { 0 }
@@ -630,116 +554,367 @@
\cs_new:Npn \__diffcoeff_tot_order:nn #1#2
{
\int_compare:nNnTF { #2 } > { 0 }
+ { \int_compare:nNnTF { #2 } = { 1 } { +#1 } { +#2#1 } }
+ {
+ \int_compare:nNnT { #2 } < { 0 }
+ { \int_compare:nNnTF { #2 } = { -1 } { -#1 } { #2#1 } }
+ }
+ }
+%%%%%%%%% derivand
+\cs_new_protected:Npn \__diffcoeff_derivand:n #1
+ {
+ \tl_set:Nn \l__diffcoeff_derivand_tl { #1 }
+ \int_compare:nNnTF { \tl_count:N \l__diffcoeff_derivand_tl } > { 1 }
+ { \bool_set_true:N \l__diffcoeff_multitok_bool }
{
- \int_compare:nNnTF { #2 } = { 1 }
- { \tl_put_left:Nn \l_tmpa_tl { +#1 } }
- { \tl_put_left:Nn \l_tmpa_tl { +#2#1 } }
+ \str_if_eq:VnTF \l__diffcoeff_derivand_tl { ! }
+ { \msg_error:nnnn { diffcoeff } { version-conflict } { #1 } {} }
+ {
+ \str_if_eq:VnT \l__diffcoeff_derivand_tl { [ }
+ { \msg_error:nnnn { diffcoeff } { version-conflict } { the~
+ order-override~argument } { Use~\difoverride instead.~ } }
+ }
}
+ }
+%%%%%%%%% build #1 vars clist; #2 trailing arg
+\cs_new_protected:Npn \__diffcoeff_build:nn #1#2
+ {
+ \str_if_eq:nnT { #1 } { / }
+ {
+ \msg_error:nnnn { diffcoeff } { version-conflict } { / }
+ { Use~\difs or~\difsp instead.~ }
+ }
+ \seq_set_from_clist:Nn \l__diffcoeff_vars_seq { #1 }
+ \seq_pop_right:NN \l__diffcoeff_vars_seq \l__diffcoeff_var_tl
+ \tl_put_left:Nx \l__diffcoeff_derivand_tl
+ { \__diffcoeff_spaced:n { \l__diffcoeff_spaced_int } }
+ \tl_if_novalue:nF { #2 }
+ { \__diffcoeff_delim:N l \mskip \l__diffcoeff_elbowrm_tl }
+ \__diffcoeff_form_deriv:xNN
+ { \__diffcoeff_build_numer:Vn \l__diffcoeff_tot_ord_tl
+ { \l__diffcoeff_style_int } }
+ \__diffcoeff_build_denom:
+ \l__diffcoeff_derivand_tl
+ \tl_if_novalue:nF { #2 }
+ { \__diffcoeff_trailing_arg:n { #2 } }
+ }
+\cs_new:Npn \__diffcoeff_delim:N #1
+ {
+ \bool_if:nTF { \l__diffcoeff_innerwrap_bool && \l__diffcoeff_append_bool }
+ { \use:c { l__diffcoeff_#1 delimapp_tl } }
+ { \use:c { l__diffcoeff_#1 delim_tl } }
+ }
+\cs_new:Npn \__diffcoeff_subnudge:
+ {
+ \bool_if:nTF { \l__diffcoeff_innerwrap_bool && \l__diffcoeff_append_bool }
+ { \l__diffcoeff_subnudgeapp_tl } { \l__diffcoeff_subnudge_tl }
+ }
+\cs_new:Npn \__diffcoeff_trailing_arg:n #1
+ {
+ \mskip \l__diffcoeff_elbowrm_tl \__diffcoeff_delim:N r
+ \tl_if_empty:nF { #1 }
+ { \c_math_subscript_token { \mskip \__diffcoeff_subnudge: #1 } }
+ }
+\cs_new:Npn \__diffcoeff_spaced:n #1
+ {
+ \int_case:nn { \int_sign:n { #1 } }
{
- \int_compare:nNnT { #2 } < { 0 }
- {
- \int_compare:nNnTF { #2 } = { -1 }
- { \tl_put_right:Nn \l_tmpa_tl { -#1 } }
- { \tl_put_right:Nn \l_tmpa_tl { #2#1 } }
+ { 1 } { \__diffcoeff_derivsep: }
+ { 0 } { \mskip 0 mu }
+ {-1 }
+ {
+ \bool_lazy_or:nnT { \l__diffcoeff_multitok_bool }
+ { \int_compare_p:nNn { \l__diffcoeff_group_int } = { 2 } }
+ { \__diffcoeff_derivsep: }
}
+ }
+ }
+\cs_new:Npn \__diffcoeff_derivsep:
+ {
+ \bool_if:NTF \l__diffcoeff_append_bool
+ { \mskip \l__diffcoeff_derivsepi_tl }
+ { \mskip \l__diffcoeff_derivsep_tl }
+ }
+%%%%%%%%% numerator #1 total order tl #2 style int
+\cs_new:Npn \__diffcoeff_build_numer:nn #1#2
+ {
+ \int_compare:nNnF { #2 } > { 5 }
+ {
+ \bool_if:NT \l__diffcoeff_op_left_bool
+ { \mskip \l__diffcoeff_opleftnudge_tl }
+ \exp_not:o \l__diffcoeff_opi_tl
+ \str_if_eq:nnF {#1} {1}
+ { ^ { \mskip \l__diffcoeff_opordsep_tl \exp_not:o {#1} } }
+ \bool_if:NT \l__diffcoeff_op_left_bool
+ { \exp_not:o { \hfill } }
+ }
+ }
+\cs_generate_variant:Nn \__diffcoeff_build_numer:nn { V }
+%%%%%%%%%% denominator %%%%%%%%%
+\cs_new:Npn \__diffcoeff_build_denom:
+ {
+ \seq_mapthread_function:NNN \l__diffcoeff_ords_seq
+ \l__diffcoeff_vars_seq \__diffcoeff_build_denom_items:nn
+ \__diffcoeff_build_denom_item:VV \l__diffcoeff_ord_tl \l__diffcoeff_var_tl
+ \str_if_eq:VnF \l__diffcoeff_ord_tl { 1 }
+ {
+ \int_compare:nNnT { \l__diffcoeff_group_int } < { 2 }
+ { \mskip -\l__diffcoeff_sep_adj_tl}
}
}
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-% create new instances or edit existing ones
-% #1 = name; #2 = key-value list
-\NewDocumentCommand \diffdef { > { \TrimSpaces } m m }
+\cs_new:Npn \__diffcoeff_build_denom_items:nn#1#2
+ {
+ \__diffcoeff_build_denom_item:nn {#1} {#2}
+ \mskip \l__diffcoeff_termsep_tl
+ }
+% #1 order #2 var
+\cs_new:Npn \__diffcoeff_build_denom_item:nn #1#2
+ {
+ \int_compare:nNnTF { \l__diffcoeff_style_int } = { 6 }
+ { \__diffcoeff_build_denom_difc:onn \l__diffcoeff_vph_tl {#1}{#2} }
+ { \__diffcoeff_build_denom_dif:nn {#1} {#2} }
+ }
+\cs_generate_variant:Nn \__diffcoeff_build_denom_item:nn { VV }
+% #1 vphantom orders #2 order #3 var
+\cs_new:Npn \__diffcoeff_build_denom_difc:nnn #1#2#3
+ {
+ \exp_not:o \l__diffcoeff_opii_tl \c_math_subscript_token
+ { \mskip \l__diffcoeff_opsubnudge_tl {}#3 } ^
+ {
+ \mskip \l__diffcoeff_opordsep_tl \exp_not:o { \vphantom{#1} }
+ \str_if_eq:nnF { #2 } { 1 }
+ { \exp_not:o {#2} \mskip \l__diffcoeff_sep_adj_tl }
+ }
+ }
+\cs_generate_variant:Nn \__diffcoeff_build_denom_difc:nnn { o }
+% #1 order #2 var
+\cs_new:Npn \__diffcoeff_build_denom_dif:nn #1#2
{
- \tl_if_empty:nTF { #1 }
+ \str_if_eq:nnTF { #1 } { 1 }
+ { \exp_not:o { \l__diffcoeff_opii_tl #2 } }
{
- \EditTemplateDefaults { derivative }
- { DERIV } { #2 }
- \EditInstance { derivative } { ord } { #2 }
+ \int_compare:nNnTF { \tl_count:n { #2 } } = { 1 }
+ { \exp_not:o { \l__diffcoeff_opii_tl {}#2^
+ { \mskip \l__diffcoeff_varsupnudge_tl #1 } } }
+ { \__diffcoeff_wrap_longvars:nn { #1 } { #2 } }
+ \mskip \l__diffcoeff_sep_adj_tl
}
+ }
+\cs_new:Npn \__diffcoeff_wrap_longvars_dv:nn #1#2
+ { \exp_not:o { \l__diffcoeff_opii_tl {{}#2 }^
+ { \mskip \l__diffcoeff_varsupnudge_tl #1 } } }
+\cs_new:Npn \__diffcoeff_wrap_longvars_dvi:nn #1#2
+ {
+ \exp_not:o { \l__diffcoeff_opii_tl \l__diffcoeff_lvw_ldelim_tl #2
+ \l__diffcoeff_lvw_rdelim_tl^{ \mskip \l__diffcoeff_lvsupnudge_tl #1 } }
+ }
+\cs_new:Npn \__diffcoeff_wrap_longvars_dvii:nn #1#2
+ {
+ \exp_not:o { \l__diffcoeff_lvw_ldelim_tl \l__diffcoeff_opii_tl {}#2
+ \l__diffcoeff_lvw_rdelim_tl^{ \mskip \l__diffcoeff_lvsupnudge_tl #1 } }
+ }
+%%%%%%%%%%
+% #1 op+order; #2 denom; #3 diff'iand
+\cs_new:Npn \__diffcoeff_form_deriv:nNN #1#2#3
+ {
+ \bool_if:NTF \l__diffcoeff_append_bool
+ { \l__diffcoeff_frac_tl { #1 } { #2 } #3 }
+ { \l__diffcoeff_frac_tl { #1 #3 } { #2 } }
+ }
+\cs_generate_variant:Nn \__diffcoeff_form_deriv:nNN { x }
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+\file_get:nnNT { diffcoeff.DIF } {} \l_tmpa_tl
+ { \exp_args:Nnno \EditTemplateDefaults { diffcoeff } { DIF } \l_tmpa_tl }
+\exp_args:Nnno \EditTemplateDefaults { diffcoeff } { DIF }
+ \l__diffcoeff_dif_clist
+% Child template with some restricted, some new defaults.
+% #1 object type #2 parent template #3 child template
+% #4 restricted defaults (key=value) #5 new defaults (key=value)
+\NewDocumentCommand \DeclareChildTemplate { m m m m m }
+ {
+ \DeclareRestrictedTemplate {#1} {#2} {#3} {}
+ \EditTemplateDefaults {#1} {#3} {#5}
+ \DeclareRestrictedTemplate {#1} {#3} {#3} {#4}
+ }
+% create new, edit existing templates/instances;
+% #1 edit defaults with (no *) or without (*) inheritance;
+% #2 id: f,s,c,fp, sp, cp, j,l; #3 name; #4 key-value list
+\NewDocumentCommand \difdef { >{ \TrimSpaces } m >{ \TrimSpaces } m m }
+ {
+ \clist_map_inline:nn { #1 }
{
- \IfInstanceExistTF { derivative } { ord.#1 }
- { \EditInstance { derivative } { ord.#1 } { #2 } }
+ \tl_if_empty:nTF { #2 }
{
- \DeclareInstance { derivative } { ord.#1 }
- { DERIV } { #2 }
+ \DeclareChildTemplate { diffcoeff }
+ { DIF\str_uppercase:n {##1} } { DIF\str_uppercase:n {##1} }
+ { style-group = \use_i:nn ##1 \c_empty_tl } { #3 }
+ \DeclareInstance { diffcoeff } { dif##1 }
+ { DIF\str_uppercase:n {##1} } {}
+ }
+ {
+ \IfInstanceExistTF { diffcoeff } { dif##1.#2 }
+ { \EditInstance { diffcoeff } { dif##1.#2 } { #3 } }
+ { \exp_args:Nnnx
+ \DeclareInstance { diffcoeff } { dif##1.#2 }
+ { DIF\str_uppercase:n {##1} } { #3 }
+ }
}
}
}
-% relic from version 1
-\NewDocumentCommand \diffset { o }
- { \msg_warning:nn { diffcoeff } { obsolete } }
-
-% ordinary & D
-\DeclareInstance { derivative } { ord } { DERIV } { }
-\bool_if:NTF \l__diffcoeff_ISO_bool
- {
- \diffdef { }
- {
- op-symbol = \mathrm{d},
- op-order-sep = 0 mu ,
- left-delim = \left ( ,
- right-delim = \right ) ,
- subscr-nudge = -6 mu
- }
- \diffdef { D } { op-symbol = \mathrm{D} }
+\DeclareDocumentCommand \diffdef { m m }
+ {
+ \msg_error:nnnn { diffcoeff } { version-conflict } { \diffdef~(two~
+ arguments) } { Use~\difdef~(three~arguments)~instead.~ }
}
- { \diffdef { D } { op-symbol = D } }
-
-% partial
-\diffdef { p }
+\DeclareChildTemplate { diffcoeff } { DIF } { DIFF }
+ { style-group = f } {}
+\DeclareChildTemplate { diffcoeff } { DIFF } { DIFFP }
+ { style-group = f }
+ {
+ op-symbol = \partial,
+ op-order-nudge = 1 mu,
+ *italic-nudge = 3 mu
+ }
+\DeclareChildTemplate { diffcoeff } { DIF } { DIFS }
+ { style-group = s }
{
- op-symbol = \partial ,
- left-delim = \left ( ,
- right-delim = \right ) ,
- subscr-nudge = -6 mu
+ style = /,
+ derivand-sep = 2 mu plus 1 mu minus 2 mu,
+ outer-Ldelim = (,
+ outer-Rdelim = ),
+ sub-nudge = 0 mu,
+ *inner-wrap = true
+ }
+\DeclareChildTemplate { diffcoeff } { DIFS } { DIFSP }
+ { style-group = s }
+ {
+ op-symbol = \partial,
+ op-order-nudge = 1 mu
}
-\NewDocumentCommand \diffp {} { \diff.p. }
-\NewDocumentCommand \dlp {} { \dl.p. }
-
-% delta
-\diffdef { delta }
+\DeclareChildTemplate { diffcoeff } { DIF } { DIFC }
+ { style-group = c }
+ {
+ style = _ ,
+ derivand-sep = 1 mu plus 1 mu minus 1 mu ,
+ multi-term-sep = 1 mu ,
+ term-sep-adjust = 0 mu ,
+ outer-Ldelim = \bigl (,
+ outer-Rdelim = \bigr ),
+ sub-nudge = -2 mu
+ }
+\DeclareChildTemplate { diffcoeff } { DIFC } { DIFCP }
+ { style-group = c }
+ {
+ op-symbol = \partial,
+ op-order-nudge = 1 mu
+ }
+\DeclareInstance { diffcoeff } { diff } { DIFF } {}
+\DeclareInstance { diffcoeff } { diffp } { DIFFP } {}
+\DeclareInstance { diffcoeff } { difs } { DIFS } {}
+\DeclareInstance { diffcoeff } { difsp } { DIFSP } {}
+\DeclareInstance { diffcoeff } { difc } { DIFC } {}
+\DeclareInstance { diffcoeff } { difcp } { DIFCP } {}
+% jacobian
+\DeclareChildTemplate { diffcoeff } { DIF } { DIFJ }
+ { style-group = j }
{
- op-symbol = \delta ,
- op-order-sep = 0 mu
+ op-symbol = \partial,
+ outer-Ldelim = ,
+ outer-Rdelim =
}
-\diffdef { Delta }
- {
- op-symbol = \Delta ,
- op-order-sep = 0 mu
+\DeclareInstance { diffcoeff } { difj } { DIFJ } {}
+% differential
+\DeclareChildTemplate { diffcoeff } { DIF } { DIFL }
+ { style-group = l }
+ {
+ style = dl ,
+ derivand-sep = 0 mu,
+ long-var-wrap = dv ,
+ outer-Ldelim = {\,},
+ outer-Rdelim =
}
-% for compatibility with version 1
-\NewDocumentCommand \Diff { } { \diff.D. }
-\NewDocumentCommand \diffd { } { \diff.delta. }
-\NewDocumentCommand \Diffd { } { \diff.Delta. }
+\DeclareInstance { diffcoeff } { difl } { DIFL } {}
-% user-defined
-\file_if_exist:nT { \g__diffcoeff_def_tl.def }
+\file_if_exist:nTF { \g__diffcoeff_def_tl.def }
{ \file_input:n { \g__diffcoeff_def_tl.def } }
-%%%%%%%%%%%%%%%%%%%%
-% Jacobian
-\NewDocumentCommand \jacob { m t/ m }
- {
- \group_begin:
- \IfBooleanTF #2
- { \partial(#1) / \partial(#3) }
- { \frac{ \partial(#1) } { \partial(#3) } }
- \group_end:
+ {
+ \tl_if_empty:NF \g__diffcoeff_def_tl
+ { \msg_note:nnx { diffcoeff } { file-not-found }
+ { \g__diffcoeff_def_tl } }
}
-%%%%%%%%%%%%%%%%%%%%
-% messages
-\msg_new:nnn { diffcoeff } { order-specification }
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+\NewDocumentCommand \negmu {} { \mskip -1 mu }
+\NewDocumentCommand \nilmu {} { \mskip 0 mu }
+\NewDocumentCommand \onemu {} { \mskip 1 mu }
+\NewDocumentCommand \twomu {} { \mskip 2 mu }
+\NewDocumentCommand \difstfrac { s m m }
+ { \__diffcoeff_slashfracs:Nnnn #1 { #2 } { #3 } {} }
+\NewDocumentCommand \difsbfrac { o s m m }
+ { \__diffcoeff_slashfracs:Nnnn #2 { #3 } { #4 } { \use:c{#1} } }
+\NewDocumentCommand \difsafrac { s m m }
+ { \__diffcoeff_slashfracs:Nnnn #1 { \left. #2\vphantom{#3} }
+ { #3\right.} { \middle } }
+\cs_new:Npn \__diffcoeff_slashfracs:Nnnn #1#2#3#4
{
- #3~followed~by~#2~in~the~order~specification~[#1]~\msg_line_context:.~
- Diffcoeff~cannot~calculate~the~overall~order~of~differentiation~in~
- this~case.~Use~the~order-override~option~to~enter~the~overall~order.
+ \bool_if:NT #1 { \l__diffcoeff_lopwrap_tl }
+ #2 \mskip \l__diffcoeff_slashsep_tl
+ #4 \l__diffcoeff_slashtok_tl
+ \mskip \l__diffcoeff_slashsep_tl #3
+ \bool_if:NT #1 { \l__diffcoeff_ropwrap_tl }
+ }
+% derivatives
+% #1(tl) variant name; #2(*) append boolean; #3(*) switch #5#6 order;
+% #4(clist) diff. orders; #5(tl) = derivand; #6(clist) = diff. vars;
+% #7(tl) = pt of eval./vars held const
+\clist_map_inline:nn { f,s,c, fp, sp, cp }
+ {
+ \exp_args:Nc \NewDocumentCommand {dif#1}
+ { >{\TrimSpaces} D..{} s s O{1} >{\TrimSpaces} m m !o }
+ {
+ \IfBooleanTF ##3
+ { \__diffcoeff_inputs:nnnnnnn {#1}
+ {##1} {##2} {##4} {##6} {##5} {##7} }
+ { \__diffcoeff_inputs:nnnnnnn {#1}
+ {##1} {##2} {##4} {##5} {##6} {##7} }
+ }
}
-\msg_new:nnn { diffcoeff } { obsolete }
- {
- Obsolete~command:~\diffset is~superseded~by~the~\diffdef\
- command.~\msg_see_documentation_text:n { diffcoeff }
+\cs_new_protected:Npn \__diffcoeff_inputs:nnnnnnn #1#2#3#4#5#6#7
+ {
+ \group_begin:
+ \tl_set:Nx \l__diffcoeff_instance_tl
+ { dif#1 \tl_if_empty:nF { #2 } { .#2 } }
+ \UseInstance { diffcoeff } { \l__diffcoeff_instance_tl }
+ {#3} {#4} {#5} {#6} {#7}
+ \group_end:
}
-\msg_new:nnn { diffcoeff } { numbers-conflict }
+\NewDocumentCommand \difoverride { >{\TrimSpaces} m }
+ { \tl_set:Nn \l__diffcoeff_override_tl { #1 } }
+% Jacobian
+\NewDocumentCommand \jacob { >{\TrimSpaces} D..{} m m }
{
- #2~orders~of~differentiation~specified~for~#1~variables;~
- orders~[#3]\ (\msg_line_context:)~for~variables~#4.
+ \group_begin:
+ \int_zero:N \l__diffcoeff_spaced_int
+ \tl_set:Nx \l__diffcoeff_instance_tl
+ { difj \tl_if_empty:nF { #1 } { .#1 } }
+ \UseInstance { diffcoeff } { \l__diffcoeff_instance_tl }
+ { \c_false_bool } {}
+ { \l__diffcoeff_lvw_ldelim_tl #2 \l__diffcoeff_lvw_rdelim_tl }
+ { {\l__diffcoeff_lvw_ldelim_tl #3\l__diffcoeff_lvw_rdelim_tl } } {}
+ \group_end:
+ }
+% differential; #1 variant ; #2 ord(s); #3 vars; #4 exponent
+\NewDocumentCommand \dl { >{ \TrimSpaces } D..{} O{1} m e{^} }
+ {
+ \group_begin:
+ \tl_set:Nx \l__diffcoeff_instance_tl
+ { difl \tl_if_empty:nF { #1 } { .#1 } }
+ \difoverride {}
+ \tl_set:Nn \l__diffcoeff_exponent_tl { #4 }
+ \tl_if_novalue:nTF {#4}
+ { \bool_set_false:N \l__diffcoeff_exponent_bool }
+ { \bool_set_true:N \l__diffcoeff_exponent_bool }
+ \UseInstance { diffcoeff } { \l__diffcoeff_instance_tl }
+ {\c_false_bool} {#2} {} {#3} {}
+ \group_end:
}
% end of file diffcoeff.sty \ No newline at end of file
diff --git a/Master/texmf-dist/tex/latex/diffcoeff/diffcoeff4.sty b/Master/texmf-dist/tex/latex/diffcoeff/diffcoeff4.sty
new file mode 100644
index 00000000000..3125ae59028
--- /dev/null
+++ b/Master/texmf-dist/tex/latex/diffcoeff/diffcoeff4.sty
@@ -0,0 +1,744 @@
+% This is file `diffcoeff4.sty'.
+%
+% This work may be distributed and/or modified under the conditions
+% of the LaTeX Project Public License, either version 1.3c
+% (2008-05-04) of this license or any later version; see
+% http://www.latex-project.org/lppl.txt
+%
+% Andrew Parsloe ajparsloe@gmail.com
+%
+\RequirePackage{expl3}
+\RequirePackage{xparse,l3keys2e,xtemplate}
+\ProvidesExplPackage {diffcoeff4} {2022/07/30} {4.2}
+ {Write differential coefficients easily and consistently.}
+%
+\keys_define:nn { diffcoeff4 }
+ {
+ ISO .bool_set:N = \l__diffcoeff_ISO_bool,
+ spaced .int_set:N = \l__diffcoeff_spaced_int,
+ spaced .default:n = 1,
+ spaced .initial:n = 0,
+ def-file .tl_gset:N = \g__diffcoeff_def_tl,
+ def-file .initial:n = diffcoeff,
+ def-file .default:n = diffcoeff
+ }
+\ProcessKeysPackageOptions { diffcoeff4 }
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+\cs_generate_variant:Nn \tl_if_eq:nnTF { nV }
+
+\tl_new:N \l__diffcoeff_oporder_tl
+\tl_new:N \l__diffcoeff_derivand_tl
+\tl_new:N \l__diffcoeff_type_tl
+\tl_new:N \l__diffcoeff_tot_order_tl
+\tl_new:N \l__diffcoeff_curr_num_tl
+\tl_new:N \l__diffcoeff_curr_var_tl
+\tl_new:N \l__diffcoeff_paren_tl
+
+\tl_const:Nn \c__diffcoeff_digits_tl { 1234567890 }
+
+\seq_new:N \l__diffcoeff_orders_seq
+\seq_new:N \l__diffcoeff_vars_seq
+\seq_new:N \l__diffcoeff_denom_seq
+\seq_new:N \l__diffcoeff_paren_seq
+
+\prop_new:N \l__diffcoeff_vars_prop
+
+\bool_new:N \l__diffcoeff_op_left_bool
+\bool_new:N \l__diffcoeff_single_var_bool
+\bool_new:N \l__diffcoeff_opwrap_bool
+\bool_new:N \l__diffcoeff_integ_bool
+\bool_new:N \l__diffcoeff_spaced_bool
+\bool_new:N \l__diffcoeff_altsep_bool
+
+\int_new:N \l__diffcoeff_vars_int
+\int_new:N \l__diffcoeff_format_int
+\int_new:N \l__diffcoeff_curr_tok_int
+\int_new:N \l__diffcoeff_curr_state_int
+\int_new:N \l__diffcoeff_nos_int
+\int_new:N \l__diffcoeff_parenvar_int
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+\DeclareObjectType { derivative } { 3 }
+
+% defaults: ordinary deriv. values
+\DeclareTemplateInterface { derivative } { DERIV } { 3 }
+ {
+ op-symbol : tokenlist = d ,
+ op-symbol-alt : tokenlist = \KeyValue { op-symbol },
+ op-order-sep : muskip = 1 mu ,
+ derivand-sep : muskip = 3 mu plus 1 mu minus 2 mu,
+ long-var-wrap : choice { dv, d(v), (dv) }
+ = d(v) ,
+ denom-term-sep : muskip = 2 mu ,
+ term-sep-adjust : muskip = -1 mu ,
+ left-delim : tokenlist = \left . ,
+ right-delim : tokenlist = \right |,
+ elbowroom : muskip = 0 mu ,
+ subscr-nudge : muskip = 0 mu ,
+ *-derivand-sep : muskip = \KeyValue { derivand-sep },
+ *-op-left : boolean = false ,
+ *-italic-nudge : muskip = 3 mu ,
+ /-derivand-sep : muskip = \KeyValue { derivand-sep },
+ /-denom-term-sep : muskip = 1 mu ,
+ /-left-delim : tokenlist = ( ,
+ /-right-delim : tokenlist = ) ,
+ /-elbowroom : muskip = 0 mu ,
+ /-subscr-nudge : muskip = 0 mu ,
+ */-derivand-sep : muskip = \KeyValue { /-derivand-sep },
+ */-op-wrap : boolean = true
+ }
+% #1 order spec(seqvar); #2 order override(tlvar)
+% #3 derivand(tlvar); #4 denominator(seqvar)
+% #5 subscript(tlvar)
+\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_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,
+ left-delim = \l__diffcoeff_ldelim_tl,
+ right-delim = \l__diffcoeff_rdelim_tl,
+ elbowroom = \l__diffcoeff_elbowrm_muskip ,
+ subscr-nudge = \l__diffcoeff_subnudge_muskip,
+ *-derivand-sep = \l__diffcoeff_derivsepi_muskip,
+ *-op-left = \l__diffcoeff_op_left_bool,
+ *-italic-nudge = \l__diffcoeff_opnudge_muskip,
+ /-derivand-sep = \l__diffcoeff_derivsepii_muskip,
+ /-denom-term-sep = \l_tmpb_muskip,
+ /-left-delim = \l__diffcoeff_ldelimi_tl,
+ /-right-delim = \l__diffcoeff_rdelimi_tl,
+ /-elbowroom = \l_tmpc_muskip,
+ /-subscr-nudge = \l_tmpd_muskip,
+ */-derivand-sep = \l__diffcoeff_derivsepiii_muskip,
+ */-op-wrap = \l__diffcoeff_opwrap_bool
+ }
+ {
+ \AssignTemplateKeys
+
+ \bool_if:NF\l__diffcoeff_integ_bool
+ {
+ \int_compare:nNnT { \l__diffcoeff_format_int } > { 1 }
+ { \__diffcoeff_slash_vals: }
+ \__diffcoeff_build:nnn { #1 } { #2 } { #3 }
+ }
+ }
+%%%%%%%%%%
+\cs_new:Npn \__diffcoeff_slash_vals:
+ {
+ \muskip_set:Nn \l__diffcoeff_varsep_muskip \l_tmpb_muskip
+ \muskip_set:Nn \l__diffcoeff_elbowrm_muskip \l_tmpc_muskip
+ \muskip_set:Nn \l__diffcoeff_subnudge_muskip \l_tmpd_muskip
+ \tl_set:NV \l__diffcoeff_ldelim_tl \l__diffcoeff_ldelimi_tl
+ \tl_set:NV \l__diffcoeff_rdelim_tl \l__diffcoeff_rdelimi_tl
+ }
+% #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 &&
+ \int_compare_p:nNn { \l__diffcoeff_format_int } > { 1 }
+ }
+ { \int_set:Nn \l__diffcoeff_format_int { 4 } }
+ \__diffcoeff_spaced:n { \l__diffcoeff_spaced_int }
+ \bool_if:nTF
+ {
+ ( \l__diffcoeff_altsep_bool && !\l__diffcoeff_spaced_bool )
+ || ( !\l__diffcoeff_altsep_bool && \l__diffcoeff_spaced_bool )
+ }
+ { \__diffcoeff_derivsep: }
+ { \tl_put_left:Nn \l__diffcoeff_derivand_tl { \mskip 0 mu } }
+ \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 \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 \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
+ }
+ \tl_if_novalue:nF { #3 }
+ {
+ \mskip \l__diffcoeff_elbowrm_muskip \l__diffcoeff_rdelim_tl
+ \tl_if_empty:nF { #3 }
+ {
+ \c_math_subscript_token
+ { \mskip \l__diffcoeff_subnudge_muskip { #3 } }
+ }
+ }
+ }
+%%%%%%%%%%%%%%%%%%%%
+\cs_new_protected:Npn \__diffcoeff_spaced:n #1
+ {
+ \int_case:nn { \int_sign:n { #1 } }
+ {
+ { 1 } { \bool_set_true:N \l__diffcoeff_spaced_bool }
+ { 0 } { \bool_set_false:N \l__diffcoeff_spaced_bool }
+ { -1 }
+ {
+ \int_compare:nNnTF { 1 } <
+ { \tl_count:N \l__diffcoeff_derivand_tl }
+ { \bool_set_true:N \l__diffcoeff_spaced_bool }
+ { \bool_set_false:N \l__diffcoeff_spaced_bool }
+ }
+ }
+ }
+\cs_new_protected:Npn \__diffcoeff_derivsep:
+ {
+ \tl_put_left:Nx \l__diffcoeff_derivand_tl
+ {
+ \int_case:nn { \l__diffcoeff_format_int }
+ {
+ { 0 } { \mskip \l__diffcoeff_derivsep_muskip }
+ { 1 } { \mskip \l__diffcoeff_derivsepi_muskip }
+ { 2 } { \mskip \l__diffcoeff_derivsepii_muskip }
+ { 3 } { \mskip \l__diffcoeff_derivsepiii_muskip }
+ { 4 } { \mskip \l__diffcoeff_derivsepiii_muskip }
+ }
+ }
+ }
+\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 } } }
+ {
+ \int_compare:nNnTF { \tl_count:n { #2 } } = { 1 }
+ {
+ \seq_put_right:Nn \l__diffcoeff_denom_seq
+ { \l__diffcoeff_op_alt_tl { #2 }^{ #1 } }
+ }
+ {
+ \seq_put_right:Nn \l__diffcoeff_denom_seq
+ { \__diffcoeff_wrap_longvars:nn { #1\vphantom{)} } { #2 } }
+ }
+ }
+ }
+% #1 order(tlvar) ; #2 diff'iand(tlvar); #3 denom(tlvar)
+\cs_new:Npn \__diffcoeff_single:NNN #1#2#3
+ {
+ \__diffcoeff_numer:N { #1 }
+ \__diffcoeff_form_deriv:NNn
+ \l__diffcoeff_oporder_tl
+ \l__diffcoeff_derivand_tl
+ { \__diffcoeff_denom_single:NN #1 #3 }
+ }
+% #1 total order; #2 derivand; #3 denom seq
+\cs_new_protected:Npn \__diffcoeff_mixed:NNN #1#2#3
+ {
+ \__diffcoeff_numer:N #1
+ \__diffcoeff_form_deriv:NNn
+ \l__diffcoeff_oporder_tl
+ \l__diffcoeff_derivand_tl
+ { \__diffcoeff_denom_sep:N #3 }
+ }
+\cs_new:Npn \__diffcoeff_denom_sep:N #1
+ {
+ \int_zero:N \l_tmpa_int
+ \seq_map_inline:Nn #1
+ {
+ \int_incr:N \l_tmpa_int ##1
+ \int_compare:nNnT { \l_tmpa_int } < { \l__diffcoeff_vars_int }
+ {
+ \seq_pop:NN \l__diffcoeff_orders_seq \l_tmpa_tl
+ \str_if_eq:VnTF \l_tmpa_tl { 1 }
+ { \mskip \l__diffcoeff_varsep_muskip }
+ {
+ \mskip \muskip_eval:n { \l__diffcoeff_varsep_muskip +
+ \l__diffcoeff_sep_adj_muskip }
+ }
+ }
+ }
+ }
+% #1(tl) total order
+\cs_new_protected:Npn \__diffcoeff_numer:N #1
+ {
+ \bool_if:NTF \l__diffcoeff_op_left_bool
+ {
+ \tl_set:Nn \l__diffcoeff_oporder_tl
+ { \mskip \l__diffcoeff_opnudge_muskip }
+ }
+ { \tl_clear:N \l__diffcoeff_oporder_tl }
+ \tl_put_right:No \l__diffcoeff_oporder_tl \l__diffcoeff_op_tl
+ \exp_args:NnV \tl_if_eq:nnF { 1 } #1
+ {
+ \tl_put_right:Nn \l__diffcoeff_oporder_tl
+ { \mskip \l__diffcoeff_oporder_muskip ^ { #1 } }
+ }
+ \bool_if:NT \l__diffcoeff_op_left_bool
+ { \tl_put_right:Nn \l__diffcoeff_oporder_tl { \hfill } }
+ }
+% #1 order; #2 var
+\cs_new_protected:Npn \__diffcoeff_denom_single:NN #1#2
+ {
+ \tl_if_eq:nVTF { 1 } #1
+ { \l__diffcoeff_op_alt_tl {}#2 }
+ {
+ \int_compare:nNnTF { \tl_count:N #2 } = { 1 }
+ { \l__diffcoeff_op_alt_tl {}#2^{ #1 } }
+ { \__diffcoeff_wrap_longvars:nn { #1\vphantom) } { #2 } }
+ }
+ }
+% #1 op+order; #2 diff'iand; #3 denom
+% 0 frac; 1 frac append; 2 slash ; 3 ( slash ) append; 4 slash append
+\cs_new:Npn \__diffcoeff_form_deriv:NNn #1#2#3
+ {
+ \int_case:nn { \l__diffcoeff_format_int }
+ {
+ { 0 } { \frac { #1 #2 } { #3 } }
+ { 1 } { \frac { #1 } { #3 } #2 }
+ { 2 } { #1 #2 / #3 }
+ { 3 } { ( #1 / #3 ) #2 }
+ { 4 } { #1 / #3 #2 }
+ }
+ }
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% differential
+% #1 variant; #2 = space in mu before d (0--9)
+% note \group_end placement for \vec{x} etc
+\NewDocumentCommand \dl { d.. t- m }
+ {
+ \group_begin:
+ \bool_set_true:N \l__diffcoeff_integ_bool
+ \bool_set_true:N \l__diffcoeff_single_var_bool
+ \seq_set_from_clist:Nn \l__diffcoeff_orders_seq { 1 }
+ \tl_set:Nn \l__diffcoeff_tot_order_tl { 1 }
+ \IfValueTF { #1 }
+ { \tl_set:Nn \l__diffcoeff_type_tl { .#1 } }
+ { \tl_set:Nn \l__diffcoeff_type_tl { } }
+ \UseInstance { derivative } { ord\l__diffcoeff_type_tl }
+ \c_empty_tl \c_empty_seq \c_empty_tl
+ \tl_if_in:NnTF \c__diffcoeff_digits_tl { #3 }
+ { \mskip \IfBooleanT #2 { - }#3 mu \l__diffcoeff_op_tl \group_end: }
+ { \l__diffcoeff_op_tl \group_end: {} #3 }
+ }
+\NewDocumentCommand \negmu {} { \mskip -1 mu }
+\NewDocumentCommand \nilmu {} { \mskip 0 mu }
+\NewDocumentCommand \onemu {} { \mskip 1 mu }
+\NewDocumentCommand \twomu {} { \mskip 2 mu }
+% derivative
+% #1(tl) = name of variant; #2(*)= append diff'iand boolean
+% #3(clist) = orders of diff. in each var.; #4(tl) = order override
+% #5(bool) spacing switch; #6(tl) = diff'iand; #7( / ) = slash boolean
+% #8(clist) = vars of diff.; #9(tl) = pt of eval./vars held const
+\NewDocumentCommand \diff { d.. s O{1} o t! >{\TrimSpaces} m t/ m !o }
+ {
+ \group_begin:
+ \IfBooleanTF #5
+ { \bool_set_true:N \l__diffcoeff_altsep_bool }
+ { \bool_set_false:N \l__diffcoeff_altsep_bool }
+ \seq_set_from_clist:Nn \l__diffcoeff_orders_seq { #3 }
+ \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 }
+ {
+ \int_compare:nNnTF { \l__diffcoeff_vars_int } < { \l_tmpb_int }
+ {
+ \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 { , } }
+ { \clist_use:nn { #8 } { , } }
+ }
+ { % pad orders seq if nec.
+ \int_step_inline:nnnn
+ { 1 + \l_tmpb_int } { 1 } { \l__diffcoeff_vars_int }
+ { \seq_put_right:Nn \l__diffcoeff_orders_seq { 1 } }
+ }
+ }
+ % override/calc total order
+ \IfValueTF { #4 }
+ { \tl_set:Nn \l__diffcoeff_tot_order_tl { #4 } }
+ {
+ \bool_if:NTF \l__diffcoeff_single_var_bool
+ { \tl_set:Nn \l__diffcoeff_tot_order_tl { #3 } }
+ {
+ \__diffcoeff_calc_tot_order:NN \l__diffcoeff_orders_seq
+ \l__diffcoeff_tot_order_tl
+ }
+ }
+ \IfValueTF { #1 }
+ { \tl_set:Nn \l__diffcoeff_type_tl { .#1 } }
+ { \tl_set:Nn \l__diffcoeff_type_tl { } }
+ % append? slash?
+ \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 } {#6}{#8}{#9}
+ \group_end:
+ } % end of \diff
+%%%%%%%%%%%%%%%%%%%
+% #2(seq) expr in; #1(tlv) expr out
+\cs_new:Npn \__diffcoeff_calc_tot_order:NN #1 #2
+ {
+ \tl_clear:N \l__diffcoeff_nos_tl
+ \exp_args:Nx\__diffcoeff_digest_expr:n { \seq_use:Nn #1 { + } }
+ \prop_if_empty:NTF \l__diffcoeff_vars_prop
+ { \tl_set:NV #2 \l__diffcoeff_nos_tl }
+ { \__diffcoeff_evaluate:NN \l__diffcoeff_vars_prop #2 }
+ }
+\cs_new:Npn \__diffcoeff_digest_expr:n #1
+ {
+ \tl_set:Nn \l__diffcoeff_curr_num_tl { + }
+ \tl_set:Nn \l__diffcoeff_paren_tl { +1 }
+ \tl_set:Nn \l__diffcoeff_nos_tl { 0 }
+ \int_zero:N \l__diffcoeff_curr_state_int
+ \int_zero:N \l__diffcoeff_curr_tok_int
+ \tl_map_inline:nn { #1+ }
+ {
+ \__diffcoeff_get_curr_ndx:nN { ##1 } \l__diffcoeff_curr_tok_int
+ \__diffcoeff_transitions:nNN { ##1 }
+ \l__diffcoeff_curr_state_int \l__diffcoeff_curr_tok_int
+ }
+ \int_set:Nn \l__diffcoeff_nos_int { \l__diffcoeff_nos_tl }
+ \tl_set:Nx \l__diffcoeff_nos_tl { \int_use:N \l__diffcoeff_nos_int }
+ \int_compare:nNnT { \l__diffcoeff_nos_int } = { 0 }
+ { \tl_clear:N \l__diffcoeff_nos_tl }
+ }
+% #1 curr tok (tl); #2 <== curr tok ndx (int)
+\cs_new_protected:Npn \__diffcoeff_get_curr_ndx:nN #1#2
+ {
+ \tl_if_in:NnTF \c__diffcoeff_digits_tl { #1 }
+ { \int_set:Nn #2 { 1 } } % digit
+ {
+ \str_case:nnF { #1 }
+ {
+ { + } { \int_set:Nn #2 { 0 } }
+ { - } { \int_set:Nn #2 { 0 } }
+ { ( } { \int_set:Nn #2 { 3 } }
+ { ) } { \int_set:Nn #2 { 4 } }
+ }
+ { \int_set:Nn #2 { 2 } } % var
+ }
+ }
+% #1(tl) curr tok; #2(int) curr state; #3(int) curr tok ndx
+\cs_new:Npn \__diffcoeff_transitions:nNN #1#2#3
+ {
+ \int_case:nn { #2 }
+ {
+ { 0 } % sgn + -
+ { \__diffcoeff_sgn_transitions:nNN { #1 }#2#3 }
+ { 1 } % num
+ { \__diffcoeff_num_transitions:nNN { #1 }#2#3 }
+ { 2 } % alg
+ { \__diffcoeff_alg_transitions:nNN { #1 }#2#3 }
+ { 4 } % )
+ { \__diffcoeff_rpar_transitions:nNN { #1 }#2#3 }
+ }
+ }
+% transitions from the signed state
+% #1(tl) curr tok; #2(int) 0, curr state; #3 curr tok ndx
+\cs_new_protected:Npn \__diffcoeff_sgn_transitions:nNN #1#2#3
+ {
+ \int_case:nnT { #3 }
+ {
+ { 0 } % tok = s
+ {
+ \tl_if_eq:nVTF { #1 } \l__diffcoeff_curr_num_tl
+ { \tl_set:Nn \l__diffcoeff_curr_num_tl { + } }
+ { \tl_set:Nn \l__diffcoeff_curr_num_tl { - } }
+ }
+ { 1 } % tok = d
+ { \tl_put_right:Nn \l__diffcoeff_curr_num_tl { #1 } }
+ { 2 } % tok = v
+ {
+ \tl_put_right:Nn \l__diffcoeff_curr_num_tl { 1 }
+ \tl_set:Nn \l__diffcoeff_curr_var_tl { #1 }
+ }
+ { 3 } % tok = (
+ {
+ \seq_push:NV \l__diffcoeff_paren_seq \l__diffcoeff_paren_tl
+ \tl_put_left:NV \l__diffcoeff_paren_tl \l__diffcoeff_curr_num_tl
+ \tl_set:Nn \l__diffcoeff_curr_num_tl { + }
+ \int_set:Nn #3 { 0 }
+ }
+ }
+ { \int_set_eq:NN #2 #3 }
+ }
+% transitions from the numeric state
+% #1 = curr. tok.; #2 = 0, curr. state; #3 curr. tok. index
+\cs_new_protected:Npn \__diffcoeff_num_transitions:nNN #1#2#3
+ {
+ \int_case:nnT { #3 }
+ {
+ { 0 } % tok = s
+ {
+ \tl_put_right:NV\l__diffcoeff_nos_tl
+ { \l__diffcoeff_paren_tl * \l__diffcoeff_curr_num_tl }
+ \tl_set:Nn \l__diffcoeff_curr_num_tl { #1 }
+ }
+ { 1 } % tok = d
+ { \tl_put_right:Nn \l__diffcoeff_curr_num_tl { #1 } }
+ { 2 } % tok = v
+ {
+ \tl_if_in:nnTF { ^ \times * / \div } { #1 }
+ {
+ \msg_error:nnxxx { diffcoeff } { order-specification }
+ { \seq_use:Nn \l__diffcoeff_orders_seq { , } }
+ { #1 } { number }
+ }
+ { \tl_set:Nn \l__diffcoeff_curr_var_tl { #1 } }
+ }
+ { 3 } % tok = (
+ {
+ \seq_push:NV \l__diffcoeff_paren_seq \l__diffcoeff_paren_tl
+ \tl_put_left:Nn \l__diffcoeff_paren_tl { * }
+ \tl_put_left:NV \l__diffcoeff_paren_tl \l__diffcoeff_curr_num_tl
+ \tl_set:Nn \l__diffcoeff_curr_num_tl { + }
+ \int_set:Nn #3 { 0 }
+ }
+ { 4 } % tok = )
+ {
+ \tl_put_right:NV \l__diffcoeff_nos_tl
+ { \l__diffcoeff_paren_tl * \l__diffcoeff_curr_num_tl }
+ }
+ }
+ {
+ \int_set_eq:NN #2 #3 }
+ }
+% transitions from the algebraic state
+% #1 = curr. tok.; #2 = 2, curr. state; #3 curr. tok. index
+\cs_new:Npn \__diffcoeff_alg_transitions:nNN #1#2#3
+ {
+ \int_case:nnT { #3 }
+ {
+ { 0 } % tok = s
+ {
+ \int_compare:nNnTF { \l__diffcoeff_parenvar_int } = { 0 }
+ {
+ \__diffcoeff_store_var:NNN \l__diffcoeff_curr_var_tl
+ \l__diffcoeff_paren_tl \l__diffcoeff_curr_num_tl
+ \tl_clear:N \l__diffcoeff_curr_var_tl
+ \tl_set:Nn \l__diffcoeff_curr_num_tl { #1 }
+ }
+ {
+ \tl_put_right:Nn \l__diffcoeff_curr_var_tl { #1 }
+ \int_set:Nn #3 { 2 }
+ }
+ }
+ { 1 } % tok = d
+ {
+ \tl_put_right:Nn \l__diffcoeff_curr_var_tl { #1 }
+ \int_set:Nn #3 { 2 }
+ }
+ { 2 } % tok = v
+ { \tl_put_right:Nn \l__diffcoeff_curr_var_tl { #1 } }
+ { 3 } % tok = (
+ {
+ \tl_put_right:Nn \l__diffcoeff_curr_var_tl { #1 }
+ \int_set:Nn #3 { 2 }
+ \int_incr:N \l__diffcoeff_parenvar_int
+ }
+ { 4 } % tok = )
+ {
+ \int_compare:nNnTF { \l__diffcoeff_parenvar_int } = { 0 }
+ {
+ \__diffcoeff_store_var:NNN \l__diffcoeff_curr_var_tl
+ \l__diffcoeff_paren_tl \l__diffcoeff_curr_num_tl
+ \tl_clear:N \l__diffcoeff_curr_var_tl
+ }
+ {
+ \tl_put_right:Nn \l__diffcoeff_curr_var_tl { #1 }
+ \int_set:Nn #3 { 2 }
+ \int_decr:N \l__diffcoeff_parenvar_int
+ }
+ }
+ }
+ { \int_set_eq:NN #2 #3 }
+ }
+% transitions from the ) state
+% #1 = curr. tok.; #2 = 4, curr. state; #3 curr. tok. index
+\cs_new:Npn \__diffcoeff_rpar_transitions:nNN #1#2#3
+ {
+ \int_compare:nNnTF { \int_mod:nn { #3 } { 4} } = { 0 }
+ {
+ \tl_set:Nn \l__diffcoeff_curr_num_tl { #1 }
+ \seq_pop:NN \l__diffcoeff_paren_seq \l__diffcoeff_paren_tl
+ \int_set_eq:NN #2 #3
+ }
+ {
+ \msg_error:nnxxx { diffcoeff } { order-specification }
+ { \seq_use:Nn \l__diffcoeff_orders_seq { , } } { #1 } { ) }
+ }
+ }
+% #1 is var. (tlvar); #2 is num. (tlvar); #3 num. coeff. (tlvar)
+\cs_new:Npn \__diffcoeff_store_var:NNN #1#2#3
+ {
+ \prop_get:NVNF \l__diffcoeff_vars_prop #1 \l_tmpa_tl
+ { \tl_clear:N \l_tmpa_tl }
+ \tl_put_right:NV \l_tmpa_tl { #2 * #3 }
+ \prop_put:NVV \l__diffcoeff_vars_prop #1 \l_tmpa_tl
+ }
+% #1 (propv) key=var, val=coeff; #2 <= total order
+\cs_new_protected:Npn \__diffcoeff_evaluate:NN #1#2
+ {
+ \prop_map_inline:Nn #1 { \seq_put_left:Nn \l_tmpa_seq { ##1 } }
+ \seq_sort:Nn \l_tmpa_seq
+ {
+ \int_compare:nNnTF { \tl_count:n { ##1 } } < { \tl_count:n { ##2 } }
+ { \sort_return_same: } { \sort_return_swapped: }
+ }
+ \seq_map_inline:Nn \l_tmpa_seq
+ {
+ \prop_pop:NnN #1 { ##1 } \l_tmpb_tl
+ \seq_put_right:Nx \l_tmpb_seq { \int_eval:n \l_tmpb_tl }
+ }
+ \tl_clear:N \l_tmpa_tl
+ \seq_mapthread_function:NNN \l_tmpa_seq \l_tmpb_seq
+ \__diffcoeff_tot_order:nn
+ \exp_args:NV \tl_if_head_eq_charcode:nNTF \l_tmpa_tl +
+ {
+ \tl_set:Nx \l_tmpb_tl { \tl_tail:N \l_tmpa_tl }
+ \int_compare:nNnT { \l__diffcoeff_nos_int } > { 0 }
+ { \tl_put_left:Nn \l__diffcoeff_nos_tl { + } }
+ \tl_concat:NNN #2 \l_tmpb_tl \l__diffcoeff_nos_tl
+ }
+ {
+ \int_compare:nNnTF { \l__diffcoeff_nos_int } > { 0 }
+ { \tl_concat:NNN #2 \l__diffcoeff_nos_tl \l_tmpa_tl }
+ { \tl_concat:NNN #2 \l_tmpa_tl \l__diffcoeff_nos_tl }
+ }
+ \tl_set_rescan:Nno #2 { } #2
+ }
+\cs_new:Npn \__diffcoeff_tot_order:nn #1#2
+ {
+ \int_compare:nNnTF { #2 } > { 0 }
+ {
+ \int_compare:nNnTF { #2 } = { 1 }
+ { \tl_put_left:Nn \l_tmpa_tl { +#1 } }
+ { \tl_put_left:Nn \l_tmpa_tl { +#2#1 } }
+ }
+ {
+ \int_compare:nNnT { #2 } < { 0 }
+ {
+ \int_compare:nNnTF { #2 } = { -1 }
+ { \tl_put_right:Nn \l_tmpa_tl { -#1 } }
+ { \tl_put_right:Nn \l_tmpa_tl { #2#1 } }
+ }
+ }
+ }
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% create new instances or edit existing ones
+% #1 = name; #2 = key-value list
+\NewDocumentCommand \diffdef { > { \TrimSpaces } m m }
+ {
+ \tl_if_empty:nTF { #1 }
+ {
+ \EditTemplateDefaults { derivative }
+ { DERIV } { #2 }
+ \EditInstance { derivative } { ord } { #2 }
+ }
+ {
+ \IfInstanceExistTF { derivative } { ord.#1 }
+ { \EditInstance { derivative } { ord.#1 } { #2 } }
+ {
+ \DeclareInstance { derivative } { ord.#1 }
+ { DERIV } { #2 }
+ }
+ }
+ }
+% relic from version 1
+\NewDocumentCommand \diffset { o }
+ { \msg_warning:nn { diffcoeff } { obsolete } }
+
+% ordinary & D
+\DeclareInstance { derivative } { ord } { DERIV } { }
+\bool_if:NTF \l__diffcoeff_ISO_bool
+ {
+ \diffdef { }
+ {
+ op-symbol = \mathrm{d},
+ op-order-sep = 0 mu ,
+ left-delim = \left ( ,
+ right-delim = \right ) ,
+ subscr-nudge = -6 mu
+ }
+ \diffdef { D } { op-symbol = \mathrm{D} }
+ }
+ { \diffdef { D } { op-symbol = D } }
+
+% partial
+\diffdef { p }
+ {
+ op-symbol = \partial ,
+ left-delim = \left ( ,
+ right-delim = \right ) ,
+ subscr-nudge = -6 mu
+ }
+\NewDocumentCommand \diffp {} { \diff.p. }
+\NewDocumentCommand \dlp {} { \dl.p. }
+
+% delta
+\diffdef { delta }
+ {
+ op-symbol = \delta ,
+ op-order-sep = 0 mu
+ }
+\diffdef { Delta }
+ {
+ op-symbol = \Delta ,
+ op-order-sep = 0 mu
+ }
+% for compatibility with version 1
+\NewDocumentCommand \Diff { } { \diff.D. }
+\NewDocumentCommand \diffd { } { \diff.delta. }
+\NewDocumentCommand \Diffd { } { \diff.Delta. }
+
+% user-defined
+\file_if_exist:nT { \g__diffcoeff_def_tl.def }
+ { \file_input:n { \g__diffcoeff_def_tl.def } }
+%%%%%%%%%%%%%%%%%%%%
+% Jacobian
+\NewDocumentCommand \jacob { m t/ m }
+ {
+ \group_begin:
+ \IfBooleanTF #2
+ { \partial(#1) / \partial(#3) }
+ { \frac{ \partial(#1) } { \partial(#3) } }
+ \group_end:
+ }
+%%%%%%%%%%%%%%%%%%%%
+% messages
+\msg_new:nnn { diffcoeff } { order-specification }
+ {
+ #3~followed~by~#2~in~the~order~specification~[#1]~\msg_line_context:.~
+ Diffcoeff~cannot~calculate~the~overall~order~of~differentiation~in~
+ this~case.~Use~the~order-override~option~to~enter~the~overall~order.
+ }
+\msg_new:nnn { diffcoeff } { obsolete }
+ {
+ Obsolete~command:~\diffset is~superseded~by~the~\diffdef\
+ command.~\msg_see_documentation_text:n { diffcoeff }
+ }
+\msg_new:nnn { diffcoeff } { numbers-conflict }
+ {
+ #2~orders~of~differentiation~specified~for~#1~variables;~
+ orders~[#3]\ (\msg_line_context:)~for~variables~#4.
+ }
+% end of file diffcoeff4.sty \ No newline at end of file
diff --git a/Master/texmf-dist/tex/latex/diffcoeff/diffcoeff5.def b/Master/texmf-dist/tex/latex/diffcoeff/diffcoeff5.def
new file mode 100644
index 00000000000..d61028a4a0b
--- /dev/null
+++ b/Master/texmf-dist/tex/latex/diffcoeff/diffcoeff5.def
@@ -0,0 +1,136 @@
+% file `diffcoef5.def'
+% definitions for variant forms
+% 2023/01/03
+% Andrew Parsloe ajparsloe@gmail.com
+%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% material derivative
+\difdef { f, s } { D }
+ { op-symbol = \mathrm{D} }
+% math italic
+\difdef { f, s, c } { d' }
+ {
+ op-symbol = d,
+ op-order-nudge = 1 mu
+ }
+\difdef { f, s, c } { D' }
+ {
+ op-symbol = D,
+ op-order-nudge = 1 mu
+ }
+% Greek
+\difdef { f, s } { gd }
+ { op-symbol = \delta }
+\difdef { f, s } { gD }
+ { op-symbol = \Delta }
+% spaceless appending
+\difdef { f, fp } { *0 }
+ {
+ *derivand-sep = 0 mu ,
+ outer-Ldelim = \mleft ( ,
+ outer-Rdelim = \mright )
+ }
+% tfrac, nonscalable
+\difdef { f, fp } { t }
+ {
+ style = tfrac ,
+ derivand-sep = 1 mu plus 1 mu minus 1 mu,
+ multi-term-sep = 0 mu ,
+ term-sep-adjust = 0 mu ,
+ lvwrap-sup-nudge = 0 mu ,
+ outer-Ldelim = \bigl (,
+ outer-Rdelim = \bigr ),
+ elbowroom = -2 mu ,
+ sub-nudge = -3 mu
+ }
+% slash fractions: 0=scalable,
+% 1=big, 2=Big, 3=bigg, 4=Bigg
+% but > 1 gives eyesores
+\difdef { s, sp } { 0 }
+ {
+ style = auto ,
+ outer-Ldelim = \left [ ,
+ outer-Rdelim = \right ] ,
+ sub-nudge = 0 mu ,
+ *inner-Ldelim = \mleft ( ,
+ *inner-Rdelim = \mright ),
+ *outer-Ldelim = \left [ ,
+ *outer-Rdelim = \right ]
+ }
+\difdef { s, sp } { 1 }
+ {
+ style = big ,
+ outer-Ldelim = \bigl (,
+ outer-Rdelim = \bigr ),
+ sub-nudge = -2.5 mu,
+ *inner-Ldelim = \bigl (,
+ *inner-Rdelim = \bigr ),
+ *outer-Ldelim = \bigl [,
+ *outer-Rdelim = \bigr ]
+ }
+% vrule point of evaluation
+\difdef { f, fp, s, sp } { | }
+ {
+ outer-Ldelim = \left . ,
+ outer-Rdelim = \right |,
+ sub-nudge = 0 mu
+ }
+% sq. bracket pt of eval.
+\difdef { f, fp, s, sp } { ] }
+ {
+ outer-Ldelim = \left [ ,
+ outer-Rdelim = \right ],
+ elbowroom = 1 mu,
+ sub-nudge = 0 mu
+ }
+% long var wrap
+\difdef { f, fp } { (dv) }
+ { long-var-wrap = (dv) }
+\difdef { f, fp } { dv }
+ { long-var-wrap = dv }
+% compact, D operator
+\difdef { c } { D }
+ {
+ op-symbol = \mathrm{D},
+ op-sub-nudge = -2mu
+ }
+\difdef { c } { D' }
+ {
+ op-symbol = D,
+ op-sub-nudge = -2mu
+ }
+% bold
+\difdef { c } { bD }
+ {
+ op-symbol = \mathbf{D},
+ op-sub-nudge = -2mu
+ }
+% differential style
+\difdef { c, cp } { dl }
+ { style = dl }
+%%%%%%%%%%% differential %%%%%%%%%%
+% partial
+\difdef { l } { p }
+ { op-symbol = \partial }
+% bold
+\difdef { l } { b }
+ { op-symbol = \mathrm{d}\mathbf }
+
+% line elements: Pythagoras
+\difdef { l } { + }
+ {
+ multi-term-sep = 0 mu +,
+ term-sep-adjust = 0 mu ,
+ outer-Ldelim =
+ }
+% Minkowski
+\difdef { l } { - }
+ {
+ multi-term-sep = 0 mu -,
+ term-sep-adjust = 0 mu ,
+ outer-Ldelim =
+ }
+%%%%%%%%%% jacobian %%%%%%%%%%
+% slash fraction
+\difdef { j } { s }
+ { style = / } \ No newline at end of file