summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/diffcoeff/diffcoeff.sty
diff options
context:
space:
mode:
Diffstat (limited to 'macros/latex/contrib/diffcoeff/diffcoeff.sty')
-rw-r--r--macros/latex/contrib/diffcoeff/diffcoeff.sty67
1 files changed, 43 insertions, 24 deletions
diff --git a/macros/latex/contrib/diffcoeff/diffcoeff.sty b/macros/latex/contrib/diffcoeff/diffcoeff.sty
index 7f54ac0362..ba02a301bf 100644
--- a/macros/latex/contrib/diffcoeff/diffcoeff.sty
+++ b/macros/latex/contrib/diffcoeff/diffcoeff.sty
@@ -8,10 +8,10 @@
% Andrew Parsloe ajparsloe@gmail.com
%
\DeclareRelease{v4}{}{diffcoeff4.sty}
-\DeclareCurrentRelease{}{2023/04/12}
+\DeclareCurrentRelease{}{2023/11/14}
\RequirePackage{xtemplate,mleftright}
-\ProvidesExplPackage {diffcoeff} {2023/04/12} {5.3}
+\ProvidesExplPackage {diffcoeff} {2023/11/14} {5.4}
{Write differential coefficients easily and consistently.}
\keys_define:nn { diffcoeff }
{
@@ -35,6 +35,9 @@
}
\bool_if:NT \l__diffcoeff_mLR_bool
{ \mleftright }
+\cs_if_exist:NTF \seq_map_pairwise_function:NNN
+ { \cs_set_eq:NN \__diffcoeff_braid:NNN \seq_map_pairwise_function:NNN }
+ { \cs_set_eq:NN \__diffcoeff_braid:NNN \seq_mapthread_function:NNN }
%%%%%%%%%% messages %%%%%%%%%
\cs_new:Npn \__diffcoeff_msg_autocalc:n #1
{
@@ -109,7 +112,7 @@
style-group : choice { f, s, c, j, l } = f,
style : choice { frac, tfrac, dfrac,
/, auto, big, Big, bigg, Bigg,
- _, dl
+ _, dl,d^
} = frac ,
slash-tok : tokenlist = / ,
slash-sep : tokenlist = 0 mu,
@@ -160,6 +163,7 @@
bigg = \__diffcoeff_style:nn { 5 } { bigg },
Bigg = \__diffcoeff_style:nn { 5 } { Bigg },
_ = \__diffcoeff_style:nn { 6 } {},
+ d^ = \__diffcoeff_style:nn { 6 } {},
dl = \__diffcoeff_style:nn { 7 } {},
unknown = \__diffcoeff_style:nn { 9 } {}
},
@@ -228,7 +232,7 @@
{
\msg_error:nnxx { diffcoeff } { unknown-style }
{ \l__diffcoeff_instance_tl }
- { \__diffcoeff_style_group:n { \l__diffcoeff_group_int } }
+ { \__diffcoeff_style_group_base:n { \l__diffcoeff_group_int } }
}
}
}
@@ -239,14 +243,14 @@
{
( \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
+ || ( \int_compare_p:nNn { \int_div_truncate:nn {#2} {2} } < { #1 }
+ && \int_compare_p:nNn { #1 } = { 3 } ) % j
+ || \int_compare_p:nNn { #1 + #2 } > { 9 } % l
}
{
\msg_warning:nnxx { diffcoeff } { wrong-style }
{ \l__diffcoeff_instance_tl }
- { \__diffcoeff_style_group:n { #1 } }
+ { \__diffcoeff_style_group_base:n { #1 } }
\int_compare:nNnTF { #1 } = { 3 }
{ \__diffcoeff_style:nn { 0 } {} }
{
@@ -261,7 +265,7 @@
\int_compare:nNnF { #1 } = { 1 }
{ \bool_set_false:N \l__diffcoeff_innerwrap_bool }
}
-\cs_new:Npn \__diffcoeff_style_group:n #1
+\cs_new:Npn \__diffcoeff_style_group_base:n #1
{ \clist_item:nn { frac, /, _, frac, dl } { #1 + 1 } }
%%%%%%%%% append? (& wrap slash diff operator?)
\cs_new_protected:Npn \__diffcoeff_append:n #1
@@ -580,7 +584,7 @@
}
\tl_set:Nx \l_tmpa_tl
{
- \seq_mapthread_function:NNN \l_tmpa_seq \l_tmpb_seq
+ \__diffcoeff_braid:NNN \l_tmpa_seq \l_tmpb_seq
\__diffcoeff_tot_order:nn
}
\exp_args:NV \tl_if_head_eq_charcode:nNTF \l_tmpa_tl +
@@ -621,8 +625,11 @@
\cs_new_protected:Npn \__diffcoeff_build:nn #1#2
{
\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 } }
+ \int_compare:nNnF { \l__diffcoeff_group_int } = { 4 }
+ {
+ \tl_put_left:Nx \l__diffcoeff_derivand_tl
+ { \__diffcoeff_spaced:n { \l__diffcoeff_spaced_int } }
+ }
\__diffcoeff_wrap_and_form:nn { #2 }
{
\__diffcoeff_form_deriv:xNN
@@ -632,8 +639,9 @@
\l__diffcoeff_derivand_tl
}
}
+ % extra braces for \[ \alert{\dl x} \] in beamer
\cs_new:Npn \__diffcoeff_wrap_and_form:nn #1#2
- { % extra braces for \[ \alert{\dl x} \] in beamer
+ {
\tl_if_novalue:nTF {#1}
{{ #2 }}
{{
@@ -697,7 +705,7 @@
%%%%%%%%%% denominator %%%%%%%%%
\cs_new:Npn \__diffcoeff_build_denom:
{
- \seq_mapthread_function:NNN \l__diffcoeff_ords_seq
+ \__diffcoeff_braid: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 }
@@ -722,14 +730,23 @@
% #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 }
- }
- }
+ \exp_not:o \l__diffcoeff_opii_tl
+ \int_compare:nNnTF { \l__diffcoeff_group_int } = { 4 }
+ {
+ \str_if_eq:nnF { #2 } { 1 }
+ { ^{ \mskip \l__diffcoeff_opordsep_tl \exp_not:o {#2} } }
+ #3
+ }
+ {
+ \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
@@ -760,7 +777,7 @@
%%%%%%%%%%
% #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 } }
@@ -838,7 +855,7 @@
\DeclareChildTemplate { diffcoeff } { DIF } { DIFC }
{ style-group = c }
{
- style = _ ,
+ style = _ ,
derivand-sep = 1 mu plus 1 mu minus 1 mu ,
multi-term-sep = 1 mu ,
term-sep-adjust = 0 mu ,
@@ -948,6 +965,7 @@
{ {\l__diffcoeff_lvw_ldelim_tl #3\l__diffcoeff_lvw_rdelim_tl } } {}
\group_end:
}
+\NewDocumentCommand \difj {} { \jacob }
% differential; #1 variant ; #2 ord(s); #3 vars; #4 exponent
\NewDocumentCommand \dl { >{ \TrimSpaces } D..{} O{1} m e{^} }
{
@@ -963,4 +981,5 @@
{\c_false_bool} {#2} {} {#3} {}
\group_end:
}
+\NewDocumentCommand \difl {} { \dl }
% end of file diffcoeff.sty \ No newline at end of file