texlive[59344] Master/texmf-dist: derivative (25may21)
commits+karl at tug.org
commits+karl at tug.org
Tue May 25 22:47:33 CEST 2021
Revision: 59344
http://tug.org/svn/texlive?view=revision&revision=59344
Author: karl
Date: 2021-05-25 22:47:33 +0200 (Tue, 25 May 2021)
Log Message:
-----------
derivative (25may21)
Modified Paths:
--------------
trunk/Master/texmf-dist/doc/latex/derivative/README.md
trunk/Master/texmf-dist/doc/latex/derivative/derivative.pdf
trunk/Master/texmf-dist/doc/latex/derivative/derivative.tex
trunk/Master/texmf-dist/tex/latex/derivative/derivative.sty
Modified: trunk/Master/texmf-dist/doc/latex/derivative/README.md
===================================================================
--- trunk/Master/texmf-dist/doc/latex/derivative/README.md 2021-05-25 20:47:20 UTC (rev 59343)
+++ trunk/Master/texmf-dist/doc/latex/derivative/README.md 2021-05-25 20:47:33 UTC (rev 59344)
@@ -1,17 +1,22 @@
-## README for derivative package v0.98 dated 2020-07-20
+## README for derivative package v1.0 dated 2021-05-25
-The package provides a set of commands `\NewOdvVariant`, `\NewPdvVariant` etc. that can be used to define a variant of a derivative. The package have already defined several derivatives:
+The package provides a set of commands `\NewDerivative`, `\NewDifferential` etc. that can be used to define a derivative or a differential operator, respectively. The package have already defined several derivatives and differentials:
- - `\odv` Ordinary derivative
- - `\pdv` Partial derivative
- - `\fdv` Functional derivtive
- - `\mdv` Material derivative
- - `\adv` Average rate of change
- - `\jdv` Jacobian
-
+ - `\odv` Ordinary derivative
+ - `\pdv` Partial derivative
+ - `\fdv` Functional derivtive
+ - `\mdv` Material derivative
+ - `\adv` Average rate of change
+ - `\jdv` Jacobian
+ - `\odif` Shorthand for ordinary derivative
+ - `\pdif` Shorthand for partial derivative
+ - `\fdif` Shorthand for functonal derivative
+ - `\mdif` Shorthand for material derivative or general differential operator
+ - `\adif` Difference
+
### Copyright and license
-Copyright 2019-2020 Simon Jensen
+Copyright 2019-2021 Simon Jensen
This work may be distributed and/or modified under the
conditions of the LaTeX Project Public License, either version 1.3
Modified: trunk/Master/texmf-dist/doc/latex/derivative/derivative.pdf
===================================================================
(Binary files differ)
Modified: trunk/Master/texmf-dist/doc/latex/derivative/derivative.tex
===================================================================
--- trunk/Master/texmf-dist/doc/latex/derivative/derivative.tex 2021-05-25 20:47:20 UTC (rev 59343)
+++ trunk/Master/texmf-dist/doc/latex/derivative/derivative.tex 2021-05-25 20:47:33 UTC (rev 59344)
@@ -1,5 +1,5 @@
% derivative.tex
-% Copyright 2019-2020 Simon Jensen
+% Copyright 2019-2021 Simon Jensen
%
% This work may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either version 1.3
@@ -13,12 +13,33 @@
%
% The Current Maintainer of this work is Simon Jensen.
+\begin{filecontents*}{macro.mst}
+quote '+'
+headings_flag 1
+heading_prefix "\\texttt\{\\color\{RoyalBlue\}"
+heading_suffix "\}\\nopagebreak\n"
+item_0 "\n \\item \\begingroup \\small \\ttfamily \\upshape "
+delim_0 "\\endgroup, "
+group_skip "\n\n \\bigskip\n"
+\end{filecontents*}
+
+\begin{filecontents*}{option.mst}
+quote '+'
+item_0 "\n \\bigskip \\item \\begingroup \\color\{RoyalBlue\} "
+item_x1 " \\endgroup \n \\subitem \\begingroup \\small \\ttfamily \\upshape "
+item_1 "\n \\subitem \\begingroup \\small \\ttfamily \\upshape "
+delim_1 "\\endgroup, "
+indent_space "\t"
+indent_length "2"
+\end{filecontents*}
+
\NeedsTeXFormat{LaTeX2e}
\documentclass[final,british,10pt]{scrartcl}
\reversemarginpar
-\RequirePackage{polyglossia}
- \setmainlanguage[variant=british]{english}
+\RequirePackage[british]{babel}
+%\RequirePackage{polyglossia}
+% \setmainlanguage[variant=british]{english}
\RequirePackage[style=english,english=british]{csquotes}
\RequirePackage[final,babel,auto]{microtype}
\RequirePackage{xcolor}
@@ -29,6 +50,17 @@
\definecolor{RoyalBlue}{RGB}{0, 35, 102}
\definecolor{RoyalGreen}{RGB}{32, 77, 2}
+ %\definecolor{RoyalGray}{RGB}{75, 75, 75}
+ %\definecolor{RoyalDarkGray}{RGB}{225, 225, 225}
+ %\definecolor{RoyalLightGray}{RGB}{30, 30, 30}
+ %\definecolor{RoyalRed}{RGB}{255, 177, 151} % 207, 102, 121
+ %\definecolor{RoyalBlue}{RGB}{187, 134, 252} % 55, 185, 255
+ %\definecolor{RoyalGreen}{RGB}{3, 218, 198} % 52, 177, 20
+ %\definecolor{RoyalPageCoulor}{RGB}{18, 18, 18} % 30, 30, 30
+ %\definecolor{RoyalTextCoulor}{RGB}{225, 225, 225}
+ %\pagecolor{RoyalPageCoulor}
+ %\color{RoyalTextCoulor}
+
\RequirePackage{amsmath, amsthm}
\allowdisplaybreaks
\theoremstyle{remark}
@@ -103,10 +135,6 @@
\begin{abstract}
\noindent \ignorespaces
The~\mypackage{}~package~provides~a~set~of~commands~which~makes~writing~ordinary~and~partial~derivatives~of~arbitrary~order~in~a~straight~forward~manner.~Additionally,~this~package~provides~a~set~of~commands~to~define~variants~of~the~aforementioned~derivatives.~A~set~of~optional~arguments~along~with~lots~of~package~options~allow~for~easy~and~great~flexibility~over~the~derivative's~format,~such~as~where~the~function~is~positioned,~point~of~evaluation,~and~switching~between~fraction~styles.~Moreover,~the~mixed~order~of~the~partial~derivative~and~variants~hereof~is~automatically~computed.~This~package~is~written~in~the~\pkg{expl3}~language~and~requires~therefore~the~\LaTeX3~package~bundles~\pkg{l3kernel}~and~\pkg{l3package}.~Additionally,~the~\pkg{mleftright}~package~is~optional~and~provides~the~improved~automatically~scaling~\cs{mleft}~and~\cs{mright}.
- \par
- \bigskip
- \par
- \noindent~\textcolor{RoyalRed}{NB}:~This~is~a~beta~version~and~some~elements~are~subject~to~change.
\end{abstract}
\vfill
@@ -113,17 +141,22 @@
\clearpage
}
-\lstset
+\lstdefinestyle{inlinestyle}
{
- tabsize = 1,
columns = fullflexible,
basicstyle = \ttfamily\upshape\small,
- escapechar = \%,
- alsoletter = {\\,-},
- keywords = [0]{style-inf, mics-add-delims,sep-inf-ord,sep-ord-fun},
+ alsoletter = {\\,-,*,/},
+ keywords = [0]{style-inf, style-var, style-frac, style-frac-/, style-notation, style-notation-*, scale-eval, scale-eval-/, scale-fun, scale-var, scale-frac, scale-frac-/, scale-var, scale-var-*, delims-eval, delims-eval-/, delims-fun, delims-var, delims-frac, delims-var-*, delims-frac-/, sep-inf-ord, sep-inf-fun, sep-ord-fun, sep-frac-fun, sep-inf-var, sep-var-ord, sep-var-inf, sep-ord-inf, sep-var-var, sep-eval-sb, sep-eval-sp, sep-begin, sep-inf-ord, sep-inf-var, sep-ord-var, sep,var-inf, sep-var-var, sep-ord-ord, sep-end, switch-*, switch-/, add-delims, remove-delims, add-var-delims, order, morder, sort-method, sort-numerical, sort-abs-reverse, sort-number-reverse, sort-sign-reverse, sort-symbol-reverse, fun, frac, var, order, ord, mixed-order, mixord, scale-auto},
keywordstyle = [0]\__mydoc_option_font:,
- keywords = [1]{\\odv, \\mdv, \\fdv, \\adv, \\jdv, \\pdv, \\NewOdvVariant, \\RenewOdvVariant, \\ProvideOdvVariant, \\DeclareOdvVariant, \\NewPdvVariant, \\RenewPdvVariant, \\ProvidePdvVariant, \\DeclarePdvVariant},
+ keywords = [1]{\\odv, \\pdv, \\mdv, \\fdv, \\adv, \\jdv, \\odif, \\pdif, \\mdif, \\fdif, \\adif, \\NewDerivative, \\RenewDerivative, \\ProvideDerivative, \\DeclareDerivative, \\NewDifferential, \\RenewDifferential, \\ProvideDifferential, \\DeclareDifferential, \\slashfrac, \\derivset},
keywordstyle = [1]\__mydoc_function_font:,
+}
+
+\lstdefinestyle{definitionstyle}
+{
+ style = inlinestyle,
+ tabsize = 1,
+ escapechar = \%,
commentstyle = \footnotesize,
frame = single,
xleftmargin=3.4pt,
@@ -130,10 +163,10 @@
xrightmargin=3.4pt,
rulesep = 0pt,
backgroundcolor = \color{RoyalLightGray},
- rulecolor = \color{RoyalGray}
+ rulecolor = \color{RoyalGray},
}
-\lstnewenvironment{definition}{\normalmarginpar}{\reversemarginpar}
+\lstnewenvironment{definition}{\lstset{style=definitionstyle}\normalmarginpar}{\reversemarginpar}
\newlist{todo}{enumerate}{1}
\setlist[todo]{label=(\roman{todoi}), ref=\thesubsection(\roman{todoi})}
@@ -205,8 +238,37 @@
\textcolor{green}{\ensuremath{\checkmark}}
}
-\NewDocumentCommand{\answer}{ m m }
+\bool_new:N \l__mydoc_answer_bool
+\keys_define:nn {mydoc/answer}
{
+ done .bool_set:N = \l__mydoc_answer_bool,
+ done .initial:n = false,
+ done .default:n = true
+}
+
+\NewDocumentCommand{\answer}{ o m m }
+{
+ \group_begin:
+ \tl_if_novalue:nF {#1} { \mydoc_set_keys:nn {answer} {#1} }
+
+ \bool_if:NTF \l__mydoc_answer_bool
+ {
+ \fcolorbox{RoyalGray}{RoyalLightGray}
+ {
+ \parbox{\dimexpr\linewidth-2\fboxsep\relax}
+ {
+ \__mydoc_answer:nn {#2} {#3}
+ }
+ }
+ }
+ {
+ \__mydoc_answer:nn {#2} {#3}
+ }
+ \group_end:
+}
+
+\cs_new_protected:Npn \__mydoc_answer:nn #1 #2
+{
#1
\textbf{Conclusion:}
\c_space_tl
@@ -236,13 +298,6 @@
-
-
-
-
-
-
-
\tl_new:N \l__mydoc_ch_version_tl
\tl_new:N \l__mydoc_ch_date_tl
\tl_new:N \l__mydoc_ch_change_tl
@@ -304,7 +359,7 @@
\\
\tl_use:N \l__mydoc_ch_date_tl
\bool_if:NT \l__mydoc_ch_beta_bool
- { \\ \midrule \color{RoyalRed} Beta }
+ { \\ \color{RoyalRed} Beta }
\\ \bottomrule
\endtabular
}
@@ -339,6 +394,7 @@
{
}
+
\tl_new:N \l__mydoc_number_tl
\tl_new:N \l_mydoc_index_item_tl
\tl_new:N \l_mydoc_index_subitem_tl
@@ -353,8 +409,8 @@
\seq_new:N \l__deriv_earg_seq
\int_new:N \l__mydoc_earg_int
-\int_new:N \l__mydoc_function_int
-\int_new:N \l__mydoc_option_int
+\int_new:N \g__mydoc_function_int
+\int_new:N \g__mydoc_option_int
\bool_new:N \l__mydoc_number_bool
@@ -412,12 +468,11 @@
\cs_new_protected:Npn \mydoc_define_font_ii:n #1
{
- \mydoc_define_vars_keys:nnnn {#1} { l } { tl } { colour, family, shape, size }
- \mydoc_define_vars_keys:nnnn {#1} { l } { bool } { colourb, familyb, shapeb, sizeb }
+ \mydoc_define_vars_keys:nnnn {#1} { l } { tl } { family, shape, size }
+ \mydoc_define_vars_keys:nnnn {#1} { l } { bool } { familyb, shapeb, sizeb }
\cs_new_protected:cpn { __mydoc_#1_font: }
{
- \bool_if:cT { l__mydoc_#1_colourb_bool } { \color { \use:c { l__mydoc_#1_colour_tl } } }
\bool_if:cT { l__mydoc_#1_familyb_bool } { \tl_use:c { l__mydoc_#1_family_tl } }
\bool_if:cT { l__mydoc_#1_shapeb_bool } { \tl_use:c { l__mydoc_#1_shape_tl } }
\bool_if:cT { l__mydoc_#1_sizeb_bool } { \tl_use:c { l__mydoc_#1_size_tl } }
@@ -428,8 +483,15 @@
{
\mydoc_define_vars_keys:nnnn {#1} { l } { bool } { index }
\mydoc_define_vars_keys:nnnn {#1} { l } { bool } { definition }
+ \mydoc_define_vars_keys:nnnn {#1} { l } { tl } { cat }
}
+\cs_new_protected:Npn \mydoc_define_updated:n #1
+{
+ \mydoc_define_vars_keys:nnnn {#1} { l } { tl } { new }
+ \mydoc_define_vars_keys:nnnn {#1} { l } { tl } { updated }
+}
+
\cs_new_protected:Npn \mydoc_define_default:n #1
{
\mydoc_define_vars_keys:nnnn {#1} { g } { clist } { default }
@@ -438,6 +500,11 @@
\mydoc_define_vars_keys:nnnn {#1} { l } { tl } { sepc }
}
+\cs_new_protected:Npn \mydoc_define_tabular:n #1
+{
+ \mydoc_define_vars_keys:nnnn {#1} { l } { bool } { result }
+}
+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\cs_new_protected:Npn \mydoc_define_type:nn #1 #2
@@ -451,6 +518,8 @@
{ font_ii } { \mydoc_define_font_ii:n {#1} }
{ index } { \mydoc_define_index:n {#1} }
{ default } { \mydoc_define_default:n {#1} }
+ { tabular } { \mydoc_define_tabular:n {#1} }
+ { updated } { \mydoc_define_updated:n {#1} }
}
}
}
@@ -457,39 +526,39 @@
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-\mydoc_define_type:nn { function } { font_i, index }
-\mydoc_define_type:nn { macro } { font_i, index }
-\mydoc_define_type:nn { syntax } { font_i }
-\mydoc_define_type:nn { argument } { font_i, }
-\mydoc_define_type:nn { arg } { font_i, }
-\mydoc_define_type:nn { option } { font_i, index }
-\mydoc_define_type:nn { key } { font_i, index }
-\mydoc_define_type:nn { values } { font_i, default }
-\mydoc_define_type:nn { val } { font_i }
-\mydoc_define_type:nn { example } { font_i }
-\mydoc_define_type:nn { marg } { font_ii }
-\mydoc_define_type:nn { narg } { font_ii }
-\mydoc_define_type:nn { oarg } { font_ii }
-\mydoc_define_type:nn { targ } { font_ii }
-\mydoc_define_type:nn { meta } { font_ii }
-\mydoc_define_type:nn { cs } { font_ii }
+\mydoc_define_type:nn { function } { font_i, index, updated }
+\mydoc_define_type:nn { macro } { font_ii, index }
+\mydoc_define_type:nn { syntax } { font_ii }
+\mydoc_define_type:nn { argument } { font_i, updated }
+\mydoc_define_type:nn { arg } { font_ii, }
+\mydoc_define_type:nn { option } { font_i, index, updated }
+\mydoc_define_type:nn { key } { font_ii, index }
+\mydoc_define_type:nn { values } { font_ii, default }
+\mydoc_define_type:nn { val } { font_ii }
+\mydoc_define_type:nn { example } { font_ii, tabular }
+\mydoc_define_type:nn { marg } { font_ii }
+\mydoc_define_type:nn { narg } { font_ii }
+\mydoc_define_type:nn { oarg } { font_ii }
+\mydoc_define_type:nn { targ } { font_ii }
+\mydoc_define_type:nn { meta } { font_ii }
+\mydoc_define_type:nn { cs } { font_ii }
-\mydoc_set_keys:nn { function } { colour = RoyalRed, family = \ttfamily, shape = \upshape, size = \small, index = true, definition = true }
-\mydoc_set_keys:nn { macro } { colour = black, family = \ttfamily, shape = \upshape, size = \small, index = true, definition = false }
-\mydoc_set_keys:nn { syntax } { colour = black, family = \rmfamily, shape = \upshape, size = \small }
-\mydoc_set_keys:nn { argument } { colour = RoyalBlue, family = \rmfamily, shape = \upshape, size = \small }
-\mydoc_set_keys:nn { arg } { colour = black, family = \rmfamily, shape = \upshape, size = \small }
-\mydoc_set_keys:nn { option } { colour = RoyalGreen, family = \ttfamily, shape = \upshape, size = \small, index = true, definition = true }
-\mydoc_set_keys:nn { key } { colour = black, family = \ttfamily, shape = \upshape, size = \small, index = true, definition = false }
-\mydoc_set_keys:nn { values } { colour = black, family = \ttfamily, shape = \upshape, size = \small, default = \c_novalue_tl, sepa = { ,~}, sepb = { ,~}, sepc = { ,~} }
-\mydoc_set_keys:nn { val } { colour = black, family = \ttfamily, shape = \upshape, size = \small }
-\mydoc_set_keys:nn { example } { colour = black, family = \ttfamily, shape = \upshape, size = \small }
-\mydoc_set_keys:nn { marg } { colour = black, family = \ttfamily, shape = \upshape, size = \small, colourb = true, familyb = true, shapeb = true, sizeb = true }
-\mydoc_set_keys:nn { narg } { colour = black, family = \ttfamily, shape = \upshape, size = \small, colourb = true, familyb = true, shapeb = true, sizeb = true }
-\mydoc_set_keys:nn { oarg } { colour = black, family = \ttfamily, shape = \upshape, size = \small, colourb = true, familyb = true, shapeb = true, sizeb = true }
-\mydoc_set_keys:nn { targ } { colour = black, family = \ttfamily, shape = \upshape, size = \small, colourb = true, familyb = true, shapeb = true, sizeb = true }
-\mydoc_set_keys:nn { meta } { colour = black, family = \rmfamily, shape = \slshape, size = \small, colourb = true, familyb = true, shapeb = true, sizeb = true }
-\mydoc_set_keys:nn { cs } { colour = black, family = \rmfamily, shape = \upshape, size = \small, colourb = true, familyb = true, shapeb = true, sizeb = true }
+\mydoc_set_keys:nn { function } { family=\ttfamily, shape=\upshape, size=\small, colour=RoyalRed, index=true, definition=true, cat=\c_novalue_tl }
+\mydoc_set_keys:nn { macro } { family=\ttfamily, shape=\upshape, size=\small, familyb=true, shapeb=true, sizeb=true, index=true, definition=false, cat=\c_novalue_tl }
+\mydoc_set_keys:nn { syntax } { family=\rmfamily, shape=\upshape, size=\small, familyb=true, shapeb=true, sizeb=true }
+\mydoc_set_keys:nn { argument } { family=\rmfamily, shape=\upshape, size=\small, colour=RoyalBlue }
+\mydoc_set_keys:nn { arg } { family=\rmfamily, shape=\upshape, size=\small, familyb=true, shapeb=true, sizeb=true }
+\mydoc_set_keys:nn { option } { family=\ttfamily, shape=\upshape, size=\small, colour=RoyalGreen, index=true, definition=true, cat=\c_novalue_tl }
+\mydoc_set_keys:nn { key } { family=\ttfamily, shape=\upshape, size=\small, familyb=true, shapeb=true, sizeb=true, index=true, definition=false, cat=\c_novalue_tl }
+\mydoc_set_keys:nn { values } { family=\ttfamily, shape=\upshape, size=\small, familyb=true, shapeb=true, sizeb=true, default=\c_novalue_tl, sepa={ ,~}, sepb={ ,~}, sepc={ ,~} }
+\mydoc_set_keys:nn { val } { family=\ttfamily, shape=\upshape, size=\small, familyb=true, shapeb=true, sizeb=true }
+\mydoc_set_keys:nn { example } { family=\ttfamily, shape=\upshape, size=\small, familyb=true, shapeb=true, sizeb=true, result=true }
+\mydoc_set_keys:nn { marg } { family=\ttfamily, shape=\upshape, size=\small, familyb=true, shapeb=true, sizeb=true }
+\mydoc_set_keys:nn { narg } { family=\ttfamily, shape=\upshape, size=\small, familyb=true, shapeb=true, sizeb=true }
+\mydoc_set_keys:nn { oarg } { family=\ttfamily, shape=\upshape, size=\small, familyb=true, shapeb=true, sizeb=true }
+\mydoc_set_keys:nn { targ } { family=\ttfamily, shape=\upshape, size=\small, familyb=true, shapeb=true, sizeb=true }
+\mydoc_set_keys:nn { meta } { family=\rmfamily, shape=\slshape, size=\small, familyb=true, shapeb=true, sizeb=true }
+\mydoc_set_keys:nn { cs } { family=\rmfamily, shape=\upshape, size=\small, familyb=true, shapeb=true, sizeb=true }
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -542,22 +611,66 @@
\cs_new_protected:Npn \__mydoc_function_margin:n #1
{
\seq_set_from_clist:Nn \l__mydoc_function_seq {#1}
- \int_zero:N \l__mydoc_function_int
+ \int_gzero:N \g__mydoc_function_int
\mydoc_margin:n
{
- \__mydoc_function_font:
+ \tabular[t]{ @{} r @{} }
+ %\group_begin:
\seq_map_inline:Nn \l__mydoc_function_seq
{
- \int_incr:N \l__mydoc_function_int
+ \__mydoc_function_font:
+ \int_gincr:N \g__mydoc_function_int
\mydoc_cs_to_str:N ##1
\mydoc_index_cs:Nnn ##1 { function } { macro }
- \int_compare:nNnF { \l__mydoc_function_int } = { \seq_count:N \l__mydoc_function_seq }
+ \int_compare:nNnF { \g__mydoc_function_int } = { \seq_count:N \l__mydoc_function_seq }
{ \\ }
}
+ %\group_end:
+ \deriv_new_updated:NN \l__mydoc_function_new_tl \l__mydoc_function_updated_tl
+ \endtabular
}
}
+\cs_new_protected:Npn \deriv_new_updated:NN #1 #2
+{
+ \tl_if_empty:NTF #1
+ {
+ \tl_if_empty:NF #2
+ {
+ \\ \midrule
+ \deriv_add_updated:N #2
+ }
+ }
+ {
+ \\ \midrule
+ \deriv_add_new:N #1
+ \tl_if_empty:NF #2
+ {
+ \\
+ \deriv_add_updated:N #2
+ }
+ }
+}
+
+\cs_new_protected:Npn \deriv_add_new:N #1
+{
+ \group_begin:
+ \small \ttfamily
+ New: \tl_use:N \c_space_tl
+ \tl_use:N #1
+ \group_end:
+}
+
+\cs_new_protected:Npn \deriv_add_updated:N #1
+{
+ \group_begin:
+ \small \ttfamily
+ Updated: \tl_use:N \c_space_tl
+ \tl_use:N #1
+ \group_end:
+}
+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\cs_new_protected:Npn \__mydoc_syntax_begin:
@@ -592,16 +705,19 @@
{
\mydoc_margin:n
{
- \mydoc_set_keys:nn { marg } { colourb = false, familyb = false, shapeb = false, sizeb = false }
- \mydoc_set_keys:nn { narg } { colourb = false, familyb = false, shapeb = false, sizeb = false }
- \mydoc_set_keys:nn { oarg } { colourb = false, familyb = false, shapeb = false, sizeb = false }
- \mydoc_set_keys:nn { targ } { colourb = false, familyb = false, shapeb = false, sizeb = false }
- \mydoc_set_keys:nn { meta } { colourb = false, familyb = true, shapeb = true, sizeb = false }
- \mydoc_set_keys:nn { cs } { colourb = false, familyb = false, shapeb = false, sizeb = false }
+ \tabular[t]{ @{} r @{} }
+ \mydoc_set_keys:nn { marg } { familyb = false, shapeb = false, sizeb = false }
+ \mydoc_set_keys:nn { narg } { familyb = false, shapeb = false, sizeb = false }
+ \mydoc_set_keys:nn { oarg } { familyb = false, shapeb = false, sizeb = false }
+ \mydoc_set_keys:nn { targ } { familyb = false, shapeb = false, sizeb = false }
+ \mydoc_set_keys:nn { meta } { familyb = true, shapeb = true, sizeb = false }
+ \mydoc_set_keys:nn { cs } { familyb = false, shapeb = false, sizeb = false }
\__mydoc_argument_font:
\mydoc_if_int:nTF {#1}
{ \seq_item:Nn \g__mydoc_syntax_seq {#1} }
{ #1 }
+ \deriv_new_updated:NN \l__mydoc_argument_new_tl \l__mydoc_argument_updated_tl
+ \endtabular
}
}
@@ -617,6 +733,7 @@
\cs_new_protected:Npn \__mydoc_option_end:
{
\seq_clear:N \l__mydoc_option_seq
+ \clist_gclear:c { g__mydoc_values_default_clist }
\par \noindent \ignorespacesafterend
}
@@ -623,19 +740,22 @@
\cs_new_protected:Npn \__mydoc_option_margin:n #1
{
\seq_set_from_clist:Nn \l__mydoc_option_seq {#1}
- \int_zero:N \l__mydoc_option_int
+ \int_gzero:N \g__mydoc_option_int
\mydoc_margin:n
{
- \__mydoc_option_font:
+ \tabular[t]{ @{} r @{} }
\seq_map_inline:Nn \l__mydoc_option_seq
{
- \int_incr:N \l__mydoc_option_int
+ \int_gincr:N \g__mydoc_option_int
+ \__mydoc_option_font:
##1
\mydoc_index_key:nnn {##1} { option } { option }
- \int_compare:nNnF { \l__mydoc_option_int } = { \seq_count:N \l__mydoc_option_seq }
- { \\ }
+ \int_compare:nNnF { \g__mydoc_option_int } = { \seq_count:N \l__mydoc_option_seq }
+ { \\ }
}
+ \deriv_new_updated:NN \l__mydoc_option_new_tl \l__mydoc_option_updated_tl
+ \endtabular
}
}
@@ -672,24 +792,43 @@
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\DeclareDocumentEnvironment{example}{ s o b }
-{ \__mydoc_example_begin:nn {#1} {#3} }
-{ \__mydoc_example_end: }
+{
+ \tl_if_novalue:nF {#2} { \mydoc_set_keys:nn { example } {#2} }
+ \__mydoc_example_begin:nn {#1} {#3}
+}
+{
+ \__mydoc_example_end:
+}
+\cs_new_protected:Npn \__mydoc_example_end:
+{
+ \endtabular
+ \endcenter
+}
+
\cs_new_protected:Npn \__mydoc_example_begin:nn #1 #2
{
\seq_set_split:Nnn \l__deriv_example_seq { \\ } {#2}
- \bool_if:nTF {#1}
+ \bool_if:NTF \l__mydoc_example_result_bool
{
- \center \tabular{ @{} c @{} }
- \__mydoc_example_content:Nnn \l__deriv_example_seq { \\[0.5em] } { \qquad }
+ \bool_if:nTF {#1}
+ {
+ \center \tabular{ @{} c @{} }
+ \__mydoc_example_content_star:N \l__deriv_example_seq
+ }
+ {
+ \center \tabular{ @{} r c l @{} }
+ \__mydoc_example_content:N \l__deriv_example_seq
+ }
}
{
- \center \tabular{ @{} r c l @{} }
- \__mydoc_example_content:Nnn \l__deriv_example_seq { & } { $ & $ }
+ \renewcommand{\arraystretch}{0}
+ \center \tabular{ @{} >{\arraybackslash}l @{} }
+ \__mydoc_example_content_nores:N \l__deriv_example_seq
}
}
-\cs_new_protected:Npn \__mydoc_example_content:Nnn #1 #2 #3
+\cs_new_protected:Npn \__mydoc_example_content:N #1
{
\int_gzero:N \g__mydoc_example_int
\seq_map_inline:Nn #1
@@ -697,34 +836,109 @@
\int_gincr:N \g__mydoc_example_int
\__mydoc_example_font:
\__mydoc_print:n {##1}
- #2
- $\Longrightarrow #3 \displaystyle ##1 $
+ &
+ $\Longrightarrow$
+ &
+ $\displaystyle ##1$
\int_compare:nNnF { \g__mydoc_example_int } = { \seq_count:N #1 }
{ \\ \addlinespace[0.5em] }
}
}
-\cs_new_protected:Npn \__mydoc_example_end:
+\cs_new_protected:Npn \__mydoc_example_content_star:N #1
{
- \endtabular
- \endcenter
+ \int_gzero:N \g__mydoc_example_int
+ \seq_map_inline:Nn #1
+ {
+ \int_gincr:N \g__mydoc_example_int
+ \__mydoc_example_font:
+ \__mydoc_print:n {##1}
+ \\[0.5em]
+ $\Longrightarrow \qquad \displaystyle ##1$
+ \int_compare:nNnF { \g__mydoc_example_int } = { \seq_count:N #1 }
+ { \\ \addlinespace[0.5em] }
+ }
}
+\cs_new_protected:Npn \__mydoc_example_content_nores:N #1
+{
+ \int_gzero:N \g__mydoc_example_int
+ \seq_map_inline:Nn #1
+ {
+ \int_gincr:N \g__mydoc_example_int
+ \__mydoc_example_font:
+ \__mydoc_print:n {##1}
+ \int_compare:nNnF { \g__mydoc_example_int } = { \seq_count:N #1 }
+ { \\ \addlinespace[0.4em] }
+ }
+}
+
\tl_new:N \l__mydoc_print_tmp_tl
+\seq_new:N \l__deriv_print_seq
+\str_new:N \l__deriv_print_str
+
\cs_new_protected:Npn \__mydoc_print:n #1
{
\tl_set:Nn \l__mydoc_print_tmp_tl {#1}
\regex_replace_all:nnN { . } { \c{string} \0 } \l__mydoc_print_tmp_tl
- \tl_use:N \l__mydoc_print_tmp_tl
+ \str_set:Nx \l__deriv_print_str \l__mydoc_print_tmp_tl
+
+ \__deriv_split_at_star:NN \l__deriv_print_seq \l__deriv_print_str
+
+ \seq_indexed_map_inline:Nn \l__deriv_print_seq
+ {
+ \__mydoc_inlinecode:n {##2}
+ \int_compare:nNnF {##1} = { \seq_count:N \l__deriv_print_seq }
+ {
+ \hspace{0.4pt}
+ }
+ }
}
+\cs_new_protected:Npn \__mydoc_inlinecode:n #1
+{
+ \lstinline[style=inlinestyle]$#1$
+}
+
+\cs_new_protected:Npn \__deriv_split_at_star:NN #1 #2
+{
+ \seq_set_split:NnV \l_tmpa_seq {*} #2
+
+ \seq_indexed_map_inline:Nn \l_tmpa_seq
+ {
+ \int_compare:nNnTF {##1} = { \seq_count:N \l_tmpa_seq }
+ {
+ \tl_put_right:Nn \l_tmpb_tl {##2}
+ \seq_put_right:NV #1 \l_tmpb_tl
+ }
+ {
+ \tl_set:Nn \l_tmpa_tl {##2}
+ \str_if_eq:eeTF { \tl_item:Nn \l_tmpa_tl {-1} } { - }
+ {
+ \tl_set:Nn \l_tmpb_tl {##2*}
+ }
+ {
+ \seq_put_right:Nn #1 {##2}
+ \tl_set:Nn \l_tmpb_tl {*}
+ }
+ }
+ }
+}
+
+\NewDocumentCommand{\inlinecode}{ m }
+{
+ \group_begin:
+ \__mydoc_print:n {#1}
+ \group_end:
+}
+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-\DeclareDocumentEnvironment{function}{ s o m }
+\DeclareDocumentEnvironment{function}{ s m o }
{
- \tl_if_novalue:nF {#2} { \mydoc_set_keys:nn { function } {#2} }
+ \tl_if_novalue:nF {#3} { \mydoc_set_keys:nn { function } {#3} }
\__mydoc_function_begin:n {#1}
- \__mydoc_function_margin:n {#3}
+ \__mydoc_function_margin:n {#2}
}
{
\__mydoc_function_end:
@@ -740,21 +954,21 @@
\__mydoc_syntax_end:
}
-\DeclareDocumentEnvironment{argument}{ s o m }
+\DeclareDocumentEnvironment{argument}{ s m o }
{
- \tl_if_novalue:nF {#2} { \mydoc_set_keys:nn { argument } {#2} }
+ \tl_if_novalue:nF {#3} { \mydoc_set_keys:nn { argument } {#3} }
\__mydoc_argument_begin:n {#1}
- \__mydoc_argument_margin:n {#3}
+ \__mydoc_argument_margin:n {#2}
}
{
\__mydoc_argument_end:
}
-\DeclareDocumentEnvironment{option}{ s o m }
+\DeclareDocumentEnvironment{option}{ s m o }
{
- \tl_if_novalue:nF {#2} { \mydoc_set_keys:nn { option } {#2} }
+ \tl_if_novalue:nF {#3} { \mydoc_set_keys:nn { option } {#3} }
\__mydoc_option_begin:n {#1}
- \__mydoc_option_margin:n {#3}
+ \__mydoc_option_margin:n {#2}
}
{
\__mydoc_option_end:
@@ -838,20 +1052,24 @@
\group_end:
}
-\AtBeginDocument{
- \DeclareDocumentCommand{\val}{ o m }
+\AfterEndPreamble{
+ \DeclareDocumentCommand{\val}{ s o m }
{
\group_begin:
- \tl_if_novalue:nF {#1} { \mydoc_set_keys:nn { val } {#1} }
- \mydoc_val:n {#2}
+ \tl_if_novalue:nF {#2} { \mydoc_set_keys:nn { val } {#2} }
+ \bool_if:nTF {#1}
+ { \mydoc_val_star:n {#3} }
+ { \mydoc_val:n {#3} }
\group_end:
}
}
-\DeclareDocumentCommand{\keyval}{ o m m }
+\DeclareDocumentCommand{\keyval}{ s o m m }
{
\group_begin:
- \tl_if_novalue:nF {#1} { \mydoc_set_keys:nn { key } {#1} }
- \mydoc_keyval:nn {#2} {#3}
+ \tl_if_novalue:nF {#2} { \mydoc_set_keys:nn { key } {#2} }
+ \bool_if:nTF {#1}
+ { \mydoc_keyval_star:nn {#3} {#4} }
+ { \mydoc_keyval:nn {#3} {#4} }
\group_end:
}
@@ -867,6 +1085,11 @@
\__mydoc_key_font:
#1
}
+\cs_new_protected:Npn \mydoc_val_star:n #1
+{
+ \__mydoc_key_font:
+ \{ #1 \}
+}
\cs_new_protected:Npn \mydoc_keyval:nn #1 #2
{
@@ -876,6 +1099,14 @@
\mydoc_val:n {#2}
\group_end:
}
+\cs_new_protected:Npn \mydoc_keyval_star:nn #1 #2
+{
+ \group_begin:
+ \mydoc_key:n {#1}
+ =
+ \mydoc_val_star:n {#2}
+ \group_end:
+}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -895,7 +1126,10 @@
\cs_new_protected:Npn \mydoc_index_key:nnn #1 #2 #3
{
\seq_set_split:Nnn \l__mydoc_index_seq { - } {#1}
- \tl_set:Nx \l_mydoc_index_item_tl { \seq_item:Nn \l__mydoc_index_seq {1} }
+ \mydoc_if_novalue:vTF { l__mydoc_#2_cat_tl }
+ { \tl_set:Nx \l_mydoc_index_item_tl { \seq_item:Nn \l__mydoc_index_seq {1} } }
+ { \tl_set_eq:Nc \l_mydoc_index_item_tl { l__mydoc_#2_cat_tl } }
+
\tl_set:Nx \l_mydoc_index_subitem_tl {#1}
\tl_set:Nx \l_mydoc_index_entry_tl {#1}
@@ -906,6 +1140,21 @@
{ \mydoc_index:VVVnn \l_mydoc_index_item_tl \l_mydoc_index_subitem_tl \l_mydoc_index_entry_tl {#3} { textnormal } }
}
}
+\prg_new_conditional:Npnn \mydoc_if_novalue:n #1 { TF }
+{
+ \token_if_macro:NTF {#1}
+ {
+ \exp_args:NV \tl_if_novalue:nTF {#1}
+ { \prg_return_true: }
+ { \prg_return_false: }
+ }
+ {
+ \tl_if_novalue:nTF {#1}
+ { \prg_return_true: }
+ { \prg_return_false: }
+ }
+}
+\prg_generate_conditional_variant:Nnn \mydoc_if_novalue:n { v } { TF }
\cs_new_protected:Npn \mydoc_index:nnnn #1 #2 #3 #4
{
@@ -1054,15 +1303,7 @@
\DeclareDocumentCommand{\ms}{ m }
{
- \group_begin:
- \text
- {
- \scriptsize
- $\langle$
- \texttt{#1}
- $\rangle$
- }
- \group_end:
+ {\scriptstyle\langle\texttt{#1}\rangle}
}
\cs_new_protected:Npn \mydoc_cs_to_str:N #1
@@ -1078,12 +1319,14 @@
\ExplSyntaxOff
\makeatother
+
+
\Pakkenavn{derivative}
\Titel{The \pakkenavn{} package}
\Forfatter{Simon Jensen}
\Email{sjelatex at gmail.com}
-\Dato{2020/07/20}
-\Version{0.98}
+\Dato{2021/05/25}
+\Version{1.0}
\RequirePackage{derivative}[\dato]
\derivset{all}[scale-auto = mleftmright]
@@ -1103,6 +1346,7 @@
\listfiles
\setlength{\marginparwidth}{126pt} % 74.68849pt
+\setlength{\marginparpush}{0pt} % 5.39996pt
\makeindex[name = option, title = Index of Options, intoc=true]
\makeindex[name = macro, title = Index of Commands, intoc=true]
@@ -1111,6 +1355,11 @@
\def\indexspace{}
+\directlua{
+ pdf.setmajorversion(2)
+ pdf.setminorversion(0)
+}
+
\begin{document}
\forside
@@ -1120,29 +1369,24 @@
\clearpage
\section{Introduction}
- This is a beta version meaning that some elements might be changed in the official release. Using this package in its current state is therefore on your own risk. The next update, version \texttt{v1.0}, will contain the changes specified in \cref{sec:todo}.
+ This package started as a personal package a few years ago that I used in various projects. Firstly, it was written in \tex{} and \latex, which gave rise to various errors as the complexity of the package grew larger and ended up as a spaghetti code. Therefore, the code was rewritten into the \latex3 language and may now be easily maintained. Originally this package was written because there did not exist any great package for derivatives. It was first much later that I discovered the \pkg{diffcoeff} package, which does a good job. However, at this time, I had already written much of the code with no documentation. So I decided to write one and make it into a package for the public.
- This package started as a personal package a few years ago that I used in various projects. Firstly, it was written in \tex{} and \latex, which gave rise to various errors as the complexity of the package grew larger and ended up as a spaghetti code. Therefore, the code was rewritten into the \latex3 language and may now be easily maintained. Originally this package was written because there did not exist any great package for derivatives. It was first much later that I discovered the \pkg{diffcoeff} package, which does a good job. However, at this time, I had already written much of the code with no documentation. I decided to write one and make it into a package for the public.
+ As a note on terminology, I use the wording \emph{infinitesimal} abbreviated as \texttt{inf} for the operator symbols $d, \partial, \delta$ etc. that used in derivatives like $\odv{y}{x}, \pdv{y}{x}, \fdv{y}{x}$ and in differentials like $\odif{x}, \pdif{x}, \fdif{x}$. In the description of macros and options, I often write \emph{cs-\meta{placeholder}} to denote a comma-separated list of \meta{placeholder}. For example, \oarg{cs-numbers} is used in the option section for math space keys to denote comma-separated list of numbers. It should also be noted that whenever an argument reads \meta{keyvalue list}, it means that it is a comma-separated list of keyvalue pairs.
- As a note on terminology, I use the wording \emph{infinitesimal} and abbreviated as \texttt{inf} for the operator symbol $d, \partial, \delta$ etc. used in various derivatives like $\odv{y}{x}, \pdv{y}{x}, \fdv{y}{x}$ etc. Moreover, I explicitly use \emph{differential d} for $d$ and \emph{partial} for $\partial$. In the description of macros and options, I often write \emph{cs-\meta{placeholder}} to denote a comma-separated list of \meta{placeholder}. For example, \oarg{cs-orders} is used in the partial derivative's description to denote the order differentiation and is read as a comma-separated list of orders. It should also be noted that whenever an argument reads \meta{key=value}, it means that it is a comma-separated list of key-value pairs.
-
-
-
-
\clearpage
- \section{Ordinary derivative}
+ \section{Derivative}
- \begin{function}*{\odv}
+ \begin{function}*{\pdv}
\begin{syntax}
- \sarg, \oarg{order}, \marg{function}, \targ{/}, \marg{variable}, \earg{\_, point\tsb{1}, \^, point\tsb{2}}
+ \sarg, \oarg{keyval list}, \marg{function}, \targ{/}, \marg{variables}, \earg{\_, point\tsb{1}, \^, point\tsb{2}}
\end{syntax}
- The ordinary derivative \macro{1} is defined with a set of mandatory and optional arguments that either typeset specific parts or changing the style of the derivative. In this package, the ordinary derivative is defined with an upright lowercase d, because it is used by many nowadays books, as
+ The partial derivative \macro{1} is defined with a set of mandatory and optional arguments that either typeset specific parts or changing the style of the derivative. In this package, the partial derivative is defined with an italic partial differential $\partial$ as
\begin{definition}
- \DeclareOdvVariant{\odv}{d}[style-inf=\mathrm]%\marginnote{\pdftex\\\xetex, \luatex}%
- \DeclareOdvVariant{\odv}{d}[style-inf=\symup]
+ \DeclareDerivative{\pdv}{\partial}[style-var=multiple, sep-inf-ord=1,%\marginnote{\pdftex, \xetex, \luatex}%
+ delims-eval=(), delims-eval-/=()]
\end{definition}
\begin{argument}*{1}
@@ -1149,23 +1393,26 @@
The first argument of \macro{1} is an optional star that determines where the function is typeset; either in the numerator of the fraction or next to the fraction. Using the option \keyval{switch-*}{false}, the function is typeset in the numerator when the star is absent, and next to the fraction when the star is present as shown below
\begin{example}
- \odv{y}{x} \\
- \odv*{y}{x}
+ \pdv{f}{x,y} \\
+ \pdv*{f}{x,y}
\end{example}
- \noindent The effect of the star's presence can be switched around using \keyval{switch-*}{true} i.e. the equations in the above example are exchanged, as described in \cref{ssec:odv_options}.
+ \noindent The effect of the star's presence can be switched around using \keyval{switch-*}{true} i.e. the equations in the above example are exchanged.
\end{argument}
- \begin{argument}{2}
- The second argument is optional and is written inside square brackets. This argument is used to set the order of differentiation as seen below
+ \begin{argument}{2}[updated = v1.0]
+ The second argument is optional and is written inside square brackets. This argument is used to set the options of the derivative using a \keyval[index=false]{key}{value} semantic. For example the order of differentiation can be set via the \key[cat=misc]{order} option
\begin{example}
- \odv[2]{y}{x} \\
- \odv[n]{y}{x} \\
- \odv[n+2]{y}{x}
+ \pdv[order={2,3}]{f}{x,y} \\
+ \pdv[order={\beta,a,n+2a}]{f}{x,y,z} \\
+ \pdv[order={2,n^2,n^2-1}]{f}{x,y,z} \\
+ \pdv[order={2,n^2}]{f}{x,y,z}
\end{example}
- \noindent The order may be a number, a symbol and a combination hereof, because it is simply typeset there. This is different from how the partial derivative's mixed order is typeset, which is computed. The order \textit{is not} automatically sorted as the mixed order for the partial derivative. This argument is subject to change, see \cref{consid:order2keyval} for more information.
+ \noindent The list of options that can be applied to derivatives can be found in \cref{ssec:options_dv}.
+
+ %The order may be a number, a symbol and a combination hereof. Note that the total order of differentiation (i.e $\odif[order=n+2]{}$) is automatically calculated and sorted. This is particularly useful when dealing with mixed partial derivatives which is further described in \cref{ssec:DV_pdv,ssec:overall_order}
\end{argument}
\begin{argument}{3}
@@ -1172,8 +1419,8 @@
This is the first mandatory argument that typeset the function that is to be differentiated
\begin{example}
- \odv{f(x)}{x} \\
- \odv{e^{\sin(x)}}{x}
+ \pdv{f(x,y,z)}{x,y,z} \\
+ \pdv{e^x\sin(y)\ln(z)}{x,y,z}
\end{example}
\noindent The function is simply typeset in the numerator or next to the fraction.
@@ -1180,76 +1427,93 @@
\end{argument}
\begin{argument}{4}
- The fourth argument is an optional slash written \emph{between the function and the variable} and determines which fraction style the derivative is typeset with, as described in \cref{ssec:odv_options}. Using the option \keyval{switch-/}{false} and the package's default settings, the derivative is typeset with \cs{frac} when the slash is absent, and \cs{slashfrac}\footnote{which is a macro defined by the package, see \cref{ssec:slashfrac} for more information.\label{foot:sfrac}} when the slash is present, as shown below
+ The fourth argument is an optional slash written \emph{between the function and the variable} arguments and determines which fraction style the derivative is typeset with, as described in \cref{ssec:options_dv}. Using the option \keyval{switch-/}{false} and the package's default fractions, the derivative is typeset with \cs{frac} when the slash is absent, and \cs{slashfrac}\footnote{which is a macro defined by the package, see \cref{ssec:slashfrac} for more information.\label{foot:sfrac}} when the slash is present, as shown below
\begin{example}
- \odv{y}{x} \\
- \odv{y}/{x}
+ \pdv{f}{x,y} \\
+ \pdv{f}/{x,y}
\end{example}
- \noindent As for the star argument, the effect of the slash's presence can be switched around using \keyval{switch-/}{true} i.e. the equations in the above example are exchanged, as described in \cref{ssec:odv_options}.
+ \noindent As for the star argument, the effect of the slash's presence can be switched around using \keyval{switch-/}{true} i.e. the equations in the above example are exchanged.
\end{argument}
\begin{argument}{5}
- This is the second and final mandatory argument, which purpose is to typeset the variable in which the function is differentiated with respect to as shown below
+ This is the second and final mandatory argument, which purpose is to typeset the variable in which the function is differentiated with respect to. The variables are given in a comma-separated list e.g. \texttt{\{x, y, z\}}
\begin{example}
- \odv{f}{x} \\
- \odv{f}{y}
+ \pdv{f}{x} \\
+ \pdv{f}{x,y}
\end{example}
- \noindent The variable is always typeset in the denominator.
+ %\noindent The variable is always typeset in the denominator.
\end{argument}
\begin{argument}{6}
- This is the last optional argument that specifies the point(s) of evaluation. It is an \emph{e-type} argument in the \pkg{xparse} language and given as \verb|e{_^}|. This means that the subscript \verb|_| and superscript \verb|^| accepts an argument given in braces. Moreover, the order of \verb|_| and \verb|^| is independent as shown below
+ This is the last optional argument that specifies the point(s) of evaluation or variables held constant. It is an \emph{e-type} argument in the \pkg{xparse} language and is given by \verb|e{_^}|. This means that the subscript \verb|_| and superscript \verb|^| accepts an argument given in braces. Moreover, the order of \verb|_| and \verb|^| is independent as shown below
\begin{example}
- \odv{y}{x}_{x_1} \\
- \odv{y}{x}^{x_2} \\
- \odv{y}{x}_{x_1}^{x_2} \\
- \odv{y}{x}^{x_2}_{x_1}
+ \pdv{f}{x,y}_{(x_1,y_1)} \\
+ \pdv{f}{x,y}^{(x_2,y_2)} \\
+ \pdv{f}{x,y}_{(x_1,y_1)}^{(x_2,y_2)} \\
+ \pdv{f}{x,y}^{(x_2,y_2)}_{(x_1,y_1)}
\end{example}
- The common way to specify the point of evaluation is using the subscript argument. If needed, the second point of evaluation can be specified with the superscript argument.
+ \noindent The subscript argument is commonly used as the point of evaluation or variables held constant. If needed, the superscript argument may be used for the second point of evaluation.
\end{argument}
\end{function}
- \subsection{Variants}
- This package offers four variants of the ordinary derivative: Material derivative \macro{\mdv}, functional derivative \macro{\fdv}, the average rate of change \macro{\adv} and the Jacobian \macro{\jdv}. A unique feature of this package, is that you can define your own variants of the ordinary derivative as described in \cref{ssec:CreateOdvVariant}.
+ \subsection{Other derivatives}
+ This package offers five other derivatives: Ordinary derivative \macro{\odv}, material derivative \macro{\mdv}, functional derivative \macro{\fdv}, the average rate of change \macro{\adv} and the Jacobian \macro{\jdv}. A unique feature of this package, is that you can define your own derivatives as described in \cref{ssec:defvar_dv}.
+ \begin{function}{\odv}
+ \begin{syntax}
+ \sarg, \oarg{keyval list}, \marg{function}, \targ{/}, \marg{variables}, \earg{\_, point\tsb{1}, \^, point\tsb{2}}
+ \end{syntax}
+ In this package, the ordinary derivative is defined with an upright lowercase d as
+
+ \begin{definition}
+ \DeclareDerivative{\odv}{\mathrm{d}}%\marginnote{\pdftex}%
+ \DeclareDerivative{\odv}{\symup{d}}%\marginnote{\xetex, \luatex}%
+ \end{definition}
+ because it is used by many nowadays books
+ \begin{equation*}
+ \odv{f}{x} = \lim_{h\to 0} \mleft( \frac{ f(x+h) - f(x) }{ h } \mright)
+ \end{equation*}
+ However it can always be changed with the \key{style-inf} key.
+ \end{function}
+
\begin{function}{\mdv}
\begin{syntax}
- \sarg, \oarg{order}, \marg{function}, \targ{/}, \marg{variable}, \earg{\_, point\tsb{1}, \^, point\tsb{2}}
+ \sarg, \oarg{keyval list}, \marg{function}, \targ{/}, \marg{variables}, \earg{\_, point\tsb{1}, \^, point\tsb{2}}
\end{syntax}
- The material derivative is used in some branches of physics (e.g. thermodynamic, fluid dynamic etc.). It is only natural for a physics student as me to define such a variant, that used an upright uppercase D. In this package, the material derivative is defined as
+ The material derivative is used in some branches of physics e.g. thermodynamic, fluid dynamic etc. It is only natural for a physics student as me to define such a variant, that used an upright uppercase D. In this package, the material derivative is defined as
\begin{definition}
- \DeclareOdvVariant{\mdv}{D}[style-inf=\mathrm]%\marginnote{\pdftex\\\xetex, \luatex}%
- \DeclareOdvVariant{\mdv}{D}[style-inf=\symup]
+ \DeclareDerivative{\mdv}{\mathrm{D}}%\marginnote{\pdftex}%
+ \DeclareDerivative{\mdv}{\symup{D}}%\marginnote{\xetex, \luatex}%
\end{definition}
\noindent In physics, the material derivative is defined by
\begin{equation*}
- \mdv{ \varphi(\symbf{r}, t) }{ t } \coloneq \pdv{ \varphi(\symbf{r}, t) }{ t } + \dot{\symbf{r}} \cdot \nabla \varphi(\symbf{r}, t)
+ \mdv{ \varphi(\symbf{r}, t) }{ t } \coloneq \pdv{ \varphi(\symbf{r}, t) }{ t } + \dot{\symbf{r}} \cdot \nabla \varphi(\symbf{r}, t)
\end{equation*}
\end{function}
\begin{function}{\fdv}
\begin{syntax}
- \sarg, \oarg{order}, \marg{function}, \targ{/}, \marg{variable}, \earg{\_, point\tsb{1}, \^, point\tsb{2}}
+ \sarg, \oarg{keyval list}, \marg{function}, \targ{/}, \marg{variables}, \earg{\_, point\tsb{1}, \^, point\tsb{2}}
\end{syntax}
The functional derivative is used in the calculus of variation and uses a lowercase delta. With the package's default settings, it will use an italic delta. In this package, the functional derivative is defined as
\begin{definition}
- \DeclareOdvVariant{\fdv}{\delta}%\marginnote{\pdftex, \xetex, \luatex}%
+ \DeclareDerivative{\fdv}{\delta}%\marginnote{\pdftex, \xetex, \luatex}%
\end{definition}
\noindent In physics, it is for example used in the Lagrange equation or in the derivation of the Hartree-Fock equation
\begin{equation*}
- \fdv{I}{q_{\alpha}} = \pdv{L}{q_{\alpha}} - \odv*{ \pdv{L}{ \dot{q}_{\alpha} } } { t } = 0, \qquad \fdv{ \symcal{L} }{ \psi_{n}^* } = \hat{F} \ket{\psi_{n}} - \epsilon_{n} \ket{\psi_{n}} = 0
- ,
+ \fdv{I}{q_{\alpha}} = \pdv{L}{q_{\alpha}} - \odv*{ \pdv{L}{ \dot{q}_{\alpha} } } { t } = 0, \qquad \fdv{ \symcal{L} }{ \psi_{n}^* } = \hat{F} \ket{\psi_{n}} - \epsilon_{n} \ket{\psi_{n}} = 0
+ ,
\end{equation*}
respectively.
\end{function}
@@ -1256,164 +1520,177 @@
\begin{function}{\adv}
\begin{syntax}
- \sarg, \oarg{order}, \marg{function}, \targ{/}, \marg{variable}, \earg{\_, point\tsb{1}, \^, point\tsb{2}}
+ \sarg, \oarg{keyval list}, \marg{function}, \targ{/}, \marg{variables}, \earg{\_, point\tsb{1}, \^, point\tsb{2}}
\end{syntax}
The average rate of change is defined to use an upright uppercase delta with the packages default settings. In this package, the average rate of change is defined as
\begin{definition}
- \DeclareOdvVariant{\adv}{\Delta}[style-inf=\mathrm]%\marginnote{\pdftex\\\xetex, \luatex}%
- \DeclareOdvVariant{\adv}{\Delta}
+ \DeclareDerivative{\adv}{\Delta}%\marginnote{\pdftex, \xetex, \luatex}%
\end{definition}
\noindent The average rate of change is used to determine the slope of a straight line
\begin{equation*}
- \adv{ y }{ x } = \frac{y_2- y_1}{x_2 - x_1}
+ \adv{ y }{ x } = \frac{y_2- y_1}{x_2 - x_1}
\end{equation*}
\end{function}
- \begin{function}{\jdv}
+ \begin{function}{\jdv}[updated = v1.0]
\begin{syntax}
- \sarg, \oarg{order}, \marg{function}, \targ{/}, \marg{variable}, \earg{\_, point\tsb{1}, \^, point\tsb{2}}
+ \sarg, \oarg{keyval list}, \marg{function}, \targ{/}, \marg{variables}, \earg{\_, point\tsb{1}, \^, point\tsb{2}}
\end{syntax}
The Jacobian is defined to use an italic partial differential with the package's default settings. Also a pair of parentheses is automatically inserted around the function and variable. In this package, the Jacobian is defined as
\begin{definition}
- \DeclareOdvVariant{\jdv}{\partial}[misc-add-delims={fun,var}]%\marginnote{\pdftex, \xetex, \luatex}%
+ \DeclareDerivative{\jdv}{\partial}[fun=true, var=1]%\marginnote{\pdftex, \xetex, \luatex}%
\end{definition}
\noindent which gives
\begin{equation*}
- \jdv{f,g,h}{x,y,z}
+ \jdv{f,g,h}{x,y,z}
\end{equation*}
\end{function}
+ \clearpage
+ \section{Differentials}
-
-
- \clearpage
- \section{Partial derivative}
-
- \begin{function}*{\pdv}
+ \begin{function}*{\odif}[new = v1.0]
\begin{syntax}
- \sarg, \oarg{cs-orders}, \oarg{mixed order}, \marg{function}, \targ{/}, \marg{cs-variables}, \earg{\_,point\tsb{1},\^,point\tsb{2}}
+ \sarg, \oarg{keyval list}, \marg{variables}
\end{syntax}
- The partial derivative \macro{1} is defined with a set of mandatory and optional arguments that either typeset specific parts or changing the style of the derivative. In this package, the partial derivative is defined with an italic partial differential as
+ The differential \macro{1} using an lowercase d is defined with a set of mandatory and optional arguments that either typeset specific parts or changing the style of the differential. It is defined as
\begin{definition}
- \DeclarePdvVariant{\pdv}{\partial}[sep-inf-ord=1, sep-ord-fun=-2]%\marginnote{\pdftex, \xetex, \luatex}%
+ \DeclareDifferential{\odif}{\mathrm{d}}%\marginnote{\pdftex}%
+ \DeclareDifferential{\odif}{\symup{d}}%\marginnote{\xetex, \luatex}%
\end{definition}
\begin{argument}*{1}
- The first argument of \macro{1} is an optional star that determines where the function is typeset; either in the numerator of the fraction or next to the fraction. Using the
- option \keyval{switch-*}{false}, the function is typeset in the numerator when the star is absent, and next to the fraction when the star is present as shown below
+ The first argument of \macro{1} is an optional star that determines the notation style of the differential. Using the option \keyval{switch-*}{false}, the variables and orders are typeset in a subscript and superscript respectively when the star is present. When the star is absent, then the macros associated infinitesimal is placed in front of each variable as shown below
\begin{example}
- \pdv{f}{x,y} \\
- \pdv*{f}{x,y}
+ \odif{x,y,z} \\
+ \odif*{x,y,z}
\end{example}
- \noindent The effect of the star's presence can be switched around using \keyval{switch-*}{true} i.e. the equations in the above example are exchanged, as described in \cref{ssec:pdv_options}.
+ \noindent The effect of the star's presence can be switched around using \keyval{switch-*}{true} i.e. the equations in the above example are exchanged, as described in \cref{ssec:options_dv}.
\end{argument}
\begin{argument}{2}
- The second argument is optional and is written inside square brackets. This argument is used to set the order of differentiation for each of the variables and should be given in a comma-separated list e.g. \texttt{[1,2,3]} as shown below
+ The second argument is optional and is written inside square brackets. This argument is used to set the options of the differential using a \keyval[index=false]{key}{value} semantic.
\begin{example}
- \pdv[2,3]{f}{x,y} \\
- \pdv[\beta,a,n+2a]{f}{x,y,z} \\
- \pdv[2,n^2,n^2-1]{f}{x,y,z}
+ \odif[order={n,3}]{x,y,z} \\
+ \odif[sep-var-inf=0]{x,y,z} \\
+ \odif*[sep-var-var=0]{x,y,z}
\end{example}
- The orders may consist numbers, symbols and a combination hereof. Notice, that the mixed order is automatically calculated and sorted based on the variables orders by the package. See \cref{ssec:pdv_options,ssec:overall_order} for more information. This argument is subject to change, see \cref{consid:order2keyval} for more information.
+ \noindent The list of options that can be applied to differential can be is found in \cref{ssec:options_inf}
\end{argument}
\begin{argument}{3}
- If you, unfortunately, come to the conclusion, that you are unsatisfied with how the package typeset the mixed order or if it gives a wrong result, then you can overwrite it with this argument. The use of this argument completely bypass the automatic calculation and sorting done by the package, and simply typeset the mixed order as you wrote it as shown below
+ This is the mandatory argument, which purpose is to typeset the variables, as shown below
\begin{example}
- \pdv[4n+2k, 3k+n]{ f(x,y) }{ x,y } \\
- \pdv[4n+2k, 3k+n][5(n+k)]{ f(x,y) }{ x,y }
+ \odif{x} \\
+ \odif{s_1,s_2...,s_n}
\end{example}
-
- \noindent This argument is also subject to change, see \cref{consid:RemoveMixedOrder} for more information.
\end{argument}
+ \end{function}
+
+ \subsection{Other differentials}
+ This package offers four other differentials: partial differential \macro{\pdif}, uppercase D \macro{\mdif}, delta \macro{\fdif} and Delta \macro{\adif}. A unique feature of this package, is that you can define your own differential as described in \cref{ssec:defvar_inf}.
+
+ \begin{function}{\pdif}
+ \begin{syntax}
+ \sarg, \oarg{keyval list}, \marg{variables}
+ \end{syntax}
+ The partial differential \macro{1} is typically used as a shorthand notation for the partial derivative. In this package it is defined as
- \begin{argument}{4}
- This is the first mandatory argument that typeset the function that is to be partially differentiated as shown below
-
- \begin{example}
- \pdv{ f(x,y,z) }{ x, y, z } \\
- \pdv{ e^x \sin(y) \ln(z) }{ x, y, z }
- \end{example}
-
- \noindent The function is simply typeset in the numerator or next to the fraction.
- \end{argument}
+ \begin{definition}
+ \DeclareDifferential{\pdif}{\partial}[style-notation=single,
+ style-notation-*=mixed]%\marginnote{\pdftex, \xetex, \luatex}%
+ \end{definition}
- \begin{argument}{5}
- The fifth argument is an optional slash written \emph{between the function and the variables} and determines which fraction style the derivative is typeset with, as described in \cref{ssec:pdv_options}. Using the option \keyval{switch-/}{false} and the package's default settings, the derivative is typeset with \cs{frac} when the slash is absent and \cs{slashfrac}\footref{foot:sfrac} when the slash is present, as shown below
-
- \begin{example}
- \pdv{f}{x,y} \\
- \pdv{f}/{x,y}
- \end{example}
-
- \noindent As for the star argument, the effect of the slash's presence can be switched around using \keyval{switch-/}{true} i.e. the equations in the above example are exchanged, as described in \cref{ssec:pdv_options}.
- \end{argument}
+ \noindent The non-star and star version gives
+ \begin{align*}
+ \pdif[order={i,j,k}]{x,y,z} &\coloneq \pdv[order={i,j,k}]{}{x,y,z} \\
+ \pdif*[order={i,j,k}]{x,y,z} &\coloneq \pdv[order={i,j,k}]{}{x,y,z}
+ \end{align*}
+ respectively.
+ \end{function}
+
+ \begin{function}{\mdif}
+ \begin{syntax}
+ \sarg, \oarg{keyval list}, \marg{variables}
+ \end{syntax}
+ Another commonly used shorthand notation for various derivatives is the differential with a uppercase D. In this package it is defined with a upright D as
- \begin{argument}{6}
- This is the second and final mandatory argument, which purpose is to typeset the variables in which the function is partially differentiated with respect to. The variables are given in a comma-separated list e.g. \texttt{\{x, y, z\}}, as shown below
-
- \begin{example}
- \pdv{f}{x} \\
- \pdv{f}{x,y}
- \end{example}
-
- \noindent The variables are typeset in the denominator with a $\partial$ inserted to the left of them.
- \end{argument}
+ \begin{definition}
+ \DeclareDifferential{\mdif}{\mathrm{D}}[style-notation=single,
+ style-notation-*=mixed]%\marginnote{\pdftex}%
+ \DeclareDifferential{\mdif}{\symup{D}}[style-notation=single,
+ style-notation-*=mixed]%\marginnote{\xetex, \luatex}%
+ \end{definition}
- \begin{argument}{7}
- This is the last optional argument that specifies the point(s) of evaluation or variables held constant.
- It is an \emph{e-type} argument in the \pkg{xparse} language and given as \verb|e{_^}|. This means that the
- subscript \verb|_| and superscript \verb|^| accepts an argument given in braces. Moreover, the order
- of \verb|_| and \verb|^| is independent as shown below
-
- \begin{example}
- \pdv{f}{x,y}_{(x_1,y_1)} \\
- \pdv{f}{x,y}^{(x_2,y_2)} \\
- \pdv{f}{x,y}_{(x_1,y_1)}^{(x_2,y_2)} \\
- \pdv{f}{x,y}^{(x_2,y_2)}_{(x_1,y_1)}
- \end{example}
-
- The subscript argument is commonly used as the point of evaluation or variables held constant. If needed, the superscript argument may be used for the second point of evaluation.
- \end{argument}
+ \noindent The non-star and star version gives
+ \begin{align*}
+ \mdif[order={i,j,k}]{x,y,z} \\
+ \mdif*[order={i,j,k}]{x,y,z}
+ \end{align*}
+ respectively.
\end{function}
- \subsection{Variants}
- This package does not define any variants of the partial derivative. However, a unique feature of this package, is that you can define your own variants of the partial derivative as described in \cref{ssec:CreatePdvVariant}.
+ \begin{function}{\fdif}
+ \begin{syntax}
+ \sarg, \oarg{keyval list}, \marg{variables}
+ \end{syntax}
+ When working with functional derivatives another differential is frequently encountered. This differential uses a delta symbol and is defined as
+
+ \begin{definition}
+ \DeclareDifferential{\fdif}{\delta}%\marginnote{\pdftex, \xetex, \luatex}%
+ \end{definition}
+
+ \noindent For example an expression like
+ \begin{align*}
+ \fdif{J} = \int_{a}^{b} \pdv{L}{f} \fdif{f(x)} + \pdv{L}{f'} \odv*{ \fdif{f(x)} }{x} \odif{x}
+ \end{align*}
+ is frequently encountered.
+ \end{function}
+ \begin{function}{\adif}
+ \begin{syntax}
+ \sarg, \oarg{keyval list}, \marg{variables}
+ \end{syntax}
+ To wrap it up, a differential for differences is defined as
+
+ \begin{definition}
+ \DeclareDifferential{\adif}{\Delta}%\marginnote{\pdftex, \xetex, \luatex}%
+ \end{definition}
+
+ \noindent For example
+ \begin{align*}
+ \adif{E} = E_2 - E_1
+ \end{align*}
+ \end{function}
-
-
-
-
\clearpage
\section{Package options}
- This package accepts its options using the well-known \emph{key=value} syntax. The keys are divided into categories, for which each key have its associated category as a prefix. Each category and option is explained below.
+ This package accepts its options using the well-known \emph{key=value} syntax. The keys are divided into categories, for which each key have its associated category as a prefix. %Each category and option is explained below.
- \begin{function}{\derivset}
+ \begin{function}{\derivset}[updated = v1.0]
\begin{syntax}
- \marg{derivative}, \oarg{key=value}
+ \marg{command}, \oarg{keyval list}
\end{syntax}
- The package options can be set either in the preamble or in the document using the \macro{1} command. The options may also be set when defining a new derivative. Currently, there is no other way to set the options however this is subject to change, see \cref{consid:order2keyval} for more information.
+ The \macro{1} is meant to set the default values for derivatives and differentials options in the preamble. It can be used in the document but this is what the new \oarg{keyval list} arguments are for in the derivative and differential commands.
\begin{argument}{1}
- A mandatory argument that determines which derivative the \emph{key=value} pairs is assigned to, where the allowed \meta{main-category} are the derivatives defined by the packages and you, see \cref{ssec:CreateOdvVariant,ssec:CreatePdvVariant}. The special value \texttt{all} is also allowed, which gives access to the options that applies to \textit{all} derivatives.
+ A mandatory argument that determines which command the \emph{key=value} pairs is assigned to, where the allowed \meta{commands} are the derivatives and differentials defined by the package and you, see \cref{ssec:defvar_dv,ssec:defvar_inf} for more information. The special value \texttt{all} is also allowed, which gives access to the options that applies to \textit{all} derivatives and differentials.
\end{argument}
\begin{argument}{2}
- This optional argument accepts its input as a comma-separated list of \emph{key=value} pairs. Leaving out \arg{2} sets the options to the packages default settings for the chosen \arg{1} e.g. \macro{\derivset}[\narg{\macro{\odv}}] sets the options for the ordinary derivative to the packages default settings. This argument is subject to change, see \cref{consid:DerivsetOptional} for more information.
+ This optional argument accepts its input as a comma-separated list of \emph{key=value} pairs. Leaving out \arg{2} sets the options to the package's default settings for the chosen \arg{1}. E.g. \macro{\derivset}[\narg{\macro{\odv}}] sets the options for the ordinary derivative to the packages default settings. %This argument is subject to change, see \cref{consid:DerivsetOptional} for more information.
\end{argument}
\end{function}
@@ -1421,29 +1698,30 @@
This section seeks to give a detailed description of each category.
\begin{itemize}
- \item The \key[index=false]{style-\meta{\dots}} keys sets either the font style or the fraction style of \meta{\dots}. The font styles \cs{mathnormal}/\cs{symnormal} and \cs{mathrm}/\cs{symup} are commonly used in literature. The fraction style can be either \cs{frac}, \cs{dfrac}, \cs{tfrac}, \cs{sfrac}\req{}, \cs{slashfrac}\footref{foot:sfrac} and many more.
+ \item The \key[index=false]{style-\meta{\dots}} keys sets either the font style or the fraction style of \meta{\dots}. The font styles \cs{mathnormal}/\cs{symnormal} and \cs{mathrm}/\cs{symup} are commonly used in literature. The fraction style can be either \cs{frac}, \cs{dfrac}, \cs{tfrac}, \cs{sfrac}\req{}, \cs{slashfrac}\footref{foot:sfrac} or any command with two mandatory arguments.
\item The \key[index=false]{delims-\meta{\dots}} keys sets the delimiters used around the \meta{\dots}. The Rule of Two applies here: \enquote{Always two there are, no more, no less. A left and a right delimiter}. The allowed delimiters are those that can be scaled with \cs{left}, \cs{big} etc.
\item The \key[index=false]{scale-\meta{\dots}} keys sets the size of the \meta{\dots}'s delimiters. The values \texttt{big}, \texttt{Big}, \texttt{bigg}, and \texttt{Bigg} are self-explanatory and internally a left and right version are used e.g. \cs{bigl} and \cs{bigr}. The value \texttt{none} inserts the delimiters (except periods) unscaled. While the value \texttt{auto} scales the delimiters automatically using \cs{left} and \cs{right}.
- \item The \key[index=false]{sep-\meta{\dots}-\meta{\dots}} keys inserts math space between \meta{\dots} and \meta{\dots} using \cs{mskip}. These keys accepts a comma-separated list of numbers \texttt{\{x,y,z\}} that are internally used to form the syntax \texttt{x mu plus y mu minus z mu}.
+ \item The \key[index=false]{sep-\meta{\dots}-\meta{\dots}} keys inserts their value between \meta{\dots} and \meta{\dots}. If the value is a comma-separated list of up to three numbers (e.g. \texttt{\{x,y,z\}}) it will be converted into the syntax \texttt{\cs{muskip} x mu plus y mu minus z mu} and inserted. All other values are used as they were given.
\item The \key[index=false]{switch-\meta{\dots}} keys serves to change an argument's behaviour by swapping the effect of an optional character's presence.
- \item The \key[index=false]{sort-\meta{\dots}} keys deals with the sorting algorithm behind the mixed order, where you can choose the sorting method that suits you best. These keys are unique to the partial derivative and variants of it.
- \item The \key[index=false]{mics-\meta{\dots}} keys are miscellaneous keys that does not belong to any of the above categories.
+ \item The \key[index=false]{sort-\meta{\dots}} keys deals with the sorting algorithm behind the mixed order, where you can choose the sorting method that suits you best.
+ \item The miscellaneous keys does not fit into any of the above categories and no longer have the prefix \key[index=false]{misc}
\end{itemize}
\begin{note}
- A value with superscripted \texttt{U}, \texttt{P} and \texttt{R} refers to a unicode engine i.e. \luatex{} and \xetex, \pdftex{} and requires package, respectively. Additionally, some keys have two versions; with and without \texttt{-/} at the end. These keys are related to the slash argument. If \keyval{switch-/}{false} then the keys with and without \texttt{-/} are used when the slash argument is present and absent, respectively. Setting \keyval{switch-/}{true} then these keys are used in the opposite cases for the slash's presence.
+ A value with superscripted \texttt{U}, \texttt{P} and \texttt{R} refers to a unicode engine i.e. \luatex{} and \xetex, \pdftex{} and requires package, respectively. Additionally, some keys have two versions; with and without \texttt{-/} at the end. These keys are related to the slash argument. If \keyval{switch-/}{false} then the keys with and without \texttt{-/} are used when the slash argument is present and absent, respectively. Setting \keyval{switch-/}{true} then these keys are used in the opposite cases of the slash argument's presence.
\end{note}
- \subsection{Ordinary derivative} \label{ssec:odv_options}
- The options in this subsection are available for the ordinary derivative \macro{\odv} and variants hereof that are defined by the package and you.
+ \subsection{Derivative options} \label{ssec:options_dv}
+ The options in this subsection are available for derivatives defined by the package and you with the commands in \cref{ssec:defvar_dv}.
\subsubsection*{Style}
- \begin{option}*{style-inf}
- \begin{values}[default = { \cs{mathnormal}\pdf, \cs{symnormal}\uni }]
- \meta{math-font-style}
+ \begin{option}*{style-inf}[updated = v1.0]
+ \begin{values}[default = d]
+ \meta{math-font-style}\meta{infinitesimal}
\end{values}
- The font style of the infinitesimal for the chosen derivative is set by this key. The default font style is \default*. If an upright font is preferred then \cs{mathrm}\pdf{} and \cs{symup}\uni{} could be used, or if an italic font then \cs{mathnormal}\pdf{} and \cs{symit}\uni.
+ Sets the derivative's infinitesimal including font style. This change was necessary to allow multiple font styles, e.g. \keyval{style-inf}{\cs{mathbf}\{\cs{mathrm}\{d\}\}}.
+ The default font style is \default. If an upright font is preferred then \cs{mathrm}\pdf{} and \cs{symup}\uni{} could be used, or if an italic font then \cs{mathnormal}\pdf{} and \cs{symit}\uni.
\end{option}
\begin{option}{style-frac}
@@ -1450,7 +1728,7 @@
\begin{values}[default = \cs{frac}]
\meta{fraction}
\end{values}
- The derivative uses the fraction set by this key whenever \keyval{switch-/}{false} and the slash argument is absent. The key's default value is the usual fraction \default.
+ The derivative uses the fraction set by this key whenever \keyval{switch-/}{false} and the slash argument is absent. The key's default value is the usual fraction \cs{frac}.
\end{option}
\begin{option}{style-frac-/}
@@ -1457,9 +1735,18 @@
\begin{values}[default = \cs{slashfrac}]
\meta{fraction}
\end{values}
- The derivative uses the fraction set by this key whenever \keyval{switch-/}{false} and the slash argument is present. The key's default value is a text-styled fraction \default\footref{foot:sfrac} i.e. on the form $\derivset{\odv}[style-frac-/=\slashfrac, switch-/=false] \odv{y}/{x}$.
+ The derivative uses the fraction set by this key whenever \keyval{switch-/}{false} and the slash argument is present. The key's default value is a text-styled fraction \default\footref{foot:sfrac} i.e. on the form $\pdv[style-frac-/=\slashfrac, switch-/=false]{f}/{x,y}$.
\end{option}
+ \begin{option}{style-var}[new = v1.0]
+ \begin{values}[default = single]
+ single, multiple
+ \end{values}
+ This option determines how the derivative treats its variables and some features. The variable argument is treated as a single variable when \val{single} is used. Moreover the mixed order is set equal to the first order given in \keyval[cat=misc]{order}{\meta{order}} which by default is \val{1}. The variable argument is treated as a comma separated list of variables with \val{multiple} similarly to a partial derivative. Moreover the mixed order is automatically calculated from the list of orders given in \keyval[cat=misc]{order}{\meta{order}}.
+ \end{option}
+
+ \clearpage
+
\subsubsection*{Scaling}
\begin{option}*{scale-eval}
@@ -1480,7 +1767,7 @@
\begin{values}[default = auto]
auto, none, big, Big, bigg, Bigg
\end{values}
- This key sets the size of the delimiters used around the function. The scaling is used whenever \keyval{misc-add-delims}{fun} is used. The key's default value is set to scale the delimiters automatically.
+ This key sets the size of the delimiters used around the function. The scaling is used whenever \keyval[cat=misc]{fun}{true} is used. The key's default value is set to scale the delimiters automatically.
\end{option}
\begin{option}{scale-var}
@@ -1487,7 +1774,7 @@
\begin{values}[default = auto]
auto, none, big, Big, bigg, Bigg
\end{values}
- This key sets the size of the delimiters used around the variable. The scaling is used whenever \keyval{misc-add-delims}{var} is used. The key's default value is set to scale the delimiters automatically.
+ This key sets the size of the delimiters used around the variable. The scaling is used whenever \keyval[cat=misc]{var}{true} is used. The key's default value is set to scale the delimiters automatically.
\end{option}
\begin{option}{scale-frac}
@@ -1494,7 +1781,7 @@
\begin{values}[default = auto]
auto, none, big, Big, bigg, Bigg
\end{values}
- This key sets the size of the delimiters used for around the fraction. This scaling is used whenever \keyval{switch-/}{false}, the slash argument is absent and \keyval{misc-add-delims}{frac} is used. The key's default value is set to scale the delimiters automatically.
+ This key sets the size of the delimiters used for around the fraction. This scaling is used whenever \keyval{switch-/}{false}, the slash argument is absent and \keyval[cat=misc]{frac}{true} is used. The key's default value is set to scale the delimiters automatically.
\end{option}
\begin{option}{scale-frac-/}
@@ -1501,7 +1788,7 @@
\begin{values}[default = auto]
auto, none, big, Big, bigg, Bigg
\end{values}
- This key sets the size of the delimiters used for around the fraction. This scaling is used whenever \keyval{switch-/}{false}, the slash argument is present and \keyval{misc-add-delims}{frac} is used. The key's default value is set to scale the delimiters automatically.
+ This key sets the size of the delimiters used for around the fraction. This scaling is used whenever \keyval{switch-/}{false}, the slash argument is present and \keyval[cat=misc]{frac}{true} is used. The key's default value is set to scale the delimiters automatically.
\end{option}
\subsubsection*{Delimiters}
@@ -1510,7 +1797,7 @@
\begin{values}[default = .~\cs{rvert}]
\meta{left delimiter}\meta{right delimiter}
\end{values}
- This key sets the left and right delimiters used to indicate the point of evaluation. These delimiters are inserted whenever \keyval{switch-/}{false} and the slash argument is absent. The default left and right delimiters is a period\footnote{which doesn't output anything.\label{foot:period_no_output}} and a vertical bar, respectively.
+ This key sets the left and right delimiters used to indicate the point of evaluation. These delimiters are inserted whenever \keyval{switch-/}{false} and the slash argument is absent. The key's default left and right delimiters are a left and a right parenthesis, respectively.
\end{option}
\begin{option}{delims-eval-/}
@@ -1517,7 +1804,7 @@
\begin{values}[default = .~\cs{rvert}]
\meta{left delimiter}\meta{right delimiter}
\end{values}
- This key sets the left and right delimiters used to indicate the point of evaluation. These delimiters are inserted whenever \keyval{switch-/}{false} and the slash argument is present. The default left and right delimiters is a period\footref{foot:period_no_output} and a vertical bar, respectively.
+ This key sets the left and right delimiters used to indicate the point of evaluation. These delimiters are inserted whenever \keyval{switch-/}{false} and the slash argument is present. The key's default left and right delimiters are a left and a right parenthesis, respectively.
\end{option}
\begin{option}{delims-fun}
@@ -1524,14 +1811,16 @@
\begin{values}[default = (~)]
\meta{left delimiter}\meta{right delimiter}
\end{values}
- This key sets the left and right delimiters used to around the function and these are inserted whenever \keyval{misc-add-delims}{fun} is used. The key's default left and right delimiters are a left and a right parenthesis, respectively.
+ This key sets the left and right delimiters used around the function and these are inserted whenever \keyval[cat=misc]{fun}{true} is used. The key's default left and right delimiters are a left and a right parenthesis, respectively.
\end{option}
+ \clearpage
+
\begin{option}{delims-var}
\begin{values}[default = (~)]
\meta{left delimiter}\meta{right delimiter}
\end{values}
- This key sets the left and right delimiters used to around the variable and these are inserted whenever \keyval{misc-add-delims}{var} is used. The key's default left and right delimiters are a left and a right parenthesis, respectively.
+ This key sets the left and right delimiters used around the variable and these are inserted whenever \keyval[cat=misc]{var}{true} is used. The key's default left and right delimiters are a left and a right parenthesis, respectively.
\end{option}
\begin{option}{delims-frac}
@@ -1538,7 +1827,7 @@
\begin{values}[default = (~)]
\meta{left delimiter}\meta{right delimiter}
\end{values}
- This key sets the left and right delimiters used to around the fraction in the derivative e.g. $\derivset{\odv}[misc-add-delims=frac] \odv*{y}{x}$ These delimiters are inserted whenever \keyval{switch-/}{false}, the slash argument is absent and \keyval{misc-add-delims}{frac} is used. The key's default left and right delimiters are a left and a right parenthesis, respectively.
+ This key sets the left and right delimiters used around the fraction in the derivative e.g. $\pdv*[frac=true]{y}{x}$. These delimiters are inserted whenever \keyval{switch-/}{false}, the slash argument is absent and \keyval[cat=misc]{frac}{true} is used. The key's default left and right delimiters are a left and a right parenthesis, respectively.
\end{option}
\begin{option}{delims-frac-/}
@@ -1545,59 +1834,101 @@
\begin{values}[default = (~)]
\meta{left delimiter}\meta{right delimiter}
\end{values}
- This key sets the left and right delimiters used to around the fraction in the derivative e.g. $\derivset{\odv}[misc-add-delims=frac] \odv*{y}/{x}$ These delimiters are inserted whenever \keyval{switch-/}{false}, the slash argument is present and \keyval{misc-add-delims}{frac} is used. The key's default left and right delimiters are a left and a right parenthesis, respectively.
+ This key sets the left and right delimiters used around the fraction in the derivative e.g. $\pdv*[frac=true]{y}/{x}$. These delimiters are inserted whenever \keyval{switch-/}{false}, the slash argument is present and \keyval[cat=misc]{frac}{true} is used. The key's default left and right delimiters are a left and a right parenthesis, respectively.
\end{option}
\subsubsection*{Math spacing}
- The options in this subsection inserts extra horizontal math space. The below equation illustrates where the space is inserted
+ The options in this subsection inserts extra horizontal math space. The below equation illustrates where the space is inserted for each option
+ \begin{align*}
+ \begin{gathered}
+ \frac{ \partial }{ \partial x } \ms{frac-fun} f \\
+ \frac{ \partial^{ \ms{inf-ord} 2 } f }{ \partial x^{ \ms{var-ord} 2 } }
+ \end{gathered}
+ &&
+ \begin{gathered}
+ \frac{ \partial \ms{inf-fun} f }{ \partial \ms{inf-var} x } \\
+ \frac{ \partial^3 \ms{ord-fun} f }{ \partial x^2 \ms{ord-inf} \partial y }
+ \end{gathered}
+ &&
+ \begin{gathered}
+ \frac{ \partial^2 f }{ \partial x \ms{var-inf} \partial y } \\
+ \mleft( \frac{ \partial f}{ \partial x } \mright)_{ \ms{eval-sb} x_1}^{ \ms{eval-sp} x_2}
+ \end{gathered}
+ \end{align*}
+ where it have been split into six to give a better overview. Here $\ms{\dots}$ means the value given to the option \key[index=false]{sep-\meta{\dots}}. Some of the math spaces shown above are only used when \keyval{style-var}{multiple}. Additionally, when the option \keyval{style-var}{single} is used then the following math space is used in the denominator
\begin{equation*}
- \frac{ \symup{d} \ms{inf-fun} y }{ \symup{d} \ms{inf-var} x }
- \qquad
- \frac{ \symup{d}^{ \ms{inf-ord} 2 } \ms{ord-fun} y }{ \symup{d} x^{ \ms{var-ord} 2 } }
- \qquad
- \mleft. \frac{ \symup{d} y}{ \symup{d} x } \mright\rvert_{ \ms{eval-sb} x_1}^{ \ms{eval-sp} x_2}
- ,
+ \frac{\partial(f, g)}{\partial(x \ms{var-var} y)}
\end{equation*}
- where it has been split into three to give a better overview.
+ where the Jacobian have been used as an example.
\begin{option}{sep-inf-ord}
\begin{values}[default = 0]
- \meta{cs-numbers}
+ \meta{cs-number}, \marg{mspace}, \marg{delimiter}
\end{values}
- This key sets the math space that is inserted in the infinitesimal's power left to the order. It is only inserted when the order is different from \num{1}. The key's default value is \default{} \texttt{mu}.
+ Sets the math space that is inserted in the infinitesimal's power left to the mixed order in the numerator. It is only inserted when the mixed order is different from \num{1}. The key's default value is \default{} \texttt{mu}.
\end{option}
\begin{option}{sep-inf-fun}
\begin{values}[default = 0]
- \meta{cs-numbers}
+ \meta{cs-number}, \marg{mspace}, \marg{delimiter}
\end{values}
- This key sets the math space that is inserted between the infinitesimal and the function when the order \emph{is equal} to \num{1}. The space is only inserted when a non-blank function is printed \emph{in the numerator}. The key's default value is \default{} \texttt{mu}.
+ This key sets the math space that is inserted between the infinitesimal and the function when the mixed order \emph{is equal} to \num{1}. The space is only inserted when a non-blank function is printed \emph{in the numerator}. The key's default value is \default{} \texttt{mu}.
\end{option}
+ \clearpage
+
\begin{option}{sep-ord-fun}
\begin{values}[default = 0]
- \meta{cs-numbers}
+ \meta{cs-number}, \marg{mspace}, \marg{delimiter}
\end{values}
- This key sets the math space that is inserted between the infinitesimal and the function when the order \emph{is different} from \num{1}. The space is only inserted when a non-blank function is printed \emph{in the numerator}. The key's default value is \default{} \texttt{mu}.
+ This key sets the math space that is inserted between the infinitesimal's order and the function when the mixed order \emph{is different} from \num{1}. The space is only inserted when a non-blank function is printed \emph{in the numerator}. The key's default value is \default{} \texttt{mu}.
\end{option}
+ \begin{option}{sep-frac-fun}[new = v1.0]
+ \begin{values}[default = 0]
+ \meta{cs-number}, \marg{mspace}, \marg{delimiter}
+ \end{values}
+ This key sets the math space that is inserted between the fractional part of the derivative and the function. The space is only inserted when a non-blank function is printed \emph{next to the derivative}. The key's default value is \default{} \texttt{mu}.
+ \end{option}
+
\begin{option}{sep-inf-var}
\begin{values}[default = 0]
- \meta{cs-numbers}
+ \meta{cs-number}, \marg{mspace}, \marg{delimiter}
\end{values}
- This key sets the math space that is inserted between the infinitesimal and the variable. The space is only inserted when a non-blank variable is given. The key's default value is \default{} \texttt{mu}.
+ This key sets the math space that is inserted between the infinitesimal and the following variable. The space is only inserted when a non-blank variable is given. The key's default value is \default{} \texttt{mu}.
\end{option}
\begin{option}{sep-var-ord}
\begin{values}[default = 0]
- \meta{cs-numbers}
+ \meta{cs-number}, \marg{mspace}, \marg{delimiter}
\end{values}
- This key sets the math space that is inserted in the variable's power left to the order. The space is only inserted when the order is different from \num{1}. The key's default value is \default{} \texttt{mu}.
+ This key sets the math space that is inserted in a variable's power left to the order. The space is only inserted when the order is different from \num{1}. The key's default value is \default{} \texttt{mu}.
\end{option}
+ \begin{option}{sep-var-inf}
+ \begin{values}[default = \cs{mathop}\{\}\cs{!}]
+ \meta{cs-number}, \marg{mspace}, \marg{delimiter}
+ \end{values}
+ They key sets the math space that is inserted between a variable and the following infinitesimal. The space is only inserted when the variable's order \emph{is equal} to \num{1}. It is only inserted when more than one non-blank variables are given. The key's default value is \default{}.
+ \end{option}
+
+ \begin{option}{sep-ord-inf}
+ \begin{values}[default = \cs{mathop}\{\}\cs{!}]
+ \meta{cs-number}, \marg{mspace}, \marg{delimiter}
+ \end{values}
+ They key sets the math space that is inserted between a variable and the following infinitesimal. The space is only inserted when the variable's order \emph{is different} from \num{1}. It is only inserted when more than one non-blank variables are given. The key's default value is \default{}.
+ \end{option}
+
+ \begin{option}{sep-var-var}[new = v1.0]
+ \begin{values}[default = {{,}}]
+ \meta{cs-number}, \marg{mspace}, \marg{delimiter}
+ \end{values}
+ They key sets the math space that is inserted between two variables. The space is only inserted when the \keyval{style-var}{single} is used. and when more than one non-blank variables are given. The key's default value is a comma.
+ \end{option}
+
\begin{option}{sep-eval-sb}
\begin{values}[default = 0]
- \meta{cs-numbers}
+ \meta{cs-number}, \marg{mspace}, \marg{delimiter}
\end{values}
This key sets the math space that is inserted in the evaluation subscript left to the point of evaluation. The space is only inserted when a non-blank subscript is given. The key's default value is \default{} \texttt{mu}.
\end{option}
@@ -1604,11 +1935,13 @@
\begin{option}{sep-eval-sp}
\begin{values}[default = 0]
- \meta{cs-numbers}
+ \meta{cs-number}, \marg{mspace}, \marg{delimiter}
\end{values}
This key sets the math space that is inserted in the evaluation superscript left to the point of evaluation. The space is only inserted when a non-blank superscript is given. The key's default value is \default{} \texttt{mu}.
\end{option}
+ \clearpage
+
\subsubsection*{Switches}
\begin{option}*{switch-*}
@@ -1615,14 +1948,14 @@
\begin{values}[default = false]
true, false
\end{values}
- The effect of the star's presence can be switched with the value \val{true}. That is, the function is typeset next to the fraction when the star is absent and in the numerator when the star is present. As an example, compare below where the option is turned on (\val{true}) and off (\val{false}),
+ The effect of the star argument's presence can be switched with the value \val{true}. That is, the function is typeset next to the fraction when the star is absent and in the numerator when the star is present. As an example, compare below where the option is turned on (\val{true}) and off (\val{false})
\begin{example}
- \derivset{\odv}[switch-*=false] \odv{y}{x} \\
- \derivset{\odv}[switch-*=true] \odv{y}{x}
+ \pdv[switch-*=false]{y}{x} \\
+ \pdv[switch-*=true]{y}{x}
\end{example}
- \noindent The key's default value is \default.
+ \noindent respectively. The key's default value is \default.
\end{option}
\begin{option}{switch-/}
@@ -1629,236 +1962,280 @@
\begin{values}[default = false]
true, false
\end{values}
- The effect of the slash's presence can be switched with the value \val{true}. That is, the derivative is typeset with the fraction set by \key{style-frac-/} when the slash is absent and with the fraction set by \key{style-frac} when the slash is present. As an example, compare below where the option is turned on (\val{true}) and off (\val{false}),
+ The effect of the slash argument's presence can be switched with the value \val{true}. That is, the derivative is typeset with the fraction set by \key{style-frac-/} when the slash is absent and with the fraction set by \key{style-frac} when the slash is present. As an example, compare below where the option is turned on (\val{true}) and off (\val{false})
\begin{example}
- \derivset{\odv}[switch-/=false] \odv{y}{x} \\
- \derivset{\odv}[switch-/=true] \odv{y}{x}
+ \pdv[switch-/=false]{y}{x} \\
+ \pdv[switch-/=true]{y}{x}
\end{example}
- \noindent The key's default value is \default.
+ \noindent respectively. The key's default value is \default.
\end{option}
- \subsubsection*{Miscellaneous}
+ \subsubsection*{Sort}
+ The keys given in this subsection will be briefly described here and a in-depth description will be given in \cref{ssec:overall_order}.
- \begin{option}*{misc-add-delims, misc-remove-delims}
- \begin{values}
- fun, var, frac
+ \begin{option}{sort-method}[updated = v1.0]
+ \begin{values}[default = {sign, symbol, abs}]
+ abs, number, sign, symbol
\end{values}
- These two keys accepts its input as an comma-separated list of values such that
- \begin{verbatim}
- \derivset{\odv}[misc-add-delims=fun]
- \derivset{\odv}[misc-add-delims={fun,var}]
- \derivset{\odv}[misc-add-delims={fun,var,frac}]
- \end{verbatim}
- are all valid, and the same goes for \key{misc-remove-delims}. The key \key{misc-add-delims}{} is used to insert the delimiters around the key's values, while \key{misc-remove-delims}{} is used to remove the inserted delimiters. The next example shows the key \key{misc-add-delims} in action
+ This key sets the sorting method behind the mixed order using build-in algorithms. The symbolic terms in the mixed order are sorted by their sign, symbolic length, numerical value and absolute value by the \val{sign}, \val{symbol}, \val{number} and \val{abs} algorithms, respectively. The key takes its input as a comma-separated list of values, accepting up to three values e.g.
\begin{example}
- \derivset{\odv}[misc-add-delims=fun] \odv{y}{x} \\
- \derivset{\odv}[misc-add-delims={fun,var}] \odv{y}{x} \\
- \derivset{\odv}[misc-add-delims={fun,var,frac}] \odv{y}{x}
+ \pdv[sort-method=sign, order={c+kn,-b+2a}]{f}{x,y} \\
+ \pdv[sort-method={sign,symbol}, order={c+kn,-b+2a}]{f}{x,y} \\
+ \pdv[sort-method={sign,symbol,abs}, order={c+kn,-b+2a}]{f}{x,y}
\end{example}
- \noindent All the above applies to \key{misc-remove-delims}{} as well, except it removes the delimiters. The effect of the key \key{misc-add-delims}{} is turned off (\val{false}) locally inside a derivative. This is to ensure that the option is not applied to more than one derivative when nested as shown below
+ \noindent are all valid inputs. Note how the terms are ordered differently with different methods. This key is further described in \cref{ssec:sort-method}. The key's default value uses the three algorithms \val{\default}.
+ \end{option}
+
+ \begin{option}{sort-numerical}[updated = v1.0]
+ \begin{values}[default = auto]
+ auto, first, last, symbolic
+ \end{values}
+ This key determines where the numerical term\footnote{The numerical term is the sum of all the orders that does not contain any symbols but solely consist of numbers.\label{foot:numerical-term}} is placed in the mixed order. The numerical term will \emph{always} be placed as the first with \val{first} and as the last term with \val{last} in the mixed order. While \val{auto} will automatically determine where to place the numerical term depending on the sign of the first symbolic term. This is shown below
\begin{example}
- \derivset{\odv}[misc-add-delims=var] \odv*{\odv{y}{x}}{x} \\
- \derivset{\odv}[misc-add-delims=fun] \odv*{\odv{y}{x}}{x} \\
- \derivset{\odv}[misc-add-delims=frac] \odv*{\odv{y}{x}}{x}
+ \pdv[sort-numerical=first, order={n,2}]{f}{x,y} \\
+ \pdv[sort-numerical=last, order={-n,2}]{f}{x,y}
\end{example}
- \noindent These two keys and this local behaviour are subject to change, see \cref{revis:add_remove,consid:add_remove_local} for more information.
+ \noindent where the value \val{auto} would have placed the numerical term opposite in both equations. The value \val{symbolic} treats the numerical term as a symbolic term with symbolic length equal zero and is thus sorted alongside with all other terms
+ \begin{example}
+ \pdv[sort-numerical=symbolic, order={2+n,-a}]{f}{x,y}
+ \end{example}
+ The key is further described in \cref{ssec:sort-numerical}, and its default value is \default.
\end{option}
+ \begin{option}{sort-abs-reverse}
+ \begin{values}[default = false]
+ true, false
+ \end{values}
+ The sorting algorithm \val{abs} sorts the terms by their absolute value in a descending manner. If the value \val{true} is used, then the terms will be sorted in an ascending manner instead. See \cref{ssec:sort-reverse} for more information.
+ \end{option}
- \subsection{Partial derivative} \label{ssec:pdv_options}
- The options in this subsection are available for the partial derivative \macro{\pdv} and variants hereof that are defined by the package and you.
-
- \subsubsection*{Style}
-
- \begin{option}*{style-inf}
- \begin{values}[default = { \cs{mathnormal}\pdf, \cs{symnormal}\uni }]
- \meta{math-font-style}
+ \begin{option}{sort-number-reverse}[new = v1.0]
+ \begin{values}[default = false]
+ true, false
\end{values}
- The font style of the infinitesimal for the chosen derivative is set by this key. The default font style is \default*. If an upright font is preferred then \cs{mathrm}\pdf{} and \cs{symup}\uni{} could be used, or if an italic font then \cs{mathnormal}\pdf{} and \cs{symit}\uni.
+ The sorting algorithm \val{number} sorts the terms by their numerical value in a descending manner. If the value \val{true} is used, then the terms will be sorted in an ascending manner instead. See \cref{ssec:sort-reverse} for more information.
\end{option}
- \begin{option}{style-frac}
- \begin{values}[default = \cs{frac}]
- \meta{fraction}
+ \begin{option}{sort-sign-reverse}
+ \begin{values}[default = false]
+ true, false
\end{values}
- The derivative uses the fraction set by this key whenever \keyval{switch-/}{false} and the slash argument is absent. The key's default value is the usual fraction \cs{frac}.
+ The sorting algorithm \val{sign} sorts the terms by their numerical sign where the positive terms are placed before the negative terms. The value \val{true} will reverse this ordering such that the negative terms are placed before the positive terms. See \cref{ssec:sort-reverse} for more information.
\end{option}
- \begin{option}{style-frac-/}
- \begin{values}[default = \cs{slashfrac}]
- \meta{fraction}
+ \begin{option}{sort-symbol-reverse}
+ \begin{values}[default = false]
+ true, false
\end{values}
- The derivative uses the fraction set by this key whenever \keyval{switch-/}{false} and the slash argument is present. The key's default value is a text-styled fraction \default\footref{foot:sfrac} i.e. on the form $\derivset{\pdv}[style-frac-/=\slashfrac, switch-/=false] \pdv{f}/{x,y}$.
+ The sorting algorithm \val{symbol} sorts the terms by their symbolic length in a descending manner. If the value \val{true} is used, then the terms will sorted in an ascending manner instead. See \cref{ssec:sort-reverse} for more information.
\end{option}
- \subsubsection*{Scaling}
+ \clearpage
- \begin{option}*{scale-eval}
- \begin{values}[default = auto]
- auto, none, big, Big, bigg, Bigg
+ \subsubsection*{Miscellaneous}
+
+ \begin{option}*{fun}[cat=misc, new = v1.0]
+ \begin{values}
+ true, false
\end{values}
- This key sets the size of the delimiters used for the point of evaluation. This scaling is used whenever \keyval{switch-/}{false} and the slash argument is absent. The key's default value is set to scale the delimiters automatically.
+ Adds or remove delimiters around the function.
+ \begin{example}
+ \pdv[fun=false]{f}{x,y,z} \\
+ \pdv[fun=true]{f}{x,y,z} \\
+ \pdv[fun]{f}{x,y,z}
+ \end{example}
+ Without setting the option to a value is equivalent to setting it to \val{true} as seen above.
\end{option}
- \begin{option}{scale-eval-/}
- \begin{values}[default = auto]
- auto, none, big, Big, bigg, Bigg
+ \begin{option}{frac}[cat=misc, new = v1.0]
+ \begin{values}
+ true, false
\end{values}
- This key sets the size of the delimiters used for the point of evaluation. This scaling is used whenever \keyval{switch-/}{false} and the slash argument is present. The key's default value is set to scale the delimiters automatically.
+ Adds or remove delimiters around the fractional part of the derivative.
+ \begin{example}
+ \pdv[frac=false]{f}{x,y,z} \\
+ \pdv[frac=true]{f}{x,y,z} \\
+ \pdv*[frac=true]{f}{x,y,z} \\
+ \pdv[frac]{f}{x,y,z}
+ \end{example}
+ Without setting the option to a value is equivalent to setting it to \val{true} as seen above.
\end{option}
- \begin{option}{scale-fun}
- \begin{values}[default = auto]
- auto, none, big, Big, bigg, Bigg
+ \begin{option}{var}[cat=misc, new = v1.0]
+ \begin{values}[default=none]
+ none, all, \meta{cs-numbers}
\end{values}
- This key sets the size of the delimiters used around the function. The scaling is used whenever \keyval{misc-add-delims}{fun} is used. The key's default value is set to scale the delimiters automatically.
+ Adds or remove delimiters around the variable. The value \val{all} adds delimiters around all variables and \val{none} removed all delimiters. However, if only some variables needs delimiters then \meta{cs-numbers} can be used e.g. \keyval*[cat=misc]{var}{1,3} adds delimiters around the first and third variable
+ \begin{example}
+ \pdv[var=none]{f}{x,y,z,t} \\
+ \pdv[var={1,3}]{f}{x,y,z,t} \\
+ \pdv[var=all]{f}{x,y,z,t} \\
+ \pdv[var]{f}{x,y,z,t}
+ \end{example}
+ Without setting the option to a value is equivalent to setting it to \val{all} as seen above.
\end{option}
- \begin{option}{scale-var}
- \begin{values}[default = auto]
- auto, none, big, Big, bigg, Bigg
+ \clearpage
+
+ \begin{option}{order, ord}[cat=misc, new = v1.0]
+ \begin{values}[default = 1]
+ \marg{cs-orders}
\end{values}
- This key sets the size of the delimiters used around the variable. The scaling is used whenever \keyval{misc-add-delims}{var} is used. The key's default value is set to scale the delimiters automatically.
+ Sets the order of differentiation for each variable as a comma separated list of values.
\end{option}
- \begin{option}{scale-frac}
- \begin{values}[default = auto]
- auto, none, big, Big, bigg, Bigg
+ \bigskip\bigskip
+
+ \begin{option}{mixed-order, mixord}[cat=misc, new = v1.0]
+ \begin{values}[default = 1]
+ \marg{mixed order}
\end{values}
- This key sets the size of the delimiters used for around the fraction. This scaling is used whenever \keyval{switch-/}{false}, the slash argument is absent and \keyval{misc-add-delims}{frac} is used. The key's default value is set to scale the delimiters automatically.
+ The mixed order is automatically calculated from the orders of differentiation set by \keyval[cat=misc]{order}{\marg{orders}}.
+ In cases where it fails or another form is preferred, the calculated mixed order can be overwritten with this option.
\end{option}
- \begin{option}{scale-frac-/}
- \begin{values}[default = auto]
- auto, none, big, Big, bigg, Bigg
+ \subsection{Differential options} \label{ssec:options_inf}
+ The options in this subsection are available for differentials defined by the package and you with the commands in \cref{ssec:defvar_inf}. All options in this section were introduced in \texttt{v1.0}.
+
+ \subsubsection*{Style}
+
+ \begin{option}*{style-inf}[updated = v1.0]
+ \begin{values}[default = d]
+ \meta{math-font-style}\meta{infinitesimal}
\end{values}
- This key sets the size of the delimiters used for around the fraction. This scaling is used whenever \keyval{switch-/}{false}, the slash argument is present and \keyval{misc-add-delims}{frac} is used. The key's default value is set to scale the delimiters automatically.
+ Sets the differential's infinitesimal including font style. This change was necessary to allow multiple font styles, e.g. \keyval{style-inf}{\cs{mathbf}\{\cs{mathrm}\{d\}\}}. The default font style is \default*. If an upright font is preferred then \cs{mathrm}\pdf{} and \cs{symup}\uni{} could be used, or if an italic font is preferred then \cs{mathnormal}\pdf{} and \cs{symit}\uni.
\end{option}
- \subsubsection*{Delimiters}
-
- \begin{option}*{delims-eval}
- \begin{values}[default = (~)]
- \meta{left delimiter}\meta{right delimiter}
+ \begin{option}{style-notation}
+ \begin{values}[default = multiple]
+ single, multiple, mixed
\end{values}
- This key sets the left and right delimiters used to indicate the point of evaluation. These delimiters are inserted whenever \keyval{switch-/}{false} and the slash argument is absent. The key's default left and right delimiters are a left and a right parenthesis, respectively.
+ Sets the differential's notation when the star argument is absent (given \keyval{switch-*}{false}). The key's default value is \val{\default}. The value \val{single} creates a single differential with the variables and orders in a subscript and superscript, respectively. The value \val{multiple} creates a differentials for each variable. The value \val{mixed} creates multiple differentials with the variables and orders in a subscript and superscript, respectively.
+
+ \begin{example}
+ \odif[style-notation=multiple, order={n,1,2}]{x,y,z,t} \\
+ \odif[style-notation=single, order={n,1,2}]{x,y,z,t} \\
+ \odif[style-notation=mixed, order={n,1,2}]{x,y,z,t}
+ \end{example}
+
\end{option}
- \begin{option}{delims-eval-/}
- \begin{values}[default = (~)]
- \meta{left delimiter}\meta{right delimiter}
+ \begin{option}{style-notation-*}
+ \begin{values}[default = single]
+ single, multiple, mixed
\end{values}
- This key sets the left and right delimiters used to indicate the point of evaluation. These delimiters are inserted whenever \keyval{switch-/}{false} and the slash argument is present. The key's default left and right delimiters are a left and a right parenthesis, respectively.
+ Sets the differential's notation when the star argument is present (given \keyval{switch-*}{false}). The key's default value is \val{\default}.
\end{option}
- \begin{option}{delims-fun}
- \begin{values}[default = (~)]
- \meta{left delimiter}\meta{right delimiter}
+ \subsubsection*{Scaling}
+
+ \begin{option}{scale-var}
+ \begin{values}[default = auto]
+ auto, none, big, Big, bigg, Bigg
\end{values}
- This key sets the left and right delimiters used to around the function and these are inserted whenever \keyval{misc-add-delims}{fun} is used. The key's default left and right delimiters are a left and a right parenthesis, respectively.
+ Sets the size of the delimiters used around the variable when the star argument is absent (given \keyval{switch-*}{false}). The scaling is used whenever \keyval[cat=misc]{var}{true} is used. The key's default value is set to scale the delimiters automatically.
\end{option}
- \begin{option}{delims-var}
- \begin{values}[default = (~)]
- \meta{left delimiter}\meta{right delimiter}
+ \begin{option}{scale-var-*}
+ \begin{values}[default = auto]
+ auto, none, big, Big, bigg, Bigg
\end{values}
- This key sets the left and right delimiters used to around the variable and these are inserted whenever \keyval{misc-add-delims}{var} is used. The key's default left and right delimiters are a left and a right parenthesis, respectively.
+ Sets the size of the delimiters used around the variable when the star argument is present (given \keyval{switch-*}{false}). The scaling is used whenever \keyval[cat=misc]{var}{true} is used. The key's default value is set to scale the delimiters automatically.
\end{option}
- \begin{option}{delims-frac}
+ \subsubsection*{Delimiters}
+
+ \begin{option}{delims-var}
\begin{values}[default = (~)]
\meta{left delimiter}\meta{right delimiter}
\end{values}
- This key sets the left and right delimiters used to around the fraction in the derivative e.g. $\derivset{\pdv}[misc-add-delims=frac] \pdv*{y}{x}$. These delimiters are inserted whenever \keyval{switch-/}{false}, the slash argument is absent and \keyval{misc-add-delims}{frac} is used. The key's default left and right delimiters are a left and a right parenthesis, respectively.
+ Sets the left and right delimiters used around the variable when the star argument is absent (given \keyval{switch-*}{false}). The delimiters are inserted when \keyval[cat=misc]{var}{true} is used. The key's default delimiters are a left and right parenthesis, respectively.
\end{option}
- \begin{option}{delims-frac-/}
+ \begin{option}{delims-var-*}
\begin{values}[default = (~)]
\meta{left delimiter}\meta{right delimiter}
\end{values}
- This key sets the left and right delimiters used to around the fraction in the derivative e.g. $\derivset{\pdv}[misc-add-delims=frac] \pdv*{y}/{x}$. These delimiters are inserted whenever \keyval{switch-/}{false}, the slash argument is present and \keyval{misc-add-delims}{frac} is used. The key's default left and right delimiters are a left and a right parenthesis, respectively.
+ Sets the left and right delimiters used around the variable when the star argument is present (given \keyval{switch-*}{false}). The delimiters are inserted when \keyval[cat=misc]{var}{true} is used. The key's default delimiters are a left and right parenthesis, respectively.
\end{option}
\subsubsection*{Math spacing}
- The options in this subsection inserts extra horizontal math space. The below equation illustrates where the space is inserted
- \begin{equation*}
- \frac{ \partial \ms{inf-fun} f }{ \partial \ms{inf-var} x }
- \qquad
- \frac{ \partial^{ \ms{inf-ord} 2 } \ms{ord-fun} f }{ \partial x \ms{var-inf} \partial y }
- \qquad
- \frac{ \partial^{ 3 } f }{ \partial x^{ \ms{var-ord} 2 } \ms{ord-inf} \partial y }
- \qquad
- \mleft( \frac{ \partial f}{ \partial x } \mright)_{ \ms{eval-sb} (x_1,y_1)}^{ \ms{eval-sp} (x_2,y_2)}
- \end{equation*}
+ The options in this subsection inserts extra horizontal math space. Below, illustrates where the space is inserted for each option
+ \begin{align*}
+ \begin{gathered}
+ \partial \ms{inf-var} x \ms{var-inf} \partial y \\
+ \partial^{ \ms{inf-ord} 2 } \ms{ord-var} x
+ \end{gathered}
+ &&
+ \begin{gathered}
+ \ms{begin} \partial x \ms{end} \\
+ \partial^{ 2\ms{ord-ord} 2 }_{ x \ms{var-var} y }
+ \end{gathered}
+ \end{align*}
where it have been split into four to give a better overview.
- \begin{option}{sep-inf-ord}
- \begin{values}[default = 0]
- \meta{cs-number}
+ \begin{option}{sep-begin}
+ \begin{values}[default = \cs{mathop}\{\}\cs{!}]
+ \meta{cs-number}, \marg{mspace}, \marg{delimiter}
\end{values}
- This key sets the math space that is inserted in the infinitesimal's power left to the mixed order. It is only inserted when the mixed order is different from \num{1}. The key's default value is \default{} \texttt{mu}.
+ Sets the math space that is inserted to the left of the first differential. The key's default value is \val{\default}.
\end{option}
- \begin{option}{sep-inf-fun}
+ \begin{option}{sep-inf-ord}
\begin{values}[default = 0]
- \meta{cs-number}
+ \meta{cs-number}, \marg{mspace}, \marg{delimiter}
\end{values}
- This key sets the math space that is inserted between the infinitesimal and the function when the mixed order \emph{is equal} to \num{1}. The space is only inserted when a non-blank function is printed \emph{in the numerator}. The key's default value is \default{} \texttt{mu}.
+ This key sets the math space that is inserted in the infinitesimal's power left to the order. It is only inserted when the mixed order is different from \num{1}. The key's default value is \default{} \texttt{mu}.
\end{option}
- \begin{option}{sep-ord-fun}
- \begin{values}[default = 0]
- \meta{cs-number}
- \end{values}
- This key sets the math space that is inserted between the infinitesimal and the function when the mixed order \emph{is different} from \num{1}. The space is only inserted when a non-blank function is printed \emph{in the numerator}. The key's default value is \default{} \texttt{mu}.
- \end{option}
-
\begin{option}{sep-inf-var}
\begin{values}[default = 0]
- \meta{cs-number}
+ \meta{cs-number}, \marg{mspace}, \marg{delimiter}
\end{values}
- This key sets the math space that is inserted between the infinitesimal and the following variable. The space is only inserted when a non-blank variable is given. The key's default value is \default{} \texttt{mu}.
+ This key sets the math space that is inserted between the infinitesimal and the following variable. The space is only inserted when the order \emph{is equal} to \num{1}when a non-blank variable is given. The key's default value is \default{} \texttt{mu}.
\end{option}
- \begin{option}{sep-var-ord}
+ \begin{option}{sep-ord-var}
\begin{values}[default = 0]
- \meta{cs-number}
+ \meta{cs-number}, \marg{mspace}, \marg{delimiter}
\end{values}
- This key sets the math space that is inserted in a variable's power left to the order. The space is only inserted when the order is different from \num{1}. The key's default value is \default{} \texttt{mu}.
+ This key sets the math space that is inserted between the infinitesimal's power and the following variable. The space is only inserted when the order \emph{is different} from \num{1} and a non-blank variable is given. The key's default value is \default{} \texttt{mu}.
\end{option}
+ \clearpage
+
\begin{option}{sep-var-inf}
- \begin{values}[default = 3]
- \meta{cs-number}
+ \begin{values}[default = \cs{mathop}\{\}\cs{!}]
+ \meta{cs-number}, \marg{mspace}, \marg{delimiter}
\end{values}
- They key sets the math space that is inserted between a variable and the following infinitesimal. The space is only inserted when the variable's order \emph{is equal} to \num{1}. It is only inserted when more than one non-blank variables are given. The key's default value is \default{} \texttt{mu}.
+ They key sets the math space that is inserted between a variable and the following infinitesimal. It is only inserted when more than one non-blank variables are given. The key's default value is \val{\default}.
\end{option}
- \begin{option}{sep-ord-inf}
- \begin{values}[default = 3]
- \meta{cs-number}
+ \begin{option}{sep-var-var}
+ \begin{values}[default = {{,}}]
+ \meta{cs-number}, \marg{mspace}, \marg{delimiter}
\end{values}
- They key sets the math space that is inserted between a variable and the following infinitesimal. The space is only inserted when the variable's order \emph{is different} from \num{1}. It is only inserted when more than one non-blank variables are given. The key's default value is \default{} \texttt{mu}.
+ Sets the math space that is inserted between two variables. The space is only inserted when \keyval{style-var}{single} and more than one non-blank variables are given. The key's default value is a comma.
\end{option}
- \begin{option}{sep-eval-sb}
- \begin{values}[default = -4]
- \meta{cs-number}
+ \begin{option}{sep-ord-ord}
+ \begin{values}[default = {{,}}]
+ \meta{cs-number}, \marg{mspace}, \marg{delimiter}
\end{values}
- This key sets the math space that is inserted in the evaluation subscript left to the point of evaluation. The space is only inserted when a non-blank subscript is given. The key's default value is \default{} \texttt{mu}.
+ Sets the math space that is inserted between two orders. The space is only inserted when \keyval{style-var}{single} and more than one non-blank orders are given. The key's default value is a comma.
\end{option}
- \begin{option}{sep-eval-sp}
- \begin{values}[default = -4]
- \meta{cs-number}
+ \begin{option}{sep-end}
+ \begin{values}[default = \cs{mathop}\{\}\cs{!}]
+ \meta{cs-number}, \marg{mspace}, \marg{delimiter}
\end{values}
- This key sets the math space that is inserted in the evaluation superscript left to the point of evaluation. The space is only inserted when a non-blank superscript is given. The key's default value is \default{} \texttt{mu}.
+ Sets the math space that is inserted to the right of the last differential. The key's default value is \val{\default}.
\end{option}
\subsubsection*{Switches}
@@ -1867,115 +2244,42 @@
\begin{values}[default = false]
true, false
\end{values}
- The effect of the star's presence can be switched with the value \val{true}. That is, the function is typeset next to the fraction when the star is absent and in the numerator when the star is present. As an example, compare below where the option is turned on (\val{true}) and off (\val{false}),
+ The effect of the star argument's presence can be switched with the value \val{true}. As an example, compare below where the option is turned on (\val{true}) and off (\val{false}),
\begin{example}
- \derivset{\pdv}[switch-/=false] \pdv{y}{x} \\
- \derivset{\pdv}[switch-/=true] \pdv{y}{x}
+ \odif[switch-*=false]{x,y,z,t} \\
+ \odif[switch-*=true]{x,y,z,t}
\end{example}
\noindent The key's default value is \default.
\end{option}
- \begin{option}{switch-/}
- \begin{values}[default = false]
- true, false
- \end{values}
- The effect of the slash's presence can be switched with the value \val{true}. That is, the derivative is typeset with the fraction set by \key{style-frac-/} when the slash is absent and with the fraction set by \key{style-frac} when the slash is present. As an example, compare below where the option is turned on (\val{true}) and off (\val{false}),
-
- \begin{example}
- \derivset{\pdv}[switch-/=false] \pdv{y}{x} \\
- \derivset{\pdv}[switch-/=true] \pdv{y}{x}
- \end{example}
-
- \noindent The key's default value is \default.
- \end{option}
-
\subsubsection*{Miscellaneous}
- \begin{option}*{misc-add-delims, misc-remove-delims}
- \begin{values}
- fun, var, frac
+ \begin{option}*{var}[cat=misc]
+ \begin{values}[default=none]
+ none, all, \meta{cs-numbers}
\end{values}
- These two keys accepts its input as an comma-separated list of values such that
- \begin{verbatim}
- \derivset{\pdv}[misc-add-delims=fun]
- \derivset{\pdv}[misc-add-delims={fun,var}]
- \derivset{\pdv}[misc-add-delims={fun,var,frac}]
- \end{verbatim}
- are all valid, and the same goes for \key{misc-remove-delims}. The key \key{misc-add-delims}{} is used to insert the delimiters around the key's values, while \key{misc-remove-delims}{} is used to remove the inserted delimiters. The next example shows the key \key{misc-add-delims} in action
-
+ Adds or remove delimiters around the variable. The value \val{all} adds delimiters around all variables and \val{none} removed all delimiters. However, if only some variables needs delimiters then \meta{cs-numbers} can be used e.g. \keyval*[cat=misc]{var}{1,3} adds delimiters around the first and third variable
\begin{example}
- \derivset{\pdv}[misc-add-delims=fun] \pdv{y}{x} \\
- \derivset{\pdv}[misc-add-delims={fun,var}] \pdv{y}{x} \\
- \derivset{\pdv}[misc-add-delims={fun,var,frac}] \pdv{y}{x}
+ \odif[var=none]{x,y,z,t} \\
+ \odif[var={1,3}]{x,y,z,t} \\
+ \odif[var=all]{x,y,z,t} \\
+ \odif[var]{x,y,z,t}
\end{example}
-
- \noindent All the above applies to \key{misc-remove-delims}{} as well, except it removes the delimiters. The effect of the key \key{misc-add-delims}{} is turned off (\val{false}) locally inside a derivative. This is to ensure that the option is not applied to more than one derivative when nested as shown below
-
- \begin{example}
- \derivset{\pdv}[misc-add-delims=var] \pdv*{\pdv{y}{x}}{x}
- \end{example}
-
- \noindent These two keys and this local behaviour are subject to change, see \cref{revis:add_remove,consid:add_remove_local} for more information.
+ Without setting the option to a value is equivalent to setting it to \val{all} as seen above.
\end{option}
- \subsubsection*{Sort}
- The keys given in this subsection will be briefly described here and a more in-depth description will be given in \cref{ssec:overall_order}.
-
- \begin{option}{sort-method}
- \begin{values}[default = {sign, symbol, abs}]
- abs, sign, symbol
+ \begin{option}{order, ord}[cat=misc]
+ \begin{values}[default = 1]
+ \marg{cs-orders}
\end{values}
- This key sets the sorting method behind the mixed order using build in algorithms. The symbolic terms in the mixed order is sorted by sign, symbolic length and absolute value by the \val{sign}, \val{symbol} and \val{abs} algorithms, respectively. The key takes its input as a comma-separated list of values, accepting up to three values e.g.
-
- \begin{example}*
- \derivset{\pdv}[sort-method=sign] \pdv[c+kn,-b+2a]{f}{x,y} \\
- \derivset{\pdv}[sort-method={sign,symbol}] \pdv[c+kn,-b+2a]{f}{x,y} \\
- \derivset{\pdv}[sort-method={sign,symbol,abs}] \pdv[c+kn,-b+2a]{f}{x,y}
- \end{example}
-
- \noindent are valid inputs. Note how the terms in the mixed order are ordered using different sorting methods. This key is further described in \cref{ssec:sort-method}. The key's default value uses all three algorithms as \default.
+ Sets the differentiation order of each variable.
\end{option}
- \begin{option}{sort-numerical}
- \begin{values}[default = auto]
- auto, first, last
- \end{values}
- This key determines where the numerical term\footnote{The numerical term is the sum of all the orders that does not contain any symbols, but solely consist of numbers.\label{foot:numerical-term}} is placed in the mixed order. Using the values \val{first} and \val{last}, then the numerical term will \emph{always} be placed as the first and last term in the mixed order, respectively. While the value \val{auto} will automatically determine where to place the numerical term depending on the sign of the first symbolic term; it is placed as the first and last term if the sign is negative and positive, respectively. This is shown below
-
- \begin{example}*
- \derivset{\pdv}[sort-numerical=first] \pdv[n,2]{f}{x,y} \\
- \derivset{\pdv}[sort-numerical=last] \pdv[-n,2]{f}{x,y}
- \end{example}
-
- \noindent where the value \val{auto} would have placed the numerical term opposite in both equations. The key is further described in \cref{ssec:sort-numerical}, and its default value is \default.
- \end{option}
+ \subsection{All derivatives and differentials} \label{ssec:both_options}
+ The options in this subsection are applied to all derivatives and differential because some options should be consisting regardless of the derivative and differential. The options are accessed using \macro{\derivset}[\narg{all},\oarg{key=value}].
- \begin{option}{sort-sign-reverse}
- \begin{values}[default = false]
- true, false
- \end{values}
- The sorting algorithm \val{sign} separates the positive and negative terms where the former is placed first and the latter last. The value \val{true} will reverse this ordering such that the negative terms is placed first and the positive terms last. See \cref{ssec:sort-reverse} for more information.
- \end{option}
-
- \begin{option}{sort-symbol-reverse}
- \begin{values}[default = false]
- true, false
- \end{values}
- The sorting algorithm \val{symbol} separates the terms by their symbolic length, where the terms are ordered in a descending manner according to their length. If the value \val{true} is used, then the terms will ordered in a ascending manner instead. See \cref{ssec:sort-reverse} for more information.
- \end{option}
-
- \begin{option}{sort-abs-reverse}
- \begin{values}[default = false]
- true, false
- \end{values}
- The sorting algorithm \val{abs} separates the terms by their absolute value, where the terms are ordered in a descending manner. If the value \val{true} is used, then the terms will ordered in a ascending manner instead. See \cref{ssec:sort-reverse} for more information.
- \end{option}
-
- \subsection{All derivatives} \label{ssec:both_options}
- The options in this subsection are applied to all of the derivatives that are defined by the package and you, because some options should be consisting regardless of the derivatives. The options are accessed using \macro{\derivset}[\narg{all},\oarg{key=value}].
-
\begin{option}{scale-auto}
\begin{values}[default = leftright]
leftright, mleftmright\req
@@ -1985,20 +2289,17 @@
-
-
-
\clearpage
- \section{Defining variants} \label{sec:createvariants}
- This section goes into detail with how to define variants of the ordinary and partial derivative based on the package's internal commands, as mentioned earlier. The \mypackage{} package provides a \latex2 way of defining the derivatives. Thought it is preferable to define variants of the ordinary derivative over the partial derivative, unless one needs more than one variable of differentiation and access to the mixed order.
+ \section{Defining variants} \label{sec:defvar}
+ This section goes into detail with how to define derivative and differential variants based on the package's internal commands, as mentioned earlier. The \mypackage{} package provides a \latex2 way of defining the derivatives.
- \subsection{Variants of the ordinary derivative} \label{ssec:CreateOdvVariant}
+ \subsection{Derivative variant} \label{ssec:defvar_dv}
- \begin{function}*{\NewOdvVariant, \RenewOdvVariant, \ProvideOdvVariant, \DeclareOdvVariant}
+ \begin{function}*{\NewDerivative, \RenewDerivative, \ProvideDerivative, \DeclareDerivative}
\begin{syntax}
\meta{control-sequence}, \marg{infinitesimal}, \oarg{key=value}
\end{syntax}
- This family of commands are used to define a variant of the ordinary derivative with the macro name \arg{1}. Moreover, the new derivative will use \arg{2} as its infinitesimal and inherit the package's default settings given in \cref{ssec:odv_options}, but they may be overwritten with \arg{3}. The difference between them, is as follows:
+ This family of commands are used to define a derivative variant with the macro name \arg{1}. Moreover, the new derivative will use \arg{2} as its infinitesimal and inherit the package's default settings given in \cref{ssec:options_dv}, but they may be overwritten with \arg{3}. The difference between them is as follows:
\begin{itemize}
\item \macro{1} is similar to \cs{NewDocumentCommand} of the \pkg{xparse} package and will issue an error if \arg{1} has already been defined.
\item \macro{2} is similar to \cs{RenewDocumentCommand} of the \pkg{xparse} package and will issue an error if \arg{1} has not previously been defined.
@@ -2011,21 +2312,21 @@
\end{argument}
\begin{argument}{2}
- While the second argument makes the derivative \arg{1} use \arg{2} as the infinitesimal, like \enquote{d} is used as the infinitesimal in the ordinary derivative \macro{\odv}.
+ The second argument makes the derivative \arg{1} use \arg{2} as its infinitesimal. It is equivalent to setting \keyval{style-inf}{\arg{2}}.
\end{argument}
\begin{argument}{3}
- The optional argument accepts its input as a comma-separated list of \emph{key=value} pairs, which overrides the package's default options for the keys given. Leaving out this argument, then the derivative will use the package's default settings.
+ The optional argument accepts its input as a comma-separated list of \emph{key=value} pairs, which overrides the package's default options for the keys given. The derivative \arg{1} will use the package's default settings if the argument is left out.
\end{argument}
\end{function}
- \subsection{Variants of the partial derivative} \label{ssec:CreatePdvVariant}
+ \subsection{Differential variant} \label{ssec:defvar_inf}
- \begin{function}*{\NewPdvVariant, \RenewPdvVariant, \ProvidePdvVariant, \DeclarePdvVariant}
+ \begin{function}*{\NewDifferential, \RenewDifferential, \ProvideDifferential, \DeclareDifferential}
\begin{syntax}
\meta{control-sequence}, \marg{infinitesimal}, \oarg{key=value}
\end{syntax}
- This family of commands are used to define a variant of the partial derivative with the macro name \arg{1}. Moreover, the new derivative will use \arg{2} as its infinitesimal and inherit the package's default options given in \cref{ssec:pdv_options}, but they may be overwritten with \arg{3}. The difference between them is as follows:
+ This family of commands are used to define a differential variant with the macro name \arg{1}. Moreover, the new derivative will use \arg{2} as its infinitesimal and inherit the package's default options given in \cref{ssec:options_inf}, but they may be overwritten with \arg{3}. The difference between them is as follows:
\begin{itemize}
\item \macro{1} is similar to \cs{NewDocumentCommand} of the \pkg{xparse} package and will issue an error if \arg{1} has already been defined.
@@ -2035,153 +2336,155 @@
\end{itemize}
\begin{argument}{1}
- The first argument is the macro name of the derivative that is to be defined.
+ The first argument is the macro name of the differential that is to be defined.
\end{argument}
\begin{argument}{2}
- While the second argument makes the derivative \arg{1} use \arg{2} as the infinitesimal, like \enquote{$\partial$} is used as the infinitesimal in the partial derivative \macro{\pdv}.
+ While the second argument makes the differential \arg{1} use \arg{2} as its infinitesimal. It is equivalent to setting \keyval{style-inf}{\arg{2}}.
\end{argument}
\begin{argument}{3}
- The optional argument accepts its input as a comma-separated list of \emph{key=value} pairs, which overrides the package's default options for the keys given. Leaving out this argument, then the derivative will use the package's default settings.
+ The optional argument accepts its input as a comma-separated list of \emph{key=value} pairs, which overrides the package's default options for the keys given. The derivative \arg{1} will use the package's default settings if the argument is left out.
\end{argument}
\end{function}
-
-
\clearpage
\section{The mixed order} \label{ssec:overall_order}
\subsection{Sorting algorithms} \label{ssec:sort-method}
- A unique feature of this package is that the sorting method behind the mixed order may be changed using built-in algorithms and there are currently three algorithms available: \val{sign}, \val{symbol} and \val{abs} which are explained below. The algorithms have been chosen such that it the terms in the mixed order may be arranged in many ways with as few algorithms as possible to suit your liking. A sorting method may consist of up to three algorithms which are applied in layers.
+ A unique feature of this package is that the sorting method behind the mixed order may be changed using built-in algorithms and there are currently four available: \val{abs}, \val{number}, \val{sign} and \val{symbol}. The algorithms have been chosen such that it the terms in the mixed order may be arranged in many ways with as few algorithms as possible to suit your liking. A sorting method may consist of up to three algorithms which are applied in layers.
\begin{itemize}
- \item The sorting algorithm \val{sign} separates the positive and negative terms, putting the former terms first and the latter terms last in the mixed order. Using the option \keyval{sort-sign-reverse}{true}, then this ordering is reversed such that the negative terms appear before the positive terms.
- \item The sorting algorithm \val{symbol} separates the terms by their symbolic length, where the terms are ordered in a descending manner according to their length. Using the option \keyval{sort-symbol-reverse}{true}, then the terms are ordered in a ascending manner instead.
- \item The sorting by \val{abs} separates the terms by their absolute value, where the terms are ordered in a descending manner according to their absolute value. Using the option \keyval{sort-abs-reverse}{true}, then the terms are ordered in an ascending manner instead.
+ \item The sorting algorithm \val{sign} separates the positive and negative terms, and puts the positive terms before the negative terms in the mixed order. The option \keyval{sort-sign-reverse}{true} reverses ordering is reversed such that the negative terms appear before the positive terms.
+ \item The sorting algorithm \val{symbol} separates the terms by their symbolic length, where the terms are sorted in a descending manner according to their length. The option \keyval{sort-symbol-reverse}{true} sorts the terms in a ascending manner instead.
+ \item The sorting by \val{abs} separates the terms by their absolute value, where the terms are ordered in a descending manner. The option \keyval{sort-abs-reverse}{true} sorts the terms in an ascending manner instead.
+ \item The sorting by \val{number} separates the terms by their numerical value, where the terms are ordered in a descending manner. The option \keyval{sort-number-reverse}{true} sort the terms in an ascending manner instead.
\end{itemize}
- When using the option \keyval{sort-method}{\{...\}}, the number of algorithms determines the number of layers e.g. \keyval{sort-method}{\{sign,symbol\}} is a sorting method with two layers, where the algorithms \val{sign} and \val{symbol} are applied in layer \num{1} and layer \num{2}, respectively. It should be understood as that the \val{sign} algorithm splits the terms into two groups, one with positive terms and one with negative terms. Then the \val{symbol} algorithm will order the terms within each groups according to the terms symbolic length. The mixed order is then formed by combining these two groups such that the positive terms comes first.
+ When using the option \keyval{sort-method}{\{...\}}, the number of algorithms determines the number of layers e.g. \keyval*{sort-method}{sign,symbol} is a sorting method with two layers, where the algorithms \val{sign} and \val{symbol} are applied in layer \num{1} and layer \num{2}, respectively. E.i the \val{sign} algorithm splits the terms into two groups, one with positive terms and one with negative terms. Then the \val{symbol} algorithm will sorts the terms within each groups according to the terms symbolic length. The mixed order is then formed by combining these two groups.
- The next subsubsection is dedicated to give some examples of how the algorithms in this package sorts the mixed order.
-
\subsubsection{Examples}
- The examples are constructed of a partial derivative with the comma separated list of orders given by \texttt{[3a-3hh-2b, 4c+4gg+2ff, -5d-5ee]} and a close up view of the mixed order. Square brackets are used to indicate grouping of terms and the text below a group refers to the algorithm applied. Here the words positive and negative, long and short, and big and low refers to the \val{sign}, \val{symbol}, and \val{abs} algorithms, respectively. A row of square brackets represents a layer.
+ The examples below are uses partial derivatives with \keyval*[cat=misc]{order}{3a-3hh-2b, 4c+4gg+2ff, -5d-5ee} and a close up view of the mixed order. Square brackets are used to indicate grouping of terms and the text below a group refers to the algorithm applied. Here the words positive and negative, long and short, and big and low refers to the \val{sign}, \val{symbol}, and \val{abs} algorithms, respectively. A row of square brackets represents a layer.
- The packages default sorting method is \keyval{sort-method}{\{sign,symbol,abs\}}, which is used below. The \val{sign} algorithm separate the positive and negative terms in the first layer. While in the second layer, the terms are separated by symbol length etc.
+ The packages default sorting method is \keyval*{sort-method}{sign,symbol,abs} which is used below. The \val{sign} algorithm separate the positive and negative terms in the first layer. While in the second layer, the terms are separated by symbol length etc.
\begin{equation*}
- \derivset{\pdv}[sort-method = {sign,symbol,abs}]
- \pdv[3a-3hh-2b, 4c+4gg+2ff, -5d-5ee]{f}{x,y,z}
+ \pdv[sort-method = {sign,symbol,abs}, order={3a-3hh-2b, 4c+4gg+2ff, -5d-5ee}]{f}{x,y,z}
\end{equation*}
\begin{equation*}
- \low{
\low{
- \low{4gg}{big} +
- \low[2,2]{2ff}{low}
- }{long} +
- \low{
- \low[1,2]{4c}{big} +
- \low[1,1]{3a}{low}
- }{short}
- }{positve} -
- \low{
+ \low{
+ \low{4gg}{big} +
+ \low[2,2]{2ff}{low}
+ }{long} +
+ \low{
+ \low[1,2]{4c}{big} +
+ \low[1,1]{3a}{low}
+ }{short}
+ }{positve} -
\low{
- \low[3,3]{5ee}{big} -
- \low[2,2]{3hh}{low}
- }{long} -
- \low{
- \low[1,1]{5d}{big} -
- \low[2,2]{2b}{low}
- }{short}
- }{negative}
+ \low{
+ \low[3,3]{5ee}{big} -
+ \low[2,2]{3hh}{low}
+ }{long} -
+ \low{
+ \low[1,1]{5d}{big} -
+ \low[2,2]{2b}{low}
+ }{short}
+ }{negative}
\end{equation*}
- as expected. Interchanging \val{sign} and \val{symbol} algorithms from the previous example i.e \keyval{sort-method}{\{symbol,sign,abs\}}, then the \val{symbol} \cal{sign} algorithms are now applied in the first and second layer, respectively. The result is shown below
+ as expected. Interchanging \val{sign} and \val{symbol} from the previous example i.e \keyval*{sort-method}{symbol,sign,abs}, then the \val{symbol} and \val{sign} algorithms are now applied in the first and second layer, respectively. The result is shown below
\begin{equation*}
- \derivset{\pdv}[sort-method = {symbol,sign,abs}]
- \pdv[3a-3hh-2b, 4c+4gg+2ff, -5d-5ee]{f}{x,y,z}
+ \pdv[sort-method = {symbol,sign,abs}, order={3a-3hh-2b, 4c+4gg+2ff, -5d-5ee}]{f}{x,y,z}
\end{equation*}
\begin{equation*}
- \low{
\low{
- \low{4gg}{big} +
- \low[2,2]{2ff}{low}
- }{positive} -
+ \low{
+ \low{4gg}{big} +
+ \low[2,2]{2ff}{low}
+ }{positive} -
+ \low{
+ \low[3,3]{5ee}{big} -
+ \low[2,2]{3hh}{low}
+ }{negative}
+ }{long} +
\low{
- \low[3,3]{5ee}{big} -
- \low[2,2]{3hh}{low}
- }{negative}
- }{long} +
- \low{
- \low{
- \low[1,2]{4c}{big} +
- \low[1,1]{3a}{low}
- }{positive} -
- \low{
- \low[1,1]{5d}{big} -
- \low[2,2]{2b}{low}
- }{negative}
- }{short}
+ \low{
+ \low[1,2]{4c}{big} +
+ \low[1,1]{3a}{low}
+ }{positive} -
+ \low{
+ \low[1,1]{5d}{big} -
+ \low[2,2]{2b}{low}
+ }{negative}
+ }{short}
\end{equation*}
where a clear difference is seen between the above two examples.
- The above two examples used 3-layer sorting methods but as mentioned earlier, the sorting method can also be constructed with one and two algorithms i.e. 1-layer and 2-layer sorting methods. A sorting method with two layers could be constructed as \keyval{sort-method}{\{sign,symbol\}} and with it, the terms are ordered by sign and then symbolic length. In this case, there is not a third layer. Instead, the terms \enquote{appear randomly} according to their absolute value as shown below
+ The above two examples used 3-layer sorting methods but as mentioned earlier, the sorting method can also be constructed with one and two algorithms i.e. 1-layer and 2-layer sorting methods. A sorting method with two layers could be constructed as \keyval*{sort-method}{sign,symbol} and the terms are ordered by sign and then symbolic length. In this case, there is not a third layer
\begin{equation*}
- \derivset{\pdv}[sort-method = {sign,symbol}]
- \pdv[3a-3hh-2b, 4c+4gg+2ff, -5d-5ee]{f}{x,y,z}
+ \pdv[sort-method = {sign,symbol}, order={3a-3hh-2b, 4c+4gg+2ff, -5d-5ee}]{f}{x,y,z}
\end{equation*}
\begin{equation*}
- \low{
- \low{ 4gg + 2ff }{long} +
- \low{ 3a + 4c }{short}
- }{positive} -
- \low{
- \low{ 3hh - 5ee }{long} -
- \low{ 2b - 5d }{short}
- }{negative}
+ \low{
+ \low{ 4gg + 2ff }{long} +
+ \low{ 3a + 4c }{short}
+ }{positive} -
+ \low{
+ \low{ 3hh - 5ee }{long} -
+ \low{ 2b - 5d }{short}
+ }{negative}
\end{equation*}
- It is seen that the first two terms came out in a descending manner according to their absolute value, while the next two terms came out in a ascending manner. Hence the choice of word: \enquote{appear randomly}. The last example shows a 1-layer sorting method given as \keyval{sort-method}{symbol} which gives the result
+ The last example shows a 1-layer sorting method given as \keyval{sort-method}{symbol} which gives the result
\begin{equation*}
- \derivset{\pdv}[sort-method = symbol]
- \pdv[3a-3hh-2b, 4c+4gg+2ff, -5d-5ee]{f}{x,y,z}
+ \pdv[sort-method = symbol, order={3a-3hh-2b, 4c+4gg+2ff, -5d-5ee}]{f}{x,y,z}
\end{equation*}
\begin{equation*}
- \low{ - 3hh + 4gg + 2ff - 5ee }{long} +
- \low{ 3a - 2b + 4c - 5d }{short}
+ \low{ - 3hh + 4gg + 2ff - 5ee }{long} +
+ \low{ 3a - 2b + 4c - 5d }{short}
\end{equation*}
- where it can be see that the terms are not ordered by sign nor absolute value. A fourth sorting algorithm might be implemented in the future, see \cref{consid:sort_number} for more information.
+ as expected.
\subsection{The numerical term} \label{ssec:sort-numerical}
- With the symbolic part of the mixed order treated, it is time to look at the numerical term\footref{foot:numerical-term}. For this reason it is treated differently than the symbolic terms. Currently it is only possible to control its position in the mixed order.
+ With the symbolic part of the mixed order treated, it is time to look at the numerical term\footref{foot:numerical-term} which have a symbolic of zero. For this reason it is treated differently than the symbolic terms.
- The numerical term may be placed either at the beginning or at the end of the mixed order with the values \val{first} and \val{last}, respectively. Thought it is also possible to have the package automatically determine where to place the term with the value \val{auto}. Compare below
+ The numerical term can be placed either at the beginning or at the end of the mixed order with the values \val{first} and \val{last}, respectively. The package can also determine where to place the numerical term with the value \val{auto}. Compare below
\begin{align*}
- \text{\keyval{sort-numerical}{auto}:} & \quad \pdv[\beta, 2]{f}{x,y} \qquad \pdv[\beta, -2]{f}{x,y} \qquad \pdv[-\beta, 2]{f}{x,y} \qquad \pdv[-\beta, -2]{f}{x,y} \\
- \text{\keyval{sort-numerical}{first}:} & \quad \derivset{\pdv}[sort-numerical = first]
- \pdv[\beta, 2]{f}{x,y} \qquad \pdv[\beta, -2]{f}{x,y} \qquad \pdv[-\beta, 2]{f}{x,y} \qquad \pdv[-\beta, -2]{f}{x,y} \\
- \text{\keyval{sort-numerical}{last}:} & \quad \derivset{\pdv}[sort-numerical = last]
- \pdv[\beta, 2]{f}{x,y} \qquad \pdv[\beta, -2]{f}{x,y} \qquad \pdv[-\beta, 2]{f}{x,y} \qquad \pdv[-\beta, -2]{f}{x,y}
+ \text{\inlinecode{sort-numerical=auto:}} &&
+ \pdv[order={\beta, 2}, sort-numerical=auto]{f}{x,y} &&
+ \pdv[order={\beta, -2}, sort-numerical=auto]{f}{x,y} &&
+ \pdv[order={-\beta, 2}, sort-numerical=auto]{f}{x,y} &&
+ \pdv[order={-\beta, -2}, sort-numerical=auto]{f}{x,y} \\
+ \text{\inlinecode{sort-numerical=first:}} &&
+ \pdv[order={\beta, 2}, sort-numerical=first]{f}{x,y} && \pdv[order={\beta, -2}, sort-numerical=first]{f}{x,y} && \pdv[order={-\beta, 2}, sort-numerical=first]{f}{x,y} && \pdv[order={-\beta, -2}, sort-numerical=first]{f}{x,y} \\
+ \text{\inlinecode{sort-numerical=last:}} &&
+ \pdv[order={\beta, 2}, sort-numerical=last]{f}{x,y} && \pdv[order={\beta, -2}, sort-numerical=last]{f}{x,y} && \pdv[order={-\beta, 2}, sort-numerical=last]{f}{x,y} && \pdv[order={-\beta, -2}, sort-numerical=last]{f}{x,y} \\
+ \text{\inlinecode{sort-numerical=symbolic:}} &&
+ \pdv[order={\beta, 2}, sort-numerical=symbolic]{f}{x,y} && \pdv[order={\beta, -2}, sort-numerical=symbolic]{f}{x,y} && \pdv[order={-\beta, 2}, sort-numerical=symbolic]{f}{x,y} && \pdv[order={-\beta, -2}, sort-numerical=symbolic]{f}{x,y}
\end{align*}
- These three options should satisfy every need, but there might come more options, see \cref{consid:sort_numerical}.
+ These three options should satisfy every needs.
\subsection{Reversing the sort algorithm} \label{ssec:sort-reverse}
- The three reverse keys serves to reverse the sorting order of the sorting algorithms. This allows for even greater flexibility over the sorting method by \enquote{doubling} the number of algorithms. So if the default ordering of an algorithm is not wished it may be reversed with the corresponding reverse key. For example, the \val{sign} algorithm places the positive terms first and the negative terms last, but using the option \keyval{sort-sign-reverse}{true} will place the negative terms first and positive terms last. The reverse keys in action are shown below
+ The reverse keys serves to reverse the ordering of the terms by the sorting algorithms. This allows for even greater flexibility over the sorting method. So if the default ordering of an algorithm is not wished it may be reversed with the corresponding reverse key. For example, the \val{sign} algorithm places the positive terms before the negative terms, but is opposite with \keyval{sort-sign-reverse}{true}. The reverse keys in action are shown below (\keyval[index=false]{sort-method}{\meta{1 algorithm only}} is also used to better show off the reverse functionality)
\begin{align*}
- \text{\keyval{sort-sign-reverse}{false}:} & \quad \derivset{\pdv}[sort-sign-reverse = false] \pdv[a, -b]{f}{x,y} &
- \text{\keyval{sort-sign-reverse}{true}:} & \quad \derivset{\pdv}[sort-sign-reverse = true] \pdv[a, -b]{f}{x,y} \\
- \text{\keyval{sort-symbol-reverse}{false}:} & \quad \derivset{\pdv}[sort-symbol-reverse = false] \pdv[ab, c]{f}{x,y} &
- \text{\keyval{sort-symbol-reverse}{true}:} & \quad \derivset{\pdv}[sort-symbol-reverse = true] \pdv[ab, c]{f}{x,y} \\
- \text{\keyval{sort-abs-reverse}{false}:} & \quad \derivset{\pdv}[sort-abs-reverse = false] \pdv[2a, b]{f}{x,y} &
- \text{\keyval{sort-abs-reverse}{true}:} & \quad \derivset{\pdv}[sort-abs-reverse = true] \pdv[2a, b]{f}{x,y}
+ \text{\inlinecode{sort-abs-reverse=false:}} && \pdv[sort-method={abs}, sort-abs-reverse=false, order={2a, -3b}]{f}{x,y} &&
+ \text{\inlinecode{sort-abs-reverse=true:}} && \pdv[sort-method={abs}, sort-abs-reverse=true, order={2a, -3b}]{f}{x,y} \\
+ \text{\inlinecode{sort-number-reverse=false:}} && \pdv[sort-method={number}, sort-number-reverse=false, order={2a, -3b}]{f}{x,y} &&
+ \text{\inlinecode{sort-number-reverse=true:}} && \pdv[sort-method={number}, sort-number-reverse=true, order={2a, -3b}]{f}{x,y} \\
+ \text{\inlinecode{sort-sign-reverse=false:}} && \pdv[sort-method={sign}, sort-sign-reverse=false, order={a, -b}]{f}{x,y} &&
+ \text{\inlinecode{sort-sign-reverse=true:}} && \pdv[sort-method={sign}, sort-sign-reverse=true, order={a, -b}]{f}{x,y} \\
+ \text{\inlinecode{sort-symbol-reverse=false:}} && \pdv[sort-method={symbol}, sort-symbol-reverse=false, order={ab, c}]{f}{x,y} &&
+ \text{\inlinecode{sort-symbol-reverse=true:}} && \pdv[sort-method={symbol}, sort-symbol-reverse=true, order={ab, c}]{f}{x,y}
\end{align*}
+ \subsection{Mixed order override}
+ In cases where the mixed order fails to be calculated or another form is preferred, then the mixed order override can be used
+ \begin{example}
+ \pdv[order={n+3k, n-k}]{f}{x,y} \\
+ \pdv[order={n+3k, n-k}, mixed-order={2(n+k)}]{f}{x,y}
+ \end{example}
-
-
-
-
-
\clearpage
\section{Miscellaneous}
@@ -2190,7 +2493,7 @@
\begin{syntax}
\oarg{scale}, \marg{numerator}, \marg{denominator}
\end{syntax}
- A text-styled fraction i.e. $\slashfrac{a}{b}$, is commonly used in text-mode. While \macro{\slashfrac}[\narg{a},\narg{b}] is certainly longer to write than \texttt{a/b}, which only requires three keystrokes, but for the implementation of text-styled derivatives, a macro is needed anyway.
+ A text-styled fraction i.e. $\slashfrac{a}{b}$, is commonly used in text-mode. While \macro{\slashfrac}[\narg{a},\narg{b}] is certainly longer to write than \texttt{a/b}, which only requires three keystrokes, but for the implementation of text-styled derivatives a macro for it is needed.
\begin{argument}{1}
The optional argument is the scaling parameter for the slash and takes the inputs as shown below. Leaving out \arg{1} sets the scaling parameter to \val{auto}
@@ -2202,96 +2505,61 @@
\slashfrac[bigg]{y_f}{x} \\
\slashfrac[Bigg]{y_f}{x}
\end{example}
- This argument is subject to change, see \cref{consid:slashfrac_opt,consid:slashfrac_def_scale} for more information.
+ This argument is subject to change, see \cref{consid:slashfrac_opt} for more information.
\end{argument}
\begin{argument}{2}
- This argument typeset the fraction's numerator.
+ Typesets the fraction's numerator.
\end{argument}
\begin{argument}{3}
- This argument typeset the fraction's denominator.
+ Typesets the fraction's denominator.
\end{argument}
\end{function}
-
-
-
-
\clearpage
\section{To do}\label{sec:todo}
- Entries marked with \cmark{} will be implemented in a future release. Entries marked with \xmark{} will not be implemented.
+ Entries marked with \cmark{} will be implemented in a future release specified in the entry. Entries marked with \xmark{} will not be implemented.
\subsection{Future implementation}
The list describes what \emph{will be added} to the package in a later release.
\begin{todo}
- \item Define commands that can create variants of infinitesimal like $\symup{d}$, $\partial$, $\delta$ etc. for use in integrals $\int f(x) \mathop{}\!\symup{d}x$, in differential equations $\pdv{f}{x} \mathop{}\! \symup{d}x + \pdv{f}{y}\mathop{}\! \symup{d}y$ and a shorthand notation of the partial derivative $\partial_{xx}f(x,y)$.
- \item Implement the option to turn off the sorting of the terms in the mixed order. This could be made as a \val{draft} / \val{final} option.
+ \item Implement the option to turn off the sorting of the terms in the mixed order. This could be made as a \val{draft} / \val{final} option. \\
+ \answer{\cmark\xmark}{There could be an draft/final option for the package. But what is should turn off/on is harder to say.}
\end{todo}
\subsection{Future changes}
The list describes what \emph{will be changed} in the package in a later release.
\begin{changes}
- \item A complete rewrite of the options \key[index=false]{misc-add-delims} and \key[index=false]{misc-remove-delims} is necessary so that they have a clearer syntax. Moreover, the value \val{var} needs to work differently (and correctly) for the partial derivatives and variants hereof (pretty much useless here). \label{revis:add_remove}
+ \item
\end{changes}
\subsection{Future considerations}
The list describes what \emph{might be changed or added} to the package in a later release.
\begin{consideration}
- \item As mentioned earlier in the documentation, I heavily consider to change the optional argument \oarg{order} to a \oarg{key=value} argument. Of course this will lead to some changes: \label{consid:order2keyval}
- \begin{itemize}
- \item I would need a way to set the order of differentiation. I am thinking of something like a key value option; \keyval[index=false]{order}{\marg{cs-orders}}.
- %
- \item Such an option should not be possible to be set with \macro[index=false]{\derivset} or in the definition of a new derivative (or maybe if one really needs a lot of higher order derivative).
- \end{itemize}
- \answer{\cmark}{I truly believe this is the right way forward and is coming in version 1.0. More features can easily be added in a key-value style. The order argument will be replaced with a key-value argument and a order key introduced; \texttt{ord=\meta{order}}.}
- %
- \item With the above consideration, than it would only be natural to remove the mixed order and then have an option \keyval[index=false]{mixed-order}{\marg{mixed-order}}. Likewise, it should not be possible to be set with \macro[index=false]{\derivset} or in the definition of a new derivative. \label{consid:RemoveMixedOrder} \\
- \answer{\cmark}{The mixed order argument will be removed due to the introduction of a key-value argument as mentioned above in version 1.0. The mixed order can be set with the knew key \texttt{m-ord=\meta{mixed-order}}.}
- %
- \item Currently \macro[index=false]{\derivset}'s optional argument \oarg{key=val}, when not given, sets the derivatives options to the package default settings. This should probably be changed to the options set in the definition of the derivative. \label{consid:DerivsetOptional} \\
- \answer{\cmark}{I believe this would a nice change for the future, but I do not have the time to make the implementation for the next release.}
- %
\item It can become rather cumbersome to read a derivative with a very long function. To ease this up, I am considering to add a switch that exchange the variable and the function arguments. But this might be against the \latex{} way of using arguments, which is the reason it have not been done and I would like feedback on it. \label{consid:Fun_Var_switch}
%
- \item Should I add a key, possible a switch, that turn on/off the local behaviour \key[index=false]{misc-add-delims} and \key[index=false]{misc-remove-delims} inside derivative? \label{consid:add_remove_local}
- %
- \item It was mentioned in \cref{sec:createvariants}, that the second argument of \cs{\ldots Variant} should be a single token, e.g. meaning that \macro[index=false]{\NewOdvVariant}[\narg{\cs{myvariant}},\narg{\cs{partial}\_\cs{mu}}] is not allowed but \macro[index=false]{\NewOdvVariant}[\narg{\cs{myvariant}},\narg{\{\cs{partial}\_\cs{mu}\}}] is. It can easily be change to accept a multi token input. \\
- \answer{\cmark}{This have already been changed in version 0.95, since it is an unnecessary constraint.}
- %
- \item Should I add the option to \key[index=false]{sort-numerical}, so that it is treated as a symbolic term instead of a numerical term? \label{consid:sort_numerical}
- \\ \answer{\cmark}{Yes. Yes I should. This feature will be added in version 1.0.}
- %
- \item Should I add a sorting algorithm that order the terms according to their number (including sign)? \label{consid:sort_number}
- \\ \answer{\cmark}{Yes. Yes I should. This feature will be added in version 1.0.}
- %
\item I am considering making the optional argument of \macro[index=false]{\slashfrac} into a \oarg{key=value} argument with something like \keyval[index=false]{scale}{\marg{scaling}}. \label{consid:slashfrac_opt} \\
- \answer{\cmark}{I want an key-value implementation like this in the future, but it will not be added it version 1.0.}
- %
- \item Should the default scaling for \macro[index=false]{\slashfrac} be \val{auto} or \val{none}? Or should it be possible to set it with something like \cs{slashfracset}\oarg{key=value}? \label{consid:slashfrac_def_scale} \\
- \answer{\xmark}{The package default should be \val{auto}, but it will be possible to change it, when the key-value is implemented or \macro[index=false]{\slashfrac}.}
+ \answer{\cmark}{I want an key-value implementation like this in the future, but it will not be added in the next release.}
\end{consideration}
-
-
-
\clearpage
\addsec{Index}
Numbers in bold refer to the page where the entry is defined.
\printindex[option]
- \printindex[macro]
+ \clearpage
+ \printindex[macro]
-
\clearpage
\addsec{Change history}
@@ -2324,5 +2592,24 @@
\begin{change}[version = 0.98, date = 2020-07-20, beta = true]
\item Fixed a bug concerning the subscript argument due to recent changes to the \pkg{xparse} package dated 2020-05-14 (the fix works with earlier versions of xparse as well).
\end{change}
+ \begin{change}[version = 1.0, date = 2021-05-25, beta = false]
+ \item Added new options for derivatives
+ \item Added new values for existing options
+ \item Added new commands to write differentials
+ \item Changed usage of \key[index=false]{style-inf}
+ \item Changed the order argument to an option argument
+ \item Changed default values for some options
+ \item Changed math space keys to accept more general inputs
+ \item Changed \cs{derivset} to define default options
+ \item Merged the codes for ordinary and partial derivatives
+ \item Removed the mixed order argument
+ \item Removed the options `misc-add-delims` and `misc-remove-delims`
+ \item Replaced the commands in section 5 with new ones. Old ones no longer works.
+ \item Code clean-up and optimization
+ \item Fixed code errors
+ \item Fixed Documentation errors
+ \item Enhanced support for preventing options effecting nested derivatives/differentials
+ \end{change}
\end{changelog}
+
\end{document}
\ No newline at end of file
Modified: trunk/Master/texmf-dist/tex/latex/derivative/derivative.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/derivative/derivative.sty 2021-05-25 20:47:20 UTC (rev 59343)
+++ trunk/Master/texmf-dist/tex/latex/derivative/derivative.sty 2021-05-25 20:47:33 UTC (rev 59344)
@@ -1,5 +1,5 @@
% derivative.sty
-% Copyright 2019-2020 Simon Jensen
+% Copyright 2019-2021 Simon Jensen
%
% This work may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either version 1.3
@@ -16,7 +16,7 @@
\NeedsTeXFormat{LaTeX2e}
\RequirePackage{xparse}[2018/05/09]
-\ProvidesExplPackage{derivative}{2020/07/20}{0.98}{Nice and easy derivatives}
+\ProvidesExplPackage{derivative}{2021/05/25}{1.0}{Nice and easy derivatives and differentials for LaTeX}
%%%%% Useful conditionals %%%%%
@@ -44,77 +44,73 @@
\prg_new_conditional:Npnn \__deriv_show_order:N #1 { T, TF }
{
- \quark_if_no_value:NTF #1
+ \str_if_eq:NNTF #1 1
{ \prg_return_false: }
- {
- \str_if_eq:NNTF #1 1
- { \prg_return_false: }
- {
- \exp_args:NV \tl_if_novalue:nTF #1
- { \prg_return_false: }
- {
- \tl_if_blank:VTF #1
- { \prg_return_false: }
- { \prg_return_true: }
- }
- }
- }
+ { \prg_return_true: }
}
\cs_new:Npn \__deriv_case:n #1
-{ \exp:w \__deriv_case_begin:nTF {#1} { } { } }
+{ \exp:w \__deriv_case_begin:nTF {#1} { } { } }
\cs_new:Npn \__deriv_case:nT #1#2
-{ \exp:w \__deriv_case_begin:nTF {#1} {#2} { } }
+{ \exp:w \__deriv_case_begin:nTF {#1} {#2} { } }
\cs_new:Npn \__deriv_case:nF #1#2
-{ \exp:w \__deriv_case_begin:nTF {#1} { } {#2} }
+{ \exp:w \__deriv_case_begin:nTF {#1} { } {#2} }
\cs_new:Npn \__deriv_case:nTF #1
-{ \exp:w \__deriv_case_begin:nTF {#1} }
+{ \exp:w \__deriv_case_begin:nTF {#1} }
\cs_new:Npn \__deriv_case_begin:nTF #1#2#3
-{ \__deriv_case:w #1 \c_true_bool { } \q_mark {#2} \q_mark {#3} \q_stop }
+{ \__deriv_case:w #1 \c_true_bool { } \q_mark {#2} \q_mark {#3} \q_stop }
\cs_new:Npn \__deriv_case:w #1#2
{
\bool_if:nTF {#1}
- { \__deriv_case_end:nw {#2} }
- { \__deriv_case:w }
+ { \__deriv_case_end:nw {#2} }
+ { \__deriv_case:w }
}
\cs_new:Npn \__deriv_case_end:nw #1#2#3 \q_mark #4#5 \q_stop
-{ \exp_end: #1 #4 }
+{ \exp_end: #1 #4 }
-%%%%% Variables for settings of odv, pdv and variants %%%%%
+%%%%% Variables: derivatives %%%%%
-\cs_new_protected:Npn \__deriv_auto_left:n #1 { \left #1 }
-\cs_new_protected:Npn \__deriv_auto_right:n #1 { \right #1 }
-
-\tl_new:N \l__deriv_dv_tmp_tl
+\tl_new:N \l__deriv_cs_name_tl
\tl_new:N \l__deriv_derivset_tl
-\seq_new:N \l__deriv_var_seq
+\seq_new:N \l__deriv_new_var_seq
\seq_new:N \l__deriv_rubber_seq
-%%%%% Variables for odv %%%%%
+\prop_new:N \l__deriv_tmp_keys_prop
+\seq_new:N \l__deriv_tmp_keys_seq
+\tl_new:N \l__deriv_tmp_keys_tl
-\seq_new:N \l__deriv_d_variant_seq
+%%%%% Variables: infinisimal %%%%%
-\tl_new:N \l__deriv_d_order_tl
+\seq_new:N \l__deriv_i_var_seq
+\seq_new:N \l__deriv_i_orders_seq
+\tl_new:N \l__deriv_i_tmpa_tl
+\tl_new:N \l__deriv_i_denom_tl
-%%%%% Variables for pdv and mixed order (mo) %%%%%
+\seq_new:N \l__deriv_i_variant_seq
-\seq_new:N \l__deriv_p_variant_seq
+%%%%% Variables: other %%%%%
-\tl_new:N \l__deriv_p_tmpa_tl
-\tl_new:N \l__deriv_p_mo_tl
-\tl_new:N \l__deriv_p_denom_tl
+\seq_new:N \l__deriv_dv_variant_seq
+\seq_new:N \l__deriv_add_var_bool_seq
-\seq_new:N \l__deriv_p_var_seq
-\seq_new:N \l__deriv_p_order_seq
-\seq_new:N \l__deriv_p_mo_seq
+\tl_new:N \l__deriv_tmpa_tl
+\tl_new:N \l__deriv_tmpb_tl
+\tl_new:N \l__deriv_tmpc_tl
+\seq_new:N \l__deriv_tmpa_seq
+\tl_new:N \l__deriv_dv_denom_tl
+
+\seq_new:N \l__deriv_dv_var_seq
+\seq_new:N \l__deriv_dv_order_seq
+\seq_new:N \l__deriv_dv_mo_seq
+
\int_new:N \l__deriv_vmo_int
\tl_new:N \l__deriv_sym_tmpa_tl
@@ -133,6 +129,7 @@
\seq_new:N \l__deriv_rebuild_seq
\int_new:N \l__deriv_tmpa_int
+\int_new:N \l__deriv_tmpb_int
\int_new:N \l__deriv_numerical_int
\int_new:N \l__deriv_sort_counter_int
@@ -141,11 +138,91 @@
\int_new:N \l__deriv_position_int
\int_new:N \l__deriv_rebuild_int
+\bool_new:N \l__deriv_tmpa_bool
+
\regex_const:Nn \c__deriv_pattern_regex { \A([\+\-]?\d*)(.*) }
+\regex_const:Nn \c__deriv_cs_numbers_regex { \A\-?\d+(?:,\d+){0,2}\Z }
+%%%%% default values %%%%%
+
+\prop_const_from_keyval:Nn \c__deriv_dv_pkg_keys_prop
+{
+ style-frac = \frac,
+ style-frac-/ = \slashfrac,
+ style-var = single,
+ scale-eval = auto,
+ scale-eval-/ = auto,
+ scale-fun = auto,
+ scale-var = auto,
+ scale-frac = auto,
+ scale-frac-/ = auto,
+ delims-eval = .\rvert,
+ delims-eval-/ = .\rvert,
+ delims-fun = (),
+ delims-var = (),
+ delims-frac = (),
+ delims-frac-/ = (),
+ sep-inf-ord = 0,
+ sep-inf-fun = 0,
+ sep-ord-fun = 0,
+ sep-frac-fun = 0,
+ sep-inf-var = 0,
+ sep-var-ord = 0,
+ sep-var-inf = \mathop{}\!,
+ sep-ord-inf = \mathop{}\!,
+ sep-var-var = {,},
+ sep-eval-sb = 0,
+ sep-eval-sp = 0,
+ switch-* = false,
+ switch-/ = false,
+ sort-method = {sign, symbol, abs},
+ sort-numerical = auto,
+ sort-abs-reverse = false,
+ sort-number-reverse = false,
+ sort-sign-reverse = false,
+ sort-symbol-reverse = false,
+ fun = false,
+ frac = false,
+ var = none,
+ order = 1,
+ mixed-order = 1
+}
+
+\bool_lazy_or:nnTF { \sys_if_engine_luatex_p: } { \sys_if_engine_xetex_p: }
+{ \prop_gput:Nnn \c__deriv_dv_pkg_keys_prop { style-inf } { \symnormal } }
+{ \prop_gput:Nnn \c__deriv_dv_pkg_keys_prop { style-inf } { \mathnormal } }
+
+\prop_const_from_keyval:Nn \c__deriv_i_pkg_keys_prop
+{
+ style-notation = multiple,
+ style-notation-* = single,
+ scale-var = auto,
+ scale-var-* = auto,
+ delims-var = (),
+ delims-var-* = (),
+ sep-begin = \mathop{}\!,
+ sep-inf-ord = 0,
+ sep-inf-var = 0,
+ sep-ord-var = 0,
+ sep-var-inf = \mathop{}\!,
+ sep-var-var = {,},
+ sep-ord-ord = {,},
+ sep-end = \mathop{}\!,
+ switch-* = false,
+ var = none,
+ order = 1
+}
+
+\bool_lazy_or:nnTF { \sys_if_engine_luatex_p: } { \sys_if_engine_xetex_p: }
+{ \prop_gput:Nnn \c__deriv_i_pkg_keys_prop { style-inf } { \symnormal } }
+{ \prop_gput:Nnn \c__deriv_i_pkg_keys_prop { style-inf } { \mathnormal } }
+
%%%%%% Key-val for all %%%%%%
-\keys_define:nn { deriv-all-settings }
+\prop_const_from_keyval:Nn \c__deriv_all_pkg_keys_prop
+{ scale-auto = leftright }
+
+\keys_define:nn { deriv/all/all }
{
scale-auto .choice:,
scale-auto / leftright .code:n =
@@ -155,210 +232,106 @@
},
scale-auto / mleftmright .code:n =
{
- \cs_set_eq:NN \__deriv_auto_left:n \mleft
- \cs_set_eq:NN \__deriv_auto_right:n \mright
+ \cs_set_nopar:Npn \__deriv_auto_left:n { \mleft }
+ \cs_set_nopar:Npn \__deriv_auto_right:n { \mright }
},
scale-auto .default:n = { leftright }
}
-%%%%% Key-val for odv and variants %%%%%
-\cs_new:Npn \__deriv_d_define_keys:n #1
+%%%%%% Key-val: derivatives %%%%%%
+
+\cs_new:Npn \__deriv_dv_define_keys:n #1
{
- \keys_define:nn { deriv/d/#1 }
+ \keys_define:nn { deriv/dv/#1 }
{
- style-inf .code:n = { \cs_set_eq:cN { __deriv_#1_style_inf:n } ##1 },
+ style-inf .tl_set:c = { l__deriv_dv_#1_style_inf_tl },
+ style-var .tl_set:c = { l__deriv_dv_#1_style_var_tl },
+ style-frac .cs_set:cp = { __deriv_dv_#1_style_frac:nn } {##1},
+ style-frac-/ .cs_set:cp = { __deriv_dv_#1_style_frac_slash:nn } {##1},
- style-frac .code:n = { \cs_set_eq:cN { __deriv_#1_style_frac:n } ##1 },
- style-frac .default:n = { \frac },
+ scale-eval .choices:nn = { auto, none, big, Big, bigg, Bigg } { \tl_set:cn { l__deriv_dv_#1_scale_eval_tl } {##1} },
+ scale-eval-/ .choices:nn = { auto, none, big, Big, bigg, Bigg } { \tl_set:cn { l__deriv_dv_#1_scale_eval_slash_tl } {##1} },
+ scale-fun .choices:nn = { auto, none, big, Big, bigg, Bigg } { \tl_set:cn { l__deriv_dv_#1_scale_fun_tl } {##1} },
+ scale-var .choices:nn = { auto, none, big, Big, bigg, Bigg } { \tl_set:cn { l__deriv_dv_#1_scale_var_tl } {##1} },
+ scale-frac .choices:nn = { auto, none, big, Big, bigg, Bigg } { \tl_set:cn { l__deriv_dv_#1_scale_frac_tl } {##1} },
+ scale-frac-/ .choices:nn = { auto, none, big, Big, bigg, Bigg } { \tl_set:cn { l__deriv_dv_#1_scale_frac_slash_tl } {##1} },
- style-frac-/ .code:n = { \cs_set_eq:cN { __deriv_#1_style_frac_slash:n } ##1 },
- style-frac-/ .default:n = { \slashfrac },
+ delims-eval .tl_set:c = { l__deriv_dv_#1_delims_eval_tl },
+ delims-eval-/ .tl_set:c = { l__deriv_dv_#1_delims_eval_slash_tl },
+ delims-fun .tl_set:c = { l__deriv_dv_#1_delims_fun_tl },
+ delims-var .tl_set:c = { l__deriv_dv_#1_delims_var_tl },
+ delims-frac .tl_set:c = { l__deriv_dv_#1_delims_frac_tl },
+ delims-frac-/ .tl_set:c = { l__deriv_dv_#1_delims_frac_slash_tl },
- scale-eval .choices:nn =
- { auto, none, big, Big, bigg, Bigg }
- { \tl_set_eq:cN { l__deriv_#1_scale_eval_tl } \l_keys_choice_tl },
- scale-eval .default:n = { auto },
+ sep-inf-ord .code:n = { \__deriv_set_rubber_length:cn { l__deriv_dv_#1_sep_inf_ord_tl } {##1} },
+ sep-inf-fun .code:n = { \__deriv_set_rubber_length:cn { l__deriv_dv_#1_sep_inf_fun_tl } {##1} },
+ sep-ord-fun .code:n = { \__deriv_set_rubber_length:cn { l__deriv_dv_#1_sep_ord_fun_tl } {##1} },
+ sep-frac-fun .code:n = { \__deriv_set_rubber_length:cn { l__deriv_dv_#1_sep_frac_fun_tl } {##1} },
+ sep-inf-var .code:n = { \__deriv_set_rubber_length:cn { l__deriv_dv_#1_sep_inf_var_tl } {##1} },
+ sep-var-ord .code:n = { \__deriv_set_rubber_length:cn { l__deriv_dv_#1_sep_var_ord_tl } {##1} },
+ sep-var-inf .code:n = { \__deriv_set_rubber_length:cn { l__deriv_dv_#1_sep_var_inf_tl } {##1} },
+ sep-ord-inf .code:n = { \__deriv_set_rubber_length:cn { l__deriv_dv_#1_sep_ord_inf_tl } {##1} },
+ sep-var-var .code:n = { \__deriv_set_rubber_length:cn { l__deriv_dv_#1_sep_var_var_tl } {##1} },
+ sep-eval-sb .code:n = { \__deriv_set_rubber_length:cn { l__deriv_dv_#1_sep_eval_sb_tl } {##1} },
+ sep-eval-sp .code:n = { \__deriv_set_rubber_length:cn { l__deriv_dv_#1_sep_eval_sp_tl } {##1} },
- scale-eval-/ .choices:nn =
- { auto, none, big, Big, bigg, Bigg }
- { \tl_set_eq:cN { l__deriv_#1_scale_eval_slash_tl } \l_keys_choice_tl },
- scale-eval-/ .default:n = { auto },
+ switch-* .bool_set:c = { l__deriv_dv_#1_switch_star_bool },
+ switch-/ .bool_set:c = { l__deriv_dv_#1_switch_slash_bool },
- scale-fun .choices:nn =
- { auto, none, big, Big, bigg, Bigg }
- { \tl_set_eq:cN { l__deriv_#1_scale_fun_tl } \l_keys_choice_tl },
- scale-fun .default:n = { auto },
+ fun .bool_set:c = { l__deriv_dv_#1_misc_fun_bool },
+ frac .bool_set:c = { l__deriv_dv_#1_misc_frac_bool },
+ var .clist_set:c = { l__deriv_dv_#1_misc_var_clist },
+ %fun .default:n = {true},
+ %frac .default:n = {true},
+ var .default:n = {all},
- scale-var .choices:nn =
- { auto, none, big, Big, bigg, Bigg }
- { \tl_set_eq:cN { l__deriv_#1_scale_var_tl } \l_keys_choice_tl },
- scale-var .default:n = { auto },
+ order .clist_set:c = { l__deriv_dv_#1_misc_order_clist },
+ ord .clist_set:c = { l__deriv_dv_#1_misc_order_clist },
+ mixed-order .tl_set:c = { l__deriv_dv_#1_misc_mixed_order_tl },
+ mixord .tl_set:c = { l__deriv_dv_#1_misc_mixed_order_tl },
- scale-frac .choices:nn =
- { auto, none, big, Big, bigg, Bigg }
- { \tl_set_eq:cN { l__deriv_#1_scale_frac_tl } \l_keys_choice_tl },
- scale-frac .default:n = { auto },
-
- scale-frac-/ .choices:nn =
- { auto, none, big, Big, bigg, Bigg }
- { \tl_set_eq:cN { l__deriv_#1_scale_frac_slash_tl } \l_keys_choice_tl },
- scale-frac-/ .default:n = { auto },
-
- delims-eval .code:n = { \tl_set:cn { l__deriv_#1_delims_eval_tl } { ##1 } },
- delims-eval .default:n = { .\rvert },
- delims-eval-/ .code:n = { \tl_set:cn { l__deriv_#1_delims_eval_slash_tl } { ##1 } },
- delims-eval-/ .default:n = { .\rvert },
- delims-fun .code:n = { \tl_set:cn { l__deriv_#1_delims_fun_tl } { ##1 } },
- delims-fun .default:n = { () },
- delims-var .code:n = { \tl_set:cn { l__deriv_#1_delims_var_tl } { ##1 } },
- delims-var .default:n = { () },
- delims-frac .code:n = { \tl_set:cn { l__deriv_#1_delims_frac_tl } { ##1 } },
- delims-frac .default:n = { () },
- delims-frac-/ .code:n = { \tl_set:cn { l__deriv_#1_delims_frac_slash_tl } { ##1 } },
- delims-frac-/ .default:n = { () },
-
- sep-inf-ord .code:n = { \__deriv_set_rubber_length:cn { l__deriv_#1_sep_inf_ord_muskip } {##1} },
- sep-inf-ord .default:n = { 0 },
- sep-inf-fun .code:n = { \__deriv_set_rubber_length:cn { l__deriv_#1_sep_inf_fun_muskip } {##1} },
- sep-inf-fun .default:n = { 0 },
- sep-ord-fun .code:n = { \__deriv_set_rubber_length:cn { l__deriv_#1_sep_ord_fun_muskip } {##1} },
- sep-ord-fun .default:n = { 0 },
- sep-var-ord .code:n = { \__deriv_set_rubber_length:cn { l__deriv_#1_sep_var_ord_muskip } {##1} },
- sep-var-ord .default:n = { 0 },
- sep-inf-var .code:n = { \__deriv_set_rubber_length:cn { l__deriv_#1_sep_inf_var_muskip } {##1} },
- sep-inf-var .default:n = { 0 },
- sep-eval-sb .code:n = { \__deriv_set_rubber_length:cn { l__deriv_#1_sep_eval_sb_muskip } {##1} },
- sep-eval-sb .default:n = { 0 },
- sep-eval-sp .code:n = { \__deriv_set_rubber_length:cn { l__deriv_#1_sep_eval_sp_muskip } {##1} },
- sep-eval-sp .default:n = { 0 },
-
- switch-* .bool_set:c = { l__deriv_#1_switch_star_bool },
- switch-* .default:n = { false },
- switch-/ .bool_set:c = { l__deriv_#1_switch_slash_bool },
- switch-/ .default:n = { false },
-
- misc-add-delims .multichoices:nn =
- { fun, var, frac }
- { \bool_set_true:c { l__deriv_#1_mics_##1_bool } },
-
- misc-remove-delims .multichoices:nn =
- { fun, var, frac }
- { \bool_set_false:c { l__deriv_#1_mics_##1_bool } },
- misc-remove-delims .default:n = { fun, var, frac }
+ sort-method .clist_set:c = { l__deriv_dv_#1_sort_method_clist },
+ sort-numerical .choices:nn = { auto, first, last, symbolic } { \tl_set:cn { l__deriv_dv_#1_sort_numerical_tl } {##1} },
+ sort-abs-reverse .bool_set:c = { l__deriv_dv_#1_sort_abs_reverse_bool },
+ sort-number-reverse .bool_set:c = { l__deriv_dv_#1_sort_number_reverse_bool },
+ sort-sign-reverse .bool_set:c = { l__deriv_dv_#1_sort_sign_reverse_bool },
+ sort-symbol-reverse .bool_set:c = { l__deriv_dv_#1_sort_symbol_reverse_bool }
}
- \bool_lazy_or:nnT { \sys_if_engine_luatex_p: } { \sys_if_engine_xetex_p: }
- { \keys_define:nn { deriv/d/#1 } { style-inf .default:n = { \symnormal } } }
- \sys_if_engine_pdftex:T
- { \keys_define:nn { deriv/d/#1 } { style-inf .default:n = { \mathnormal } } }
}
-%%%%%% Key-val for pdv and variants %%%%%%
-\cs_new:Npn \__deriv_p_define_keys:n #1
+
+%%%%%% Key-val: derivatives %%%%%%
+
+\cs_new:Npn \__deriv_i_define_keys:n #1
{
- \keys_define:nn { deriv/p/#1 }
+ \keys_define:nn { deriv/i/#1 }
{
- style-inf .code:n = { \cs_set_eq:cN { __deriv_#1_style_inf:n } ##1 },
+ style-inf .tl_set:c = { l__deriv_i_#1_style_inf_tl },
+ style-notation .tl_set:c = { l__deriv_i_#1_style_notation_tl },
+ style-notation-* .tl_set:c = { l__deriv_i_#1_style_notation_star_tl },
- style-frac .code:n = { \cs_set_eq:cN { __deriv_#1_style_frac:n } ##1 },
- style-frac .default:n = { \frac },
+ scale-var .choices:nn = { auto, none, big, Big, bigg, Bigg } { \tl_set:cn { l__deriv_i_#1_scale_var_tl } {##1} },
+ scale-var-* .choices:nn = { auto, none, big, Big, bigg, Bigg } { \tl_set:cn { l__deriv_i_#1_scale_var_star_tl } {##1} },
- style-frac-/ .code:n = { \cs_set_eq:cN { __deriv_#1_style_frac_slash:n } ##1 },
- style-frac-/ .default:n = { \slashfrac },
+ delims-var .tl_set:c = { l__deriv_i_#1_delims_var_tl },
+ delims-var-* .tl_set:c = { l__deriv_i_#1_delims_var_star_tl },
- scale-eval .choices:nn =
- { auto, none, big, Big, bigg, Bigg }
- { \tl_set_eq:cN { l__deriv_#1_scale_eval_tl } \l_keys_choice_tl },
- scale-eval .default:n = { auto },
+ sep-begin .code:n = { \__deriv_set_rubber_length:cn { l__deriv_i_#1_sep_begin_tl } {##1} },
+ sep-inf-ord .code:n = { \__deriv_set_rubber_length:cn { l__deriv_i_#1_sep_inf_ord_tl } {##1} },
+ sep-inf-var .code:n = { \__deriv_set_rubber_length:cn { l__deriv_i_#1_sep_inf_var_tl } {##1} },
+ sep-ord-var .code:n = { \__deriv_set_rubber_length:cn { l__deriv_i_#1_sep_ord_var_tl } {##1} },
+ sep-var-inf .code:n = { \__deriv_set_rubber_length:cn { l__deriv_i_#1_sep_var_inf_tl } {##1} },
+ sep-var-var .code:n = { \__deriv_set_rubber_length:cn { l__deriv_i_#1_sep_var_var_tl } {##1} },
+ sep-ord-ord .code:n = { \__deriv_set_rubber_length:cn { l__deriv_i_#1_sep_ord_ord_tl } {##1} },
+ sep-end .code:n = { \__deriv_set_rubber_length:cn { l__deriv_i_#1_sep_end_tl } {##1} },
- scale-eval-/ .choices:nn =
- { auto, none, big, Big, bigg, Bigg }
- { \tl_set_eq:cN { l__deriv_#1_scale_eval_slash_tl } \l_keys_choice_tl },
- scale-eval-/ .default:n = { auto },
+ switch-* .bool_set:c = { l__deriv_i_#1_switch_star_bool },
- scale-fun .choices:nn =
- { auto, none, big, Big, bigg, Bigg }
- { \tl_set_eq:cN { l__deriv_#1_scale_fun_tl } \l_keys_choice_tl },
- scale-fun .default:n = { auto },
+ var .clist_set:c = { l__deriv_i_#1_misc_var_clist },
+ var .default:n = {all},
- scale-var .choices:nn =
- { auto, none, big, Big, bigg, Bigg }
- { \tl_set_eq:cN { l__deriv_#1_scale_var_tl } \l_keys_choice_tl },
- scale-var .default:n = { auto },
-
- scale-frac .choices:nn =
- { auto, none, big, Big, bigg, Bigg }
- { \tl_set_eq:cN { l__deriv_#1_scale_frac_tl } \l_keys_choice_tl },
- scale-frac .default:n = { auto },
-
- scale-frac-/ .choices:nn =
- { auto, none, big, Big, bigg, Bigg }
- { \tl_set_eq:cN { l__deriv_#1_scale_frac_slash_tl } \l_keys_choice_tl },
- scale-frac-/ .default:n = { auto },
-
- delims-eval .code:n = { \tl_set:cn { l__deriv_#1_delims_eval_tl } {##1} },
- delims-eval .default:n = { () },
- delims-eval-/ .code:n = { \tl_set:cn { l__deriv_#1_delims_eval_slash_tl } {##1} },
- delims-eval-/ .default:n = { () },
- delims-fun .code:n = { \tl_set:cn { l__deriv_#1_delims_fun_tl } {##1} },
- delims-fun .default:n = { () },
- delims-var .code:n = { \tl_set:cn { l__deriv_#1_delims_var_tl } {##1} },
- delims-var .default:n = { () },
- delims-frac .code:n = { \tl_set:cn { l__deriv_#1_delims_frac_tl } {##1} },
- delims-frac .default:n = { () },
- delims-frac-/ .code:n = { \tl_set:cn { l__deriv_#1_delims_frac_slash_tl } {##1} },
- delims-frac-/ .default:n = { () },
-
- sep-inf-ord .code:n = { \__deriv_set_rubber_length:cn { l__deriv_#1_sep_inf_ord_muskip } {##1} },
- sep-inf-ord .default:n = { 0 },
- sep-inf-fun .code:n = { \__deriv_set_rubber_length:cn { l__deriv_#1_sep_inf_fun_muskip } {##1} },
- sep-inf-fun .default:n = { 0 },
- sep-ord-fun .code:n = { \__deriv_set_rubber_length:cn { l__deriv_#1_sep_ord_fun_muskip } {##1} },
- sep-ord-fun .default:n = { 0 },
- sep-inf-var .code:n = { \__deriv_set_rubber_length:cn { l__deriv_#1_sep_inf_ord_muskip } {##1} },
- sep-inf-var .default:n = { 0 },
- sep-var-ord .code:n = { \__deriv_set_rubber_length:cn { l__deriv_#1_sep_var_ord_muskip } {##1} },
- sep-var-ord .default:n = { 0 },
- sep-var-inf .code:n = { \__deriv_set_rubber_length:cn { l__deriv_#1_sep_var_inf_muskip } {##1} },
- sep-var-inf .default:n = { 3 },
- sep-ord-inf .code:n = { \__deriv_set_rubber_length:cn { l__deriv_#1_sep_ord_inf_muskip } {##1} },
- sep-ord-inf .default:n = { 3 },
- sep-eval-sb .code:n = { \__deriv_set_rubber_length:cn { l__deriv_#1_sep_eval_sb_muskip } {##1} },
- sep-eval-sb .default:n = { -4 },
- sep-eval-sp .code:n = { \__deriv_set_rubber_length:cn { l__deriv_#1_sep_eval_sp_muskip } {##1} },
- sep-eval-sp .default:n = { -4 },
-
- switch-* .bool_set:c = { l__deriv_#1_switch_star_bool },
- switch-* .default:n = { false },
- switch-/ .bool_set:c = { l__deriv_#1_switch_slash_bool },
- switch-/ .default:n = { false },
-
- misc-add-delims .multichoices:nn =
- { fun, var, frac }
- { \bool_set_true:c { l__deriv_#1_mics_##1_bool } },
-
- misc-remove-delims .multichoices:nn =
- { fun, var, frac }
- { \bool_set_false:c { l__deriv_#1_mics_##1_bool } },
- misc-remove-delims .default:n = { fun, var, frac },
-
- sort-method .clist_set:c = { l__deriv_#1_sort_method_clist }, % måske seq
- sort-method .default:n = { abs, sign, symbol },
-
- sort-numerical .choices:nn =
- { auto, first, last }
- { \tl_set_eq:cN { l__deriv_#1_sort_numerical_tl } \l_keys_choice_tl },
- sort-numerical .default:n = { auto },
-
- sort-sign-reverse .bool_set:c = { l__deriv_#1_sort_sign_reverse_bool },
- sort-sign-reverse .default:n = { false },
- sort-symbol-reverse .bool_set:c = { l__deriv_#1_sort_symbol_reverse_bool },
- sort-symbol-reverse .default:n = { false },
- sort-abs-reverse .bool_set:c = { l__deriv_#1_sort_abs_reverse_bool },
- sort-abs-reverse .default:n = { false }
+ order .clist_set:c = { l__deriv_i_#1_misc_order_clist },
+ ord .clist_set:c = { l__deriv_i_#1_misc_order_clist },
}
- \bool_lazy_or:nnT { \sys_if_engine_luatex_p: } { \sys_if_engine_xetex_p: }
- { \keys_define:nn { deriv/p/#1 } { style-inf .default:n = { \symnormal } } }
- \sys_if_engine_pdftex:T
- { \keys_define:nn { deriv/p/#1 } { style-inf .default:n = { \mathnormal } } }
}
%%%%% Setting keys %%%%%
@@ -365,535 +338,639 @@
\DeclareDocumentCommand{\derivset}{ m o }
{
- \token_if_macro:NTF {#1}
- { \tl_set:Nx \l__deriv_derivset_tl { \cs_to_str:N #1 } }
- { \tl_set:Nx \l__deriv_derivset_tl { \tl_to_str:n {#1} } }
-
- \__deriv_derivset:Vn \l__deriv_derivset_tl {#2}
-}
-
-\cs_new_protected:Npn \__deriv_derivset:nn #1 #2
-{
- \seq_if_in:NnTF \l__deriv_d_variant_seq {#1}
- { \__deriv_d_set_keys:nn {#1} {#2} }
+ \str_if_eq:nnTF {#1} { all }
{
- \seq_if_in:NnTF \l__deriv_p_variant_seq {#1}
- { \__deriv_p_set_keys:nn {#1} {#2} }
- {
- \str_if_eq:nnTF {#1} { all }
- { \__deriv_all_set_keys:n {#2} }
- {
- \msg_error:nnxx { deriv } { derivative-not-defined }
- { \token_to_str:N #1 }
- { \token_to_str:N \derivset }
- }
- }
+ \__deriv_set_default:nnn { all } {#2} { all }
+ \keys_set:nn { deriv/all/all } { default }
}
+ {
+ \tl_set:Nx \l__deriv_derivset_tl { \cs_to_str:N #1 }
+ \deriv_set_keys:Vn \l__deriv_derivset_tl {#2}
+ }
}
-% dv , key=val clist
-\cs_new_protected:Npn \__deriv_d_set_keys:nn #1 #2
+% dv, keyval
+\cs_new_protected:Npn \deriv_set_keys:nn #1 #2
{
- \tl_if_novalue:nTF {#2}
+ \seq_if_in:NnTF \l__deriv_dv_variant_seq {#1}
+ { \__deriv_set_default:nnn {#1} {#2} { dv } }
{
- \keys_set:nn { deriv/d/#1 }
+ \seq_if_in:NnTF \l__deriv_i_variant_seq {#1}
+ { \__deriv_set_default:nnn {#1} {#2} { i } }
{
- style-inf , style-frac , style-frac-/ ,
- scale-eval , scale-eval-/ , scale-fun , scale-var , scale-frac , scale-frac-/ ,
- delims-eval , delims-eval-/ , delims-fun , delims-var , delims-frac , delims-frac-/ ,
- sep-inf-ord , sep-inf-fun , sep-ord-fun , sep-var-ord , sep-inf-var , sep-eval-sb , sep-eval-sp ,
- switch-* , switch-/ ,
- misc-remove-delims
+ \msg_error:nnxx { deriv } { derivative-not-defined }
+ { \token_to_str:N #1 }
+ { \token_to_str:N \derivset }
}
}
- { \keys_set:nn { deriv/d/#1 } {#2} }
}
-% key=val clist
-\cs_new_protected:Npn \__deriv_p_set_keys:nn #1 #2
+% keyval, dv/i, variant
+\cs_new_protected:Npn \deriv_local_keys:nnn #1 #2 #3
{
- \tl_if_novalue:nTF {#2}
+ \tl_if_novalue:nTF {#1}
{
- \keys_set:nn { deriv/p/#1 }
+ \bool_if:cT { l__deriv_#2_#3_local_keys_bool }
{
- style-inf , style-frac , style-frac-/ ,
- scale-eval , scale-eval-/ , scale-fun , scale-var , scale-frac , scale-frac-/ ,
- delims-eval , delims-eval-/ , delims-fun , delims-var , delims-frac , delims-frac-/ ,
- sep-inf-ord , sep-inf-fun , sep-ord-fun , sep-inf-var , sep-var-ord , sep-var-inf , sep-ord-inf , sep-eval-sb , sep-eval-sp ,
- switch-* , switch-/ ,
- sort-method , sort-numerical , sort-sign-reverse , sort-symbol-reverse , sort-abs-reverse ,
- misc-remove-delims
+ \keys_set:nn { deriv/#2/#3 } { default }
+ \bool_set_false:c { l__deriv_#2_#3_local_keys_bool }
}
}
- { \keys_set:nn { deriv/p/#1 } {#2} }
+ {
+ \bool_if:cTF { l__deriv_#2_#3_local_keys_bool }
+ { \keys_set:nn { deriv/#2/#3 } { default, #1 } }
+ { \keys_set:nn { deriv/#2/#3 } {#1} }
+ \bool_set_true:c { l__deriv_#2_#3_local_keys_bool }
+ }
}
-% key=val clist
-\cs_new_protected:Npn \__deriv_all_set_keys:n #1
-{
- \tl_if_novalue:nTF {#1}
- { \keys_set:nn { deriv-all-settings } { scale-auto } }
- { \keys_set:nn { deriv-all-settings } {#1} }
-}
-
%%%%% Declaring variants %%%%%
-% tl-dv , macro , key-value
-\cs_new_protected:Npn \deriv_d_preamble:Nnn #1 #2 #3
+% tl-dv, macro, inf, keyval, dv/i
+\cs_new_protected:Npn \deriv_preamble:NNnnn #1 #2 #3 #4 #5
{
\tl_set:Nx #1 { \cs_to_str:N #2 }
- \seq_if_in:NVF \l__deriv_d_variant_seq #1
+ \__deriv_preamble_aux:Vnn #1 {#4} {#5}
+ \exp_args:NV \deriv_set_style_inf:nnn {#1} {#3} {#5}
+}
+% dv/i, variant, inf
+\cs_new_protected:Npn \deriv_set_style_inf:nnn #1 #2 #3
+{ \keys_set:nn { deriv/#3/#1 } { style-inf = {#2} } }
+% variant, key-value, dv/i
+\cs_new_protected:Npn \__deriv_preamble_aux:nnn #1 #2 #3
+{
+ \seq_if_in:cnF { l__deriv_#3_variant_seq } {#1}
{
- \seq_put_left:NV \l__deriv_d_variant_seq #1
- \__deriv_d_variables:V #1
- \__deriv_d_define_keys:V #1
+ \seq_put_left:cn { l__deriv_#3_variant_seq } {#1}
+ \use:c { __deriv_#3_variables:n } {#1}
+ \use:c { __deriv_#3_define_keys:n } {#1}
}
- \__deriv_derivset:VV #1 \c_novalue_tl
- \tl_if_novalue:nF {#3} { \__deriv_derivset:Vn #1 {#3} }
+ \prop_set_eq:cc { l__deriv_#3_#1_user_keys_prop } { c__deriv_#3_pkg_keys_prop }
+ \__deriv_set_default:nnn {#1} {#2} {#3}
}
-% dv , new/delare/renew/provide , macro , inf
-\cs_new_protected:Npn \deriv_d_define:nnnn #1 #2 #3 #4
+% data-type, variant, category, cs-var-list
+\cs_new:Npn \__deriv_new:nnnn #1 #2 #3 #4
{
- \exp_args:Nnnx
- \use:c { #2 DocumentCommand }{#3}{ s o m t/ m !e{\char_generate:nn {`_}{8}^} }
+ \seq_set_from_clist:Nn \l__deriv_new_var_seq {#4}
+ \seq_map_inline:Nn \l__deriv_new_var_seq
+ { \cs:w #1_new:c \cs_end: { l__deriv_#2_#3_##1_#1 } }
+}
+% variant
+\cs_new_protected:Npn \__deriv_dv_variables:n #1
+{
+ \__deriv_new:nnnn { tl } {dv_#1} { style } { inf, var, frac, frac_slash }
+ \__deriv_new:nnnn { tl } {dv_#1} { scale } { eval, eval_slash, fun, var, frac, frac_slash }
+ \__deriv_new:nnnn { tl } {dv_#1} { delims } { eval, eval_slash, fun, var, frac, frac_slash }
+ \__deriv_new:nnnn { tl } {dv_#1} { sep } { inf_ord, inf_fun, ord_fun, frac_fun, inf_var, var_ord, var_inf, ord_inf, eval_sb, eval_sp }
+ \__deriv_new:nnnn { bool } {dv_#1} { switch } { star, slash }
+ \__deriv_new:nnnn { clist } {dv_#1} { sort } { method }
+ \__deriv_new:nnnn { tl } {dv_#1} { sort } { numerical }
+ \__deriv_new:nnnn { bool } {dv_#1} { sort } { abs_reverse, sign_reverse, symbol_reverse, number_reverse }
+ \__deriv_new:nnnn { bool } {dv_#1} { misc } { fun, frac }
+ \__deriv_new:nnnn { clist } {dv_#1} { misc } { var }
+
+ \__deriv_new:nnnn { clist } {dv_#1} { misc } { order }
+ \__deriv_new:nnnn { tl } {dv_#1} { misc } { mixed_order }
+ \__deriv_new:nnnn { prop } {dv_#1} { user } { keys }
+ \__deriv_new:nnnn { bool } {dv_#1} { local } { keys }
+}
+% variant
+\cs_new_protected:Npn \__deriv_i_variables:n #1
+{
+ \__deriv_new:nnnn { tl } {i_#1} { style } { inf, notation, notation_star }
+ \__deriv_new:nnnn { tl } {i_#1} { scale } { var, var_star }
+ \__deriv_new:nnnn { tl } {i_#1} { delims } { var, var_star }
+ \__deriv_new:nnnn { tl } {i_#1} { sep } { begin, inf_ord, inf_var, ord_var, var_inf, var_var, ord_ord, end }
+ \__deriv_new:nnnn { bool } {i_#1} { switch } { star }
+ \__deriv_new:nnnn { bool } {i_#1} { mics } { fun, var, frac }
+ \__deriv_new:nnnn { clist } {i_#1} { misc } { order }
+ \__deriv_new:nnnn { prop } {i_#1} { user } { keys }
+ \__deriv_new:nnnn { bool } {i_#1} { local } { keys }
+}
+% variant, keyval, dv/i
+\cs_new_protected:Npn \__deriv_set_default:nnn #1 #2 #3
+{
+ \tl_if_novalue:nTF {#2}
+ { \prop_set_eq:cc { l__deriv_#3_#1_user_keys_prop } { c__deriv_#3_pkg_keys_prop } }
+ { \__deriv_update_prop:cn { l__deriv_#3_#1_user_keys_prop } {#2} }
+
+ \__deriv_set_default_from_prop:Nc \l__deriv_tmp_keys_tl { l__deriv_#3_#1_user_keys_prop }
+ \__deriv_set_default_aux:Vnn \l__deriv_tmp_keys_tl {#1} {#3}
+}
+% user-prop, key-val
+\cs_new_protected:Npn \__deriv_update_prop:Nn #1 #2
+{
+ \prop_set_from_keyval:Nn \l__deriv_tmp_keys_prop {#2}
+ \prop_map_inline:Nn \l__deriv_tmp_keys_prop { \prop_put:Nnn #1 {##1} {##2} }
+}
+% user-prop
+\cs_new_protected:Npn \__deriv_set_default_from_prop:NN #1 #2
+{
+ \seq_clear:N \l__deriv_tmp_keys_seq
+ \prop_map_inline:Nn #2 { \seq_put_right:Nn \l__deriv_tmp_keys_seq { ##1 = {##2} } }
+ \tl_set:Nx #1 { \seq_use:Nn \l__deriv_tmp_keys_seq { , } }
+}
+% key-val, variant, dv/i
+\cs_new_protected:Npn \__deriv_set_default_aux:nnn #1 #2 #3
+{
+ \keys_define:nn { deriv/#3/#2 } { default .meta:n = {#1} }
+ \keys_set:nn { deriv/#3/#2 } { default }
+}
+% new/delare/renew/provide, variant, macro
+\cs_new_protected:Npn \deriv_dv_define:Nnn #1 #2 #3
+{
+ \exp_args:Nne #1 {#3}{ s o m t/ m !e{\char_generate:nn {`_}{8}^} }
{
\group_begin:
- \exp_args:Nnc \bool_xor:nnTF {##4} { l__deriv_#1_switch_slash_bool }
+ \deriv_local_keys:nnn {##2} { dv } {#2}
+
+ \exp_args:Nnc \bool_xor:nnTF {##4} { l__deriv_dv_#2_switch_slash_bool }
{
- \exp_args:Nnc \bool_xor:nnTF {##1} { l__deriv_#1_switch_star_bool }
- { \__deriv_odv_both:nnnnnnn {#4} {#1} {##2} {##3} {##5} {##6} {##7} }
- { \__deriv_odv_slash:nnnnnnn {#4} {#1} {##2} {##3} {##5} {##6} {##7} }
+ \exp_args:Nnc \bool_xor:nnTF {##1} { l__deriv_dv_#2_switch_star_bool }
+ { \__deriv_dv_both:nnnnn {dv_#2} {##3} {##5} {##6} {##7} }
+ { \__deriv_dv_slash:nnnnn {dv_#2} {##3} {##5} {##6} {##7} }
}
{
- \exp_args:Nnc \bool_xor:nnTF {##1} { l__deriv_#1_switch_star_bool }
- { \__deriv_odv_star:nnnnnnn {#4} {#1} {##2} {##3} {##5} {##6} {##7} }
- { \__deriv_odv_none:nnnnnnn {#4} {#1} {##2} {##3} {##5} {##6} {##7} }
+ \exp_args:Nnc \bool_xor:nnTF {##1} { l__deriv_dv_#2_switch_star_bool }
+ { \__deriv_dv_star:nnnnn {dv_#2} {##3} {##5} {##6} {##7} }
+ { \__deriv_dv_none:nnnnn {dv_#2} {##3} {##5} {##6} {##7} }
}
\group_end:
}
}
-% tl-dv , macro , key-value
-\cs_new_protected:Npn \deriv_p_preamble:Nnn #1 #2 #3
+% new/delare/renew/provide, variant, macro
+\cs_new_protected:Npn \deriv_i_define:Nnn #1 #2 #3
{
- \tl_set:Nx #1 { \cs_to_str:N #2 }
- \seq_if_in:NVF \l__deriv_p_variant_seq #1
+ #1 {#3}{ s o m }
{
- \seq_put_left:NV \l__deriv_p_variant_seq #1
- \__deriv_p_variables:V #1
- \__deriv_p_define_keys:V #1
- }
- \__deriv_derivset:VV #1 \c_novalue_tl
- \tl_if_novalue:nF {#3} { \__deriv_derivset:Vn #1 {#3} }
-}
-% dv , new/delare/renew/provide , macro , inf
-\cs_new_protected:Npn \deriv_p_define:nnnn #1 #2 #3 #4
-{
- \exp_args:Nnnx
- \use:c { #2 DocumentCommand }{#3}{ s o o m t/ m !e{\char_generate:nn {`_}{8}^} }
- {
\group_begin:
- \exp_args:Nnc \bool_xor:nnTF {##5} { l__deriv_#1_switch_slash_bool }
- {
- \exp_args:Nnc \bool_xor:nnTF {##1} { l__deriv_#1_switch_star_bool }
- { \__deriv_pdv_both:nnnnnnnn {#4} {#1} {##2} {##3} {##4} {##6} {##7} {##8} }
- { \__deriv_pdv_slash:nnnnnnnn {#4} {#1} {##2} {##3} {##4} {##6} {##7} {##8} }
- }
- {
- \exp_args:Nnc \bool_xor:nnTF {##1} { l__deriv_#1_switch_star_bool }
- { \__deriv_pdv_star:nnnnnnnn {#4} {#1} {##2} {##3} {##4} {##6} {##7} {##8} }
- { \__deriv_pdv_none:nnnnnnnn {#4} {#1} {##2} {##3} {##4} {##6} {##7} {##8} }
- }
+ \deriv_local_keys:nnn {##2} { i } {#2}
+
+ \exp_args:Nnc \bool_xor:nnTF {##1} { l__deriv_i_#2_switch_star_bool }
+ { \__deriv_inf_star:nn {i_#2} {##3} }
+ { \__deriv_inf_none:nn {i_#2} {##3} }
\group_end:
}
}
-% dv
-\cs_new_protected:Npn \__deriv_d_variables:n #1
-{
- \__deriv_new:nnnn { tl } {#1} { style } { inf, frac, frac_slash }
- \__deriv_new:nnnn { tl } {#1} { scale } { eval, eval_slash, fun, var, frac, frac_slash }
- \__deriv_new:nnnn { tl } {#1} { delims } { eval, eval_slash, fun, var, frac, frac_slash }
- \__deriv_new:nnnn { muskip } {#1} { sep } { inf_ord, inf_fun, ord_fun, var_ord, inf_var, eval_sb, eval_sp }
- \__deriv_new:nnnn { bool } {#1} { switch } { star, slash }
- \__deriv_new:nnnn { bool } {#1} { mics } { fun, var, frac }
-}
-% dv
-\cs_new_protected:Npn \__deriv_p_variables:n #1
-{
- \__deriv_new:nnnn { tl } {#1} { style } { inf, frac, frac_slash }
- \__deriv_new:nnnn { tl } {#1} { scale } { eval, eval_slash, fun, var, frac, frac_slash }
- \__deriv_new:nnnn { tl } {#1} { delims } { eval, eval_slash, fun, var, frac, frac_slash }
- \__deriv_new:nnnn { muskip } {#1} { sep } { inf_ord, inf_fun, ord_fun, inf_var, var_ord, var_inf, ord_inf, eval_sb, eval_sp }
- \__deriv_new:nnnn { bool } {#1} { switch } { star, slash }
- \__deriv_new:nnnn { clist } {#1} { sort } { method }
- \__deriv_new:nnnn { tl } {#1} { sort } { numerical }
- \__deriv_new:nnnn { bool } {#1} { sort } { sign_reverse, symbol_reverse, abs_reverse }
- \__deriv_new:nnnn { bool } {#1} { mics } { fun, var, frac }
-}
-% data-type , dv , category , cs-var-list
-\cs_new:Npn \__deriv_new:nnnn #1 #2 #3 #4
-{
- \seq_set_from_clist:Nn \l__deriv_var_seq {#4}
- \seq_map_inline:Nn \l__deriv_var_seq
- { \cs:w #1_new:c \cs_end: { l__deriv_#2_#3_##1_#1 } }
-}
-%%%%% Ordinary derivative definition %%%%%
-
-% inf , dv , order , function , variable , sb-point , sp-point
-\cs_new_protected:Npn \__deriv_odv_both:nnnnnnn #1 #2 #3 #4 #5 #6 #7
+%%%%% derivative definition %%%%%
+% variant, function, variable, sb-point, sp-point
+\cs_new_protected:Npn \__deriv_dv_both:nnnnn #1 #2 #3 #4 #5
{
- \__deriv_set_order:Nn \l__deriv_d_order_tl {#3}
- \__deriv_evaluation_slash:nnnn {#2} {#6} {#7}
+ \__deriv_dv_preparation:Nnn \l__deriv_dv_denom_tl {#1} {#3}
+ \__deriv_evaluation_slash:nnnn {#1} {#4} {#5}
{
- \__deriv_fraction_slash:nn {#2}
+ \__deriv_fraction_slash:nn {#1}
{
- \use:c { __deriv_#2_style_frac_slash:n }
- { \__deriv_d_numerator_nofun:nn {#1} {#2} }
- { \__deriv_d_denominator:nnn {#1} {#2} {#5} }
+ \use:c { __deriv_#1_style_frac_slash:nn }
+ { \__deriv_dv_numerator_nofun:n {#1} }
+ { \__deriv_dv_denominator:n {#1} }
}
- \__deriv_function:nn {#2} {#4}
+ \__deriv_insert_fun:nnn {#1} {#2} { frac_fun }
}
}
-% inf , dv , order , function , variable , sb-point , sp-point
-\cs_new_protected:Npn \__deriv_odv_star:nnnnnnn #1 #2 #3 #4 #5 #6 #7
+% variant, function, variable, sb-point, sp-point
+\cs_new_protected:Npn \__deriv_dv_star:nnnnn #1 #2 #3 #4 #5
{
- \__deriv_set_order:Nn \l__deriv_d_order_tl {#3}
- \__deriv_evaluation:nnnn {#2} {#6} {#7}
+ \__deriv_dv_preparation:Nnn \l__deriv_dv_denom_tl {#1} {#3}
+ \__deriv_evaluation:nnnn {#1} {#4} {#5}
{
- \__deriv_fraction:nn {#2}
+ \__deriv_fraction:nn {#1}
{
- \use:c { __deriv_#2_style_frac:n }
- { \__deriv_d_numerator_nofun:nn {#1} {#2} }
- { \__deriv_d_denominator:nnn {#1} {#2} {#5} }
+ \use:c { __deriv_#1_style_frac:nn }
+ { \__deriv_dv_numerator_nofun:n {#1} }
+ { \__deriv_dv_denominator:n {#1} }
}
- \__deriv_function:nn {#2} {#4}
+ \__deriv_insert_fun:nnn {#1} {#2} { frac_fun }
}
}
-% inf , dv , order , function , variable , sb-point , sp-point
-\cs_new_protected:Npn \__deriv_odv_slash:nnnnnnn #1 #2 #3 #4 #5 #6 #7
+% variant, function, variable, sb-point, sp-point
+\cs_new_protected:Npn \__deriv_dv_slash:nnnnn #1 #2 #3 #4 #5
{
- \__deriv_set_order:Nn \l__deriv_d_order_tl {#3}
- \__deriv_evaluation_slash:nnnn {#2} {#6} {#7}
+ \__deriv_dv_preparation:Nnn \l__deriv_dv_denom_tl {#1} {#3}
+ \__deriv_evaluation_slash:nnnn {#1} {#4} {#5}
{
- \__deriv_fraction_slash:nn {#2}
+ \__deriv_fraction_slash:nn {#1}
{
- \use:c { __deriv_#2_style_frac_slash:n }
- { \__deriv_d_numerator_fun:nnn {#1} {#2} {#4} }
- { \__deriv_d_denominator:nnn {#1} {#2} {#5} }
+ \use:c { __deriv_#1_style_frac_slash:nn }
+ { \__deriv_dv_numerator_fun:nn {#1} {#2} }
+ { \__deriv_dv_denominator:n {#1} }
}
}
}
-% inf , dv , order , function , variable , sb-point , sp-point
-\cs_new_protected:Npn \__deriv_odv_none:nnnnnnn #1 #2 #3 #4 #5 #6 #7
+% variant, function, variable, sb-point, sp-point
+\cs_new_protected:Npn \__deriv_dv_none:nnnnn #1 #2 #3 #4 #5
{
- \__deriv_set_order:Nn \l__deriv_d_order_tl {#3}
- \__deriv_evaluation:nnnn {#2} {#6} {#7}
+ \__deriv_dv_preparation:Nnn \l__deriv_dv_denom_tl {#1} {#3}
+ \__deriv_evaluation:nnnn {#1} {#4} {#5}
{
- \__deriv_fraction:nn {#2}
+ \__deriv_fraction:nn {#1}
{
- \use:c { __deriv_#2_style_frac:n }
- { \__deriv_d_numerator_fun:nnn {#1} {#2} {#4} }
- { \__deriv_d_denominator:nnn {#1} {#2} {#5} }
+ \use:c { __deriv_#1_style_frac:nn }
+ { \__deriv_dv_numerator_fun:nn {#1} {#2} }
+ { \__deriv_dv_denominator:n {#1} }
}
}
+}% variant, function
+\cs_new_protected:Npn \__deriv_dv_numerator_fun:nn #1 #2
+{
+ \__deriv_insert_inf:n {#1}
+ \__deriv_show_order:cTF { l__deriv_#1_misc_mixed_order_tl }
+ {
+ \__deriv_insert_ord:cnn { l__deriv_#1_misc_mixed_order_tl } {#1} { inf_ord }
+ \__deriv_insert_fun:nnn {#1} {#2} { ord_fun }
+ }
+ { \__deriv_insert_fun:nnn {#1} {#2} { inf_fun } }
}
-% inf , dv , function
-\cs_new_protected:Npn \__deriv_d_numerator_fun:nnn #1 #2 #3
+% variant
+\cs_new_protected:Npn \__deriv_dv_numerator_nofun:n #1
{
- \__deriv_insert_inf:nn {#1} {#2}
- \__deriv_insert_ord:Nnn \l__deriv_d_order_tl {#2} { inf_ord }
- \__deriv_insert_fun:Nnn \l__deriv_d_order_tl {#2} {#3}
+ \__deriv_insert_inf:n {#1}
+ \__deriv_show_order:cT { l__deriv_#1_misc_mixed_order_tl }
+ { \__deriv_insert_ord:cnn { l__deriv_#1_misc_mixed_order_tl } {#1} { inf_ord } }
}
-% inf , dv
-\cs_new_protected:Npn \__deriv_d_numerator_nofun:nn #1 #2
+% dv
+\cs_new_protected:Npn \__deriv_dv_denominator:n #1
+{ \tl_use:N \l__deriv_dv_denom_tl }
+% denom-tl, variant, variable
+\cs_new_protected:Npn \__deriv_dv_preparation:Nnn #1 #2 #3
{
- \__deriv_insert_inf:nn {#1} {#2}
- \__deriv_insert_ord:Nnn \l__deriv_d_order_tl {#2} { inf_ord }
+ \tl_clear:N #1
+ \seq_set_from_clist:Nn \l__deriv_dv_var_seq {#3}
+ \seq_set_from_clist:Nc \l__deriv_dv_order_seq { l__deriv_#2_misc_order_clist }
+
+ \__deriv_dv_choose_var:NNNn \l__deriv_dv_var_seq \l__deriv_dv_order_seq #1 {#2}
}
-% inf , dv , variable
-\cs_new_protected:Npn \__deriv_d_denominator:nnn #1 #2 #3
+% var-seq, order-seq, denom-tl, variant
+\cs_new_protected:Npn \__deriv_dv_choose_var:NNNn #1 #2 #3 #4
{
- \__deriv_insert_inf:nn {#1} {#2}
- \__deriv_insert_var_ord:Nnn \l__deriv_d_order_tl {#2} {#3}
+ \exp_args:Nv
+ \str_case:nn { l__deriv_#4_style_var_tl }
+ {
+ { single } { \__deriv_dv_build_single:NNNn #1 #2 #3 {#4} }
+ { multiple } { \__deriv_dv_build_multiple:NNNn #1 #2 #3 {#4} }
+ }
}
-
-%%%%% Partial derivative definition %%%%%
-% inf , dv , order , mixed order , function , variable , sb-point , sp-point
-\cs_new_protected:Npn \__deriv_pdv_both:nnnnnnnn #1 #2 #3 #4 #5 #6 #7 #8
+% var_seq, order_seq, denom-tl, variant
+\cs_new_protected:Npn \__deriv_dv_build_multiple:NNNn #1 #2 #3 #4
{
- \__deriv_preparation:NNnnnnn \l__deriv_p_mo_tl \l__deriv_p_denom_tl {#1} {#2} {#3} {#4} {#6}
- \__deriv_evaluation_slash:nnnn {#2} {#7} {#8}
+ \int_set:Nn \l__deriv_tmpa_int { \seq_count:N #1 }
+ \__deriv_adjust_ord_seq:NN #1 #2
+
+ \str_if_eq:cNT { l__deriv_#4_misc_mixed_order_tl } 1
+ { \__deriv_mixed_order:cNn { l__deriv_#4_misc_mixed_order_tl } #2 {#4} }
+
+ \__deriv_var_bool_seq:cNN { l__deriv_#4_misc_var_clist } \l__deriv_tmpa_seq \l__deriv_tmpa_int
+
+ \seq_map_indexed_inline:Nn #1
{
- \__deriv_fraction_slash:nn {#2}
+ \seq_pop_left:NN #2 \l__deriv_tmpa_tl
+ \seq_pop_left:NN \l__deriv_tmpa_seq \l__deriv_tmpb_tl
+ \tl_put_right:Nx #3
{
- \use:c { __deriv_#2_style_frac_slash:n }
- { \__deriv_p_numerator_nofun:nn {#1} {#2} }
- { \__deriv_p_denominator:n {#2} }
+ \__deriv_insert_inf:n {#4}
+ \__deriv_insert_mskip:nn {#4} { inf_var }
+ \__deriv_insert_var:Nnn \l__deriv_tmpb_tl {##2} {#4}
+ \__deriv_show_order:NTF \l__deriv_tmpa_tl
+ {
+ \__deriv_insert_ord:Nnn \l__deriv_tmpa_tl {#4} { var_ord }
+ \int_compare:nNnF {##1} = { \l__deriv_tmpa_int }
+ { \__deriv_insert_mskip:nn {#4} { ord_inf } }
+ }
+ {
+ \int_compare:nNnF {##1} = { \l__deriv_tmpa_int }
+ { \__deriv_insert_mskip:nn {#4} { var_inf } }
+ }
}
- \__deriv_function:nn {#2} {#5}
}
}
-% inf , dv , order , mixed order , function , variable , sb-point , sp-point
-\cs_new_protected:Npn \__deriv_pdv_star:nnnnnnnn #1 #2 #3 #4 #5 #6 #7 #8
+% var_seq, order_seq, denom-tl, variant
+\cs_new_protected:Npn \__deriv_dv_build_single:NNNn #1 #2 #3 #4
{
- \__deriv_preparation:NNnnnnn \l__deriv_p_mo_tl \l__deriv_p_denom_tl {#1} {#2} {#3} {#4} {#6}
- \__deriv_evaluation:nnnn {#2} {#7} {#8}
+ \int_set:Nn \l__deriv_tmpa_int { \seq_count:N #1 }
+ \tl_set:Nx \l__deriv_tmpa_tl { \seq_use:Nn #1 { \__deriv_insert_mskip:nn {#4} { var_var } } }
+
+ \__deriv_var_bool_seq:cNN { l__deriv_#4_misc_var_clist } \l__deriv_tmpa_seq \l__deriv_tmpa_int
+
+ \seq_pop_left:NN #2 \l__deriv_tmpb_tl
+ \seq_pop_left:NN \l__deriv_tmpa_seq \l__deriv_tmpc_tl
+ \tl_put_right:Nx #3
{
- \__deriv_fraction:nn {#2}
+ \__deriv_insert_inf:n {#4}
+ \__deriv_insert_mskip:nn {#4} { inf_var }
+ \__deriv_insert_var:NVn \l__deriv_tmpc_tl \l__deriv_tmpa_tl {#4}
+ \__deriv_show_order:NT \l__deriv_tmpb_tl
+ { \__deriv_insert_ord:Nnn \l__deriv_tmpb_tl {#4} { var_ord } }
+ }
+ \str_if_eq:cNT { l__deriv_#4_misc_mixed_order_tl } 1
+ { \tl_set_eq:cN { l__deriv_#4_misc_mixed_order_tl } \l__deriv_tmpb_tl }
+}
+% var_seq, order_seq
+\cs_new_protected:Npn \__deriv_adjust_ord_seq:NN #1 #2
+{
+ \int_set:Nn \l__deriv_vmo_int { \seq_count:N #1 - \seq_count:N #2 }
+
+ \int_compare:nNnF { \l__deriv_vmo_int } = { 0 }
+ {
+ \int_compare:nNnTF { \l__deriv_vmo_int } < { 0 }
{
- \use:c { __deriv_#2_style_frac:n }
- { \__deriv_p_numerator_nofun:nn {#1} {#2} }
- { \__deriv_p_denominator:n {#2} }
+ \int_step_inline:nn { -1 * \l__deriv_vmo_int }
+ { \seq_pop_right:NN #2 \l__deriv_tmpa_tl }
}
- \__deriv_function:nn {#2} {#5}
+ {
+ \int_step_inline:nn { \l__deriv_vmo_int }
+ { \seq_put_right:Nn #2 { 1 } }
+ }
}
}
-% inf , dv , order , mixed order , function , variable , sb-point , sp-point
-\cs_new_protected:Npn \__deriv_pdv_slash:nnnnnnnn #1 #2 #3 #4 #5 #6 #7 #8
+% avd-clist, bool-seq, count
+\cs_new_protected:Npn \__deriv_var_bool_seq:NNN #1 #2 #3
{
- \__deriv_preparation:NNnnnnn \l__deriv_p_mo_tl \l__deriv_p_denom_tl {#1} {#2} {#3} {#4} {#6}
- \__deriv_evaluation_slash:nnnn {#2} {#7} {#8}
+ \seq_clear:N #2
+ \clist_if_in:NnTF #1 { all }
{
- \__deriv_fraction_slash:nn {#2}
+ \exp_args:NNx
+ \seq_set_from_clist:Nn #2 { \prg_replicate:nn {#3} { \c_true_bool , } }
+ }
+ {
+ \clist_if_in:NnTF #1 { none }
{
- \use:c { __deriv_#2_style_frac_slash:n }
- { \__deriv_p_numerator_fun:nnn {#1} {#2} {#5} }
- { \__deriv_p_denominator:n {#2} }
+ \exp_args:NNx
+ \seq_set_from_clist:Nn #2 { \prg_replicate:nn {#3} { \c_false_bool , } }
}
+ {
+ \int_step_inline:nn {#3}
+ {
+ \clist_if_in:NnTF #1 {##1}
+ { \seq_put_right:Nn #2 { \c_true_bool } }
+ { \seq_put_right:Nn #2 { \c_false_bool } }
+ }
+ }
}
}
-% inf , dv , order , mixed order , function , variable , sb-point , sp-point
-\cs_new_protected:Npn \__deriv_pdv_none:nnnnnnnn #1 #2 #3 #4 #5 #6 #7 #8
+% ord-seq, var-seq
+\cs_new_protected:Npn \__deriv_adjust_trailing_ord:NN #1 #2
{
- \__deriv_preparation:NNnnnnn \l__deriv_p_mo_tl \l__deriv_p_denom_tl {#1} {#2} {#3} {#4} {#6}
- \__deriv_evaluation:nnnn {#2} {#7} {#8}
+ \seq_clear:N \l__deriv_tmpa_seq
+ \bool_set_false:N \l__deriv_tmpa_bool
+ \int_set:Nn \l__deriv_vmo_int { \seq_count:N #2 - \seq_count:N #1 }
+
+ \int_compare:nNnT { \l__deriv_vmo_int } < { 0 }
{
- \__deriv_fraction:nn {#2}
+ \int_step_inline:nn { -1*\l__deriv_vmo_int }
+ { \seq_pop_right:NN #1 \l__deriv_tmpa_tl }
+ }
+
+ \seq_reverse:N #1
+ \seq_map_inline:Nn #1
+ {
+ \bool_if:NTF \l__deriv_tmpa_bool
+ { \seq_put_right:Nn \l__deriv_tmpa_seq {##1} }
{
- \use:c { __deriv_#2_style_frac:n }
- { \__deriv_p_numerator_fun:nnn {#1} {#2} {#5} }
- { \__deriv_p_denominator:n {#2} }
+ \str_if_eq:nnF {##1} { 1 }
+ {
+ \seq_put_right:Nn \l__deriv_tmpa_seq {##1}
+ \bool_set_true:N \l__deriv_tmpa_bool
+ }
}
}
-}% inf , dv , function
-\cs_new_protected:Npn \__deriv_p_numerator_fun:nnn #1 #2 #3
+ \seq_set_eq:NN #1 \l__deriv_tmpa_seq
+ \seq_reverse:N #1
+}
+
+%%%%% infinisimal definition %%%%%
+% variant, variable
+\cs_new:Npn \__deriv_inf_none:nn #1 #2
{
- \__deriv_insert_inf:nn {#1} {#2}
- \__deriv_insert_ord:Nnn \l__deriv_p_mo_tl {#2} { inf_ord }
- \__deriv_insert_fun:Nnn \l__deriv_p_mo_tl {#2} {#3}
+ \__deriv_i_preparation:Nnnn \l__deriv_i_denom_tl {#1} {#2} { }
+ \__deriv_i_print:Nn \l__deriv_i_denom_tl {#1}
}
-% inf , dv
-\cs_new_protected:Npn \__deriv_p_numerator_nofun:nn #1 #2
+
+% variant, variable
+\cs_new:Npn \__deriv_inf_star:nn #1 #2
{
- \__deriv_insert_inf:nn {#1} {#2}
- \__deriv_insert_ord:Nnn \l__deriv_p_mo_tl {#2} { inf_ord }
+ \__deriv_i_preparation:Nnnn \l__deriv_i_denom_tl {#1} {#2} { _star }
+ \__deriv_i_print:Nn \l__deriv_i_denom_tl {#1}
}
-% dv
-\cs_new_protected:Npn \__deriv_p_denominator:n #1
+% print-tl, variant
+\cs_new:Npn \__deriv_i_print:Nn #1 #2
{
- \tl_use:N \l__deriv_p_denom_tl %{ \__deriv_insert_mskip:nn {#1} { var_inf } }
+ \__deriv_insert_mskip:nn {#2} { begin }
+ \tl_use:N #1
+ \__deriv_insert_mskip:nn {#2} { end }
}
-% mixed-order-tl , denom-seq , inf , dv , order , mixed order , variable
-\cs_new_protected:Npn \__deriv_preparation:NNnnnnn #1 #2 #3 #4 #5 #6 #7
+% print-tl, variant, variable, if star
+\cs_new_protected:Npn \__deriv_i_preparation:Nnnn #1 #2 #3 #4
{
- \seq_clear:N #2
- \seq_set_from_clist:Nn \l__deriv_p_var_seq {#7}
- \tl_if_novalue:nTF {#5} { \seq_clear:N \l__deriv_p_order_seq } { \seq_set_from_clist:Nn \l__deriv_p_order_seq {#5} }
+ \tl_clear:N #1
+ \seq_set_from_clist:Nn \l__deriv_i_var_seq {#3}
+ \seq_set_from_clist:Nc \l__deriv_i_order_seq { l__deriv_#2_misc_order_clist }
- \tl_if_novalue:nTF {#6}
+ \__deriv_i_choose_build:NNNnn \l__deriv_i_var_seq \l__deriv_i_order_seq #1 {#2} {#4}
+}
+% var-seq, order-seq, print-tl, variant, if star
+\cs_new_protected:Npn \__deriv_i_choose_build:NNNnn #1 #2 #3 #4 #5
+{
+ \exp_args:Nv
+ \str_case:nn { l__deriv_#4_style_notation#5_tl }
{
- \seq_set_eq:NN \l__deriv_p_mo_seq \l__deriv_p_order_seq
- \__deriv_adjust_mo_seq:NNN \l__deriv_p_mo_seq \l__deriv_p_var_seq \l__deriv_p_order_seq
- \__deriv_mixed_order:NNn #1 \l__deriv_p_mo_seq {#4}
+ { single } { \__deriv_i_build_single:NNNnn #1 #2 #3 {#4} {#5} }
+ { multiple } { \__deriv_i_build_multiple:NNNnn #1 #2 #3 {#4} {#5} }
+ { mixed } { \__deriv_i_build_mixed:NNNnn #1 #2 #3 {#4} {#5} }
}
- { \tl_set:Nn #1 {#6} }
-
- \__deriv_p_build_denom:NNNnn \l__deriv_p_var_seq \l__deriv_p_order_seq #2 {#3} {#4}
}
-
-\cs_new_protected:Npn \__deriv_adjust_mo_seq:NNN #1 #2 #3
+% var-seq, order-seq, print-tl, variant, if star
+\cs_new_protected:Npn \__deriv_i_build_single:NNNnn #1 #2 #3 #4 #5
{
- \int_set:Nn \l__deriv_vmo_int { \seq_count:N #2 - \seq_count:N #3 }
- \__deriv_case:nF
+ \int_set:Nn \l__deriv_tmpa_int { \seq_count:N #1 }
+ \__deriv_var_bool_seq:cNN { l__deriv_#4_misc_var_clist } \l__deriv_add_var_bool_seq \l__deriv_tmpa_int
+ \__deriv_adjust_trailing_ord:NN #2 #1
+
+ \int_set:Nn \l__deriv_tmpb_int { \seq_count:N #2 }
+
+ \seq_map_indexed_inline:Nn #1
{
- { \int_compare_p:nNn { \l__deriv_vmo_int } > { 0 } } { \seq_put_left:NV #1 \l__deriv_vmo_int }
- { \int_compare_p:nNn { \l__deriv_vmo_int } = { 0 } } { \prg_do_nothing: }
+ \seq_pop_left:NN \l__deriv_add_var_bool_seq \l__deriv_tmpa_tl
+ \tl_put_right:Nx \l__deriv_tmpb_tl
+ {
+ \__deriv_insert_var:Nnnn \l__deriv_tmpa_tl {##2} {#4} {#5}
+ \int_compare:nNnF {##1} = { \l__deriv_tmpa_int }
+ { \__deriv_insert_mskip:nn {#4} { var_var } }
+ }
}
+ \seq_map_indexed_inline:Nn #2
{
- \int_step_inline:nn { -1 * \l__deriv_vmo_int }
- { \seq_pop_right:NN #1 \l__deriv_p_tmpa_tl }
+ \tl_put_right:Nx \l__deriv_tmpc_tl
+ {
+ \exp_not:n {##2}
+ \int_compare:nNnF {##1} = { \l__deriv_tmpb_int }
+ { \__deriv_insert_mskip:nn {#4} { ord_ord } }
+ }
}
-}
-% \l__deriv_p_var_seq \l__deriv_p_order_seq, denom-tl , inf , dv
-\cs_new_protected:Npn \__deriv_p_build_denom:NNNnn #1 #2 #3 #4 #5
-{
- \int_zero:N \l__deriv_tmpa_int
- \seq_map_inline:Nn #1
+ \tl_put_right:Nx #3
{
- \int_incr:N \l__deriv_tmpa_int
- \seq_pop_left:NN #2 \l__deriv_p_tmpa_tl
- \tl_if_blank:nF {##1}
+ \__deriv_insert_inf:n {#4}
+ \sb
{
- \tl_put_right:Nx #3
+ \__deriv_insert_mskip:nn {#4} { inf_var }
+ \exp_not:V \l__deriv_tmpb_tl
+ }
+ \tl_if_blank:VF \l__deriv_tmpc_tl
+ {
+ \sp
{
- \__deriv_insert_inf:nn {#4} {#5}
- \int_compare:nNnTF { \l__deriv_tmpa_int } = { \seq_count:N #1 }
- { \__deriv_insert_var_ord:Nnn \l__deriv_p_tmpa_tl {#5} {##1} }
- { \__deriv_insert_var_ord_sep:Nnn \l__deriv_p_tmpa_tl {#5} {##1} }
+ \__deriv_insert_mskip:nn {#4} { inf_ord }
+ \exp_not:V \l__deriv_tmpc_tl
}
}
}
}
-%%%%% And the rest of the code %%%%%
-% inf , dv
-\cs_new:Npn \__deriv_insert_inf:nn #1 #2
+% var-seq, order-seq, print-tl, variant
+\cs_new_protected:Npn \__deriv_i_build_multiple:NNNnn #1 #2 #3 #4 #5
{
- \exp_not:n
+ \int_set:Nn \l__deriv_tmpa_int { \seq_count:N #1 }
+ \__deriv_var_bool_seq:cNN { l__deriv_#4_misc_var_clist } \l__deriv_add_var_bool_seq \l__deriv_tmpa_int
+ \__deriv_adjust_ord_seq:NN #1 #2
+
+ \seq_map_indexed_inline:Nn #1
{
- \use:c { __deriv_#2_style_inf:n } {#1}
+ \seq_pop_left:NN #2 \l__deriv_tmpa_tl
+ \seq_pop_left:NN \l__deriv_add_var_bool_seq \l__deriv_tmpb_tl
+ \tl_put_right:Nx #3
+ {
+ \__deriv_insert_inf:n {#4}
+ \__deriv_show_order:NTF \l__deriv_tmpa_tl
+ {
+ \__deriv_insert_ord:Nnn \l__deriv_tmpa_tl {#4} { inf_ord }
+ \__deriv_insert_mskip:nn {#4} { ord_var }
+ }
+ { \__deriv_insert_mskip:nn {#4} { inf_var } }
+
+ \__deriv_insert_var:Nnnn \l__deriv_tmpb_tl {##2} {#4} {#5}
+ \int_compare:nNnF {##1} = { \l__deriv_tmpa_int }
+ { \__deriv_insert_mskip:nn {#4} { var_inf } }
+ }
}
}
-% dv , function
-\cs_new:Npn \__deriv_insert_fun:Nnn #1 #2 #3
+% var-seq, order-seq, print-tl, variant
+\cs_new_protected:Npn \__deriv_i_build_mixed:NNNnn #1 #2 #3 #4 #5
{
- \tl_if_blank:nF {#3}
+ \int_set:Nn \l__deriv_tmpa_int { \seq_count:N #1 }
+ \__deriv_var_bool_seq:cNN { l__deriv_#4_misc_var_clist } \l__deriv_add_var_bool_seq \l__deriv_tmpa_int
+ \__deriv_adjust_ord_seq:NN #1 #2
+
+ \seq_map_indexed_inline:Nn #1
{
- \str_if_eq:NNTF #1 1
- { \__deriv_insert_mskip:nn {#2} { inf_fun } }
- { \__deriv_insert_mskip:nn {#2} { ord_fun } }
- \__deriv_function:nn {#2} {#3}
+ \seq_pop_left:NN #2 \l__deriv_tmpa_tl
+ \seq_pop_left:NN \l__deriv_add_var_bool_seq \l__deriv_tmpb_tl
+ \tl_put_right:Nx #3
+ {
+ \__deriv_insert_inf:n {#4}
+ \__deriv_show_order:NT \l__deriv_tmpa_tl
+ { \__deriv_insert_ord:Nnn \l__deriv_tmpa_tl {#4} { inf_ord } }
+ \sb
+ {
+ \__deriv_insert_mskip:nn {#4} { inf_var }
+ \__deriv_insert_var:Nnnn \l__deriv_tmpb_tl {##2} {#4} {#5}
+ }
+ \int_compare:nNnF {##1} = { \l__deriv_tmpa_int }
+ { \__deriv_insert_mskip:nn {#4} { var_inf } }
+ }
}
}
-% order, dv , variable
-\cs_new:Npn \__deriv_insert_var_ord:Nnn #1 #2 #3
+%%%%% And the rest of the code %%%%%
+% variant
+\cs_new:Npn \__deriv_insert_inf:n #1
+{ \exp_not:v { l__deriv_#1_style_inf_tl } }
+% dv, function, muskip
+\cs_new:Npn \__deriv_insert_fun:nnn #1 #2 #3
{
- \tl_if_blank:nF {#3}
+ \tl_if_blank:nF {#2}
{
- \__deriv_insert_mskip:nn {#2} { inf_var }
- \exp_not:n { \__deriv_variable:nn {#2} {#3} }
- \__deriv_insert_ord:Nnn #1 {#2} { var_ord }
+ \__deriv_insert_mskip:nn {#1} {#3}
+ \bool_if:cTF { l__deriv_#1_misc_fun_bool }
+ { \__deriv_add_delims:nnn {#1} { fun } {#2} }
+ {#2}
}
}
-\cs_new:Npn \__deriv_insert_var_ord_sep:Nnn #1 #2 #3
+% if delim, variable, variant
+\cs_new:Npn \__deriv_insert_var:Nnn #1 #2 #3
{
- \tl_if_blank:nF {#3}
- {
- \__deriv_insert_mskip:nn {#2} { inf_var }
- \exp_not:n { \__deriv_variable:nn {#2} {#3} }
- \__deriv_insert_ord:Nn #1 {#2}
- }
+ \bool_if:NTF #1
+ { \__deriv_add_delims:nnn {#3} { var } {#2} }
+ { \__deriv_handle_double_sp:n {#2} }
}
-% dv , name
-\cs_new:Npn \__deriv_insert_mskip:nn #1 #2
+% if delim, variable, variant, star
+\cs_new:Npn \__deriv_insert_var:Nnnn #1 #2 #3 #4
{
- \str_if_eq:vnF { l__deriv_#1_sep_#2_muskip } { 0.0mu }
- { \exp_args:Nc \mskip { l__deriv_#1_sep_#2_muskip } }
+ \bool_if:NTF #1
+ { \__deriv_add_delims:nnn {#3} { var#4 } {#2} }
+ { \__deriv_handle_double_sp:n {#2} }
}
-% order , dv , name
+% order, variant, name
\cs_new:Npn \__deriv_insert_ord:Nnn #1 #2 #3
{
- \__deriv_show_order:NT #1
+ \sp
{
- \sp
- {
- \__deriv_insert_mskip:nn {#2} {#3}
- \tl_use:N #1
- }
+ \__deriv_insert_mskip:nn {#2} {#3}
+ \exp_not:V #1
}
}
-% order , dv , name
-\cs_new:Npn \__deriv_insert_ord:Nn #1 #2
+% dv, name
+\cs_new:Npn \__deriv_insert_mskip:nn #1 #2
{
- \__deriv_show_order:NTF #1
+ %[#2]
+ \tl_if_empty:cF { l__deriv_#1_sep_#2_tl }
+ { \exp_not:v { l__deriv_#1_sep_#2_tl } }
+ %\exp_not:v { l__deriv_#1_sep_#2_tl }
+}
+% muskip, length
+\cs_new:Npn \__deriv_set_rubber_length:Nn #1 #2
+{
+ \regex_match:NnTF \c__deriv_cs_numbers_regex {#2}
{
- \sp
+ \str_case_e:nnF {#2}
{
- \__deriv_insert_mskip:nn {#2} { var_ord }
- \tl_use:N #1
+ { 0 } { \tl_clear:N #1 }
+ { 0,0 } { \tl_clear:N #1 }
+ { 0,0,0 } { \tl_clear:N #1 }
}
- \__deriv_insert_mskip:nn {#2} { ord_inf }
+ {
+ \seq_set_split:Nnn \l__deriv_rubber_seq { , } {#2}
+ \tl_set:Nf #1 { \seq_use:Nnnn \l__deriv_rubber_seq { mu plus } { mu plus } { mu minus } mu }
+ \tl_put_left:Nn #1 { \mskip }
+ }
}
- { \__deriv_insert_mskip:nn {#2} { var_inf } }
+ { \tl_set:Nn #1 {#2} }
}
-% order , order-list
-\cs_new:Npn \__deriv_set_order:Nn #1 #2
-{
- \tl_if_novalue:nTF {#2}
- { \tl_set:Nn #1 { 1 } }
- { \tl_set:Nn #1 {#2} }
-}
-% muskip , length
-\cs_new:Npn \__deriv_set_rubber_length:Nn #1 #2
-{
- \seq_set_split:Nnn \l__deriv_rubber_seq { , } { #2 }
- \exp_args:NNf
- \muskip_set:Nn #1 { \seq_use:Nnnn \l__deriv_rubber_seq { mu plus } { mu plus } { mu minus } mu }
-}
%%%%% Scale, delimiters, evaluation %%%%%
-% dv , function
-\cs_new:Npn \__deriv_function:nn #1 #2
-{
- \bool_set_false:c { l__deriv_#1_mics_var_bool }
- \bool_if:cTF { l__deriv_#1_mics_fun_bool }
- {
- \bool_set_false:c { l__deriv_#1_mics_fun_bool }
- \__deriv_add_delims:nnn {#1} { fun } {#2}
- }
- { #2 }
-}
-% dv , variable
-\cs_new:Npn \__deriv_variable:nn #1 #2
-{
- \bool_if:cTF { l__deriv_#1_mics_var_bool }
- {
- \bool_set_false:c { l__deriv_#1_mics_var_bool }
- \__deriv_add_delims:nnn {#1} { var } {#2}
- }
- { \__deriv_handle_double_sp:n {#2} }
-}
% variable
\cs_new:Npn \__deriv_handle_double_sp:n #1
{
- \tl_set:Nn \l_tmpa_tl {#1}
- \str_set:Nn \l_tmpa_str {#1}
-
- \str_if_in:NnTF \l_tmpa_str { ^ }
+ \str_case_e:nnF { ^ }
{
- \exp_args:Nf
- \str_if_eq:nnTF { \tl_item:Nn \l_tmpa_tl {-2} } { ^ }
- { {#1} }
- {
- \exp_args:Nf
- \str_if_eq:nnTF { \tl_item:Nn \l_tmpa_tl {-4} } { ^ }
- { {#1} }
- { #1 }
- }
+ { \tl_item:nn {#1} { -2 } } { \exp_not:n { {#1} } }
+ { \tl_item:nn {#1} { -4 } } { \exp_not:n { {#1} } }
}
- {#1}
+ { \exp_not:n {#1} }
}
-% dv , code-for-fraction
+% dv, code-for-fraction
\cs_new:Npn \__deriv_fraction:nn #1 #2
{
- \bool_if:cTF { l__deriv_#1_mics_frac_bool }
- {
- \bool_set_false:c { l__deriv_#1_mics_frac_bool }
- \__deriv_add_delims:nnn {#1} { frac } {#2}
- }
- { #2 }
+ \bool_if:cTF { l__deriv_#1_misc_frac_bool }
+ { \__deriv_add_delims:nnn {#1} { frac } {#2} }
+ {#2}
}
-% dv , code-for-fraction
+% dv, code-for-fraction
\cs_new:Npn \__deriv_fraction_slash:nn #1 #2
{
- \bool_if:cTF { l__deriv_#1_mics_frac_bool }
- {
- \bool_set_false:c { l__deriv_#1_mics_frac_bool }
- \__deriv_add_delims:nnn {#1} { frac_slash } {#2}
- }
- { #2 }
+ \bool_if:cTF { l__deriv_#1_misc_frac_bool }
+ { \__deriv_add_delims:nnn {#1} { frac_slash } {#2} }
+ {#2}
}
-% dv , sub , sup , code-for-fraction
+% dv, sub, sup, code-for-fraction
\cs_new:Npn \__deriv_evaluation:nnnn #1 #2 #3 #4
{
\__deriv_if_novalue_and:nnTF {#2} {#3}
- { #4 }
+ {#4}
{
\__deriv_add_delims:nnn {#1} { eval } {#4}
\__deriv_if_novalue:nF {#2} { \sb{ \__deriv_insert_mskip:nn {#1} { eval_sb } #2 } }
@@ -900,11 +977,11 @@
\__deriv_if_novalue:nF {#3} { \sp{ \__deriv_insert_mskip:nn {#1} { eval_sp } #3 } }
}
}
-% dv , sub , sup , code-for-fraction
+% dv, sub, sup, code-for-fraction
\cs_new:Npn \__deriv_evaluation_slash:nnnn #1 #2 #3 #4
{
\__deriv_if_novalue_and:nnTF {#2} {#3}
- { #4 }
+ {#4}
{
\__deriv_add_delims:nnn {#1} { eval_slash } {#4}
\__deriv_if_novalue:nF {#2} { \sb{ \__deriv_insert_mskip:nn {#1} { eval_sb } #2 } }
@@ -911,60 +988,44 @@
\__deriv_if_novalue:nF {#3} { \sp{ \__deriv_insert_mskip:nn {#1} { eval_sp } #3 } }
}
}
-% dv , name , value
+% dv, name, value
\cs_new:Npn \__deriv_add_delims:nnn #1 #2 #3
{
- \__deriv_scale_left:nn {#1} {#2}
- {#3}
- \__deriv_scale_right:nn {#1} {#2}
+ \__deriv_scale:Nnnnn \__deriv_auto_left:n {#1} {#2} { 1 } { l }
+ #3
+ \__deriv_scale:Nnnnn \__deriv_auto_right:n {#1} {#2} { 2 } { r }
}
-% dv , name
-\cs_new:Npn \__deriv_scale_left:nn #1 #2
+% dv, name
+\cs_new:Npn \__deriv_scale:Nnnnn #1 #2 #3 #4 #5
{
- \exp_args:Nv \str_case:nnF { l__deriv_#1_scale_#2_tl }
+ \exp_args:Nv \str_case:nnF { l__deriv_#2_scale_#3_tl }
{
- { auto } { \__deriv_scale_auto:Nnnn \__deriv_auto_left:n {#1} {#2} { 1 } }
- { none } { \__deriv_scale_none:nnn {#1} {#2} { 1 } }
+ { auto } { \__deriv_scale_auto:Nnnn #1 {#2} {#3} {#4} }
+ { none } { \__deriv_scale_none:nnn {#2} {#3} {#4} }
}
- { \__deriv_scale_big:nnnn {#1} {#2} { 1 } { l } }
+ { \__deriv_scale_big:nnnn {#2} {#3} {#4} {#5} }
}
-% dv , name
-\cs_new:Npn \__deriv_scale_right:nn #1 #2
-{
- \exp_args:Nv \str_case:nnF { l__deriv_#1_scale_#2_tl }
- {
- { auto } { \__deriv_scale_auto:Nnnn \__deriv_auto_right:n {#1} {#2} { 2 } }
- { none } { \__deriv_scale_none:nnn {#1} {#2} { 2 } }
- }
- { \__deriv_scale_big:nnnn {#1} {#2} { 2 } { r } }
-}
-% left/right , dv , name, number
+% left/right, variant, name, number
\cs_new:Npn \__deriv_scale_auto:Nnnn #1 #2 #3 #4
-{
- #1 \tl_item:cn { l__deriv_#2_delims_#3_tl } { #4 }
-}
-% dv , name , number
+{ #1 \tl_item:cn { l__deriv_#2_delims_#3_tl } {#4} }
+% dv, name, number
\cs_new:Npn \__deriv_scale_none:nnn #1 #2 #3
-{
- \str_if_eq:cNF { l__deriv_#1_delims_#2_tl } . { \tl_item:cn { l__deriv_#1_delims_#2_tl } { #3 } }
-}
-% dv , name , number , l/r
+{ \str_if_eq:cNF { l__deriv_#1_delims_#2_tl } . { \tl_item:cn { l__deriv_#1_delims_#2_tl } {#3} } }
+% dv, name, number, l/r
\cs_new:Npn \__deriv_scale_big:nnnn #1 #2 #3 #4
-{
- \tl_use:c { \tl_use:c { l__deriv_#1_scale_#2_tl } #4 } { \tl_item:cn { l__deriv_#1_delims_#2_tl } { #3 } }
-}
+{ \tl_use:c { \tl_use:c { l__deriv_#1_scale_#2_tl } #4 } { \tl_item:cn { l__deriv_#1_delims_#2_tl } {#3} } }
%%%%% Calculation of mixed order %%%%%
-% mixed-order-tl , mixed-order-seq , dv
+% mixed-order-tl, mixed-order-seq, variant
\cs_new:Npn \__deriv_mixed_order:NNn #1 #2 #3
{
\__deriv_replace:NN \l__deriv_input_seq #2
\__deriv_seq_counting:N \l__deriv_input_seq
- \__deriv_combine_seq:N \l__deriv_unsorted_seq
+ \__deriv_combine_seq:Nn \l__deriv_unsorted_seq {#3}
\__deriv_sort:NNn \l__deriv_sorted_seq \l__deriv_unsorted_seq {#3}
\__deriv_output:NNNn #1 \l__deriv_sorted_seq \l__deriv_numerical_int {#3}
}
-% input-seq , mixed-order-seq
+% input-seq, mixed-order-seq
\cs_new_protected:Npn \__deriv_replace:NN #1 #2
{
\tl_set:Nf \l__deriv_input_tl { \seq_use:Nn #2 { , } }
@@ -990,7 +1051,7 @@
{ \__deriv_add_to_seq:NN \l__deriv_sym_tmpa_tl \l__deriv_num_tmpa_tl }
}
}
-% sym-tl , num-tl , seq-item
+% sym-tl, num-tl, seq-item
\cs_new_protected:Npn \__deriv_extract:NNn #1 #2 #3
{
\regex_extract_once:NnN \c__deriv_pattern_regex {#3} \l__deriv_extract_seq
@@ -1003,41 +1064,49 @@
{ - } { \tl_set:Nn #2 { -1 } }
}
}
-% unsorted-seq
-\cs_new:Npn \__deriv_combine_seq:N #1
+% unsorted-seq, variant
+\cs_new:Npn \__deriv_combine_seq:Nn #1 #2
{
\seq_clear:N #1
+ \int_zero:N \l__deriv_numerical_int
\seq_map_inline:Nn \l__deriv_symbol_seq
{
\seq_pop_left:NN \l__deriv_number_seq \l__deriv_num_tmpa_tl
- \__deriv_eval_term:NNn #1 \l__deriv_num_tmpa_tl {##1}
+ \__deriv_eval_term:NVnn #1 \l__deriv_num_tmpa_tl {##1} {#2}
}
}
-% unsorted-seq , num-tl, seq-item
-\cs_new_protected:Npn \__deriv_eval_term:NNn #1 #2 #3
+% unsorted-seq, num-tl, seq-item (sym), variant
+\cs_new_protected:Npn \__deriv_eval_term:Nnnn #1 #2 #3 #4
{
\__deriv_case:nF
{
- { \tl_if_empty_p:n {#3} } { \int_set:Nn \l__deriv_numerical_int {#2} }
- { \int_compare_p:nNn {#2} = { 1 } } { \seq_put_left:Nn #1 {#3} }
- { \int_compare_p:nNn {#2} = { 0 } } { \prg_do_nothing: }
- { \int_compare_p:nNn {#2} = { -1 } } { \seq_put_left:Nn #1 { -#3 } }
+ { \tl_if_empty_p:n {#3} } { \__deriv_numerical_term:Nnn #1 {#2} {#4} }
+ { \int_compare_p:nNn {#2} = { 1 } } { \seq_put_left:Nn #1 {#3} }
+ { \int_compare_p:nNn {#2} = { 0 } } { \prg_do_nothing: }
+ { \int_compare_p:nNn {#2} = { -1 } } { \seq_put_left:Nn #1 { -#3 } }
}
- { \seq_put_left:No #1 { #2 #3 } }
+ { \seq_put_left:Nn #1 {#2#3} }
}
-% sym-tl , num-tl
+% unsorted-seq, num-tl, variant
+\cs_new_protected:Npn \__deriv_numerical_term:Nnn #1 #2 #3
+{
+ \str_if_eq:vnTF { l__deriv_#3_sort_numerical_tl } { symbolic }
+ { \seq_put_left:Nn #1 {#2} }
+ { \int_set:Nn \l__deriv_numerical_int {#2} }
+}
+% sym-tl, num-tl
\cs_new_protected:Npn \__deriv_add_to_seq:NN #1 #2
{
\seq_put_left:NV \l__deriv_symbol_seq #1
\seq_put_left:NV \l__deriv_number_seq #2
}
-% sym-tl , num-tl
+% sym-tl, num-tl
\cs_new_protected:Npn \__deriv_update_seq:NN #1 #2
{
\__deriv_get_position:NN \l__deriv_position_int #1
\__deriv_rebuild_seq:NNN \l__deriv_number_seq \l__deriv_position_int #2
}
-% position-int , sym-tl
+% position-int, sym-tl
\cs_new:Npn \__deriv_get_position:NN #1 #2
{
\int_zero:N #1
@@ -1047,10 +1116,10 @@
\exp_args:NV \tl_if_eq:nnT #2 {##1} { \seq_map_break: }
}
}
-% num-seq , position-int , num-tl
+% num-seq, position-int, num-tl
\cs_new_protected:Npn \__deriv_rebuild_seq:NNN #1 #2 #3
{
- \int_zero:N \l__deriv_rebuild_int
+ \int_zero:N \l__deriv_rebuild_int
\seq_clear:N \l__deriv_rebuild_seq
\seq_map_inline:Nn #1
@@ -1065,10 +1134,10 @@
}
\seq_set_eq:NN #1 \l__deriv_rebuild_seq
}
-% sorted-seq , unsorted-seq , dv
+% sorted-seq, unsorted-seq, variant
\cs_new_protected:Npn \__deriv_sort:NNn #1 #2 #3
{
- \int_set:Nn \l__deriv_sort_max_int { \clist_count:c { l__deriv_#3_sort_method_clist } }
+ \int_set:Nn \l__deriv_sort_max_int { \int_min:nn { 3 } { \clist_count:c { l__deriv_#3_sort_method_clist } } }
\seq_sort:Nn #2
{
@@ -1087,9 +1156,10 @@
\exp_args:Nf
\str_case:nn { \clist_item:cn { l__deriv_#1_sort_method_clist } { \l__deriv_sort_counter_int } }
{
- { sign } { \__deriv_sort_sign:n {#1} }
- { symbol } { \__deriv_sort_symbol:n {#1} }
- { abs } { \__deriv_sort_abs:n {#1} }
+ { sign } { \__deriv_sort_sign:n {#1} }
+ { symbol } { \__deriv_sort_symbol:n {#1} }
+ { abs } { \__deriv_sort_abs:n {#1} }
+ { number } { \__deriv_sort_number:n {#1} }
}
}
% dv
@@ -1097,8 +1167,8 @@
{
\__deriv_case:nF
{
- { \tl_if_head_eq_charcode_p:VN \l__deriv_num_tmpb_tl - && ! \tl_if_head_eq_charcode_p:VN \l__deriv_num_tmpa_tl - } { \__deriv_sort_reverse:nnn {#1} { sign } { same } }
- { \tl_if_head_eq_charcode_p:VN \l__deriv_num_tmpa_tl - && ! \tl_if_head_eq_charcode_p:VN \l__deriv_num_tmpb_tl - } { \__deriv_sort_reverse:nnn {#1} { sign } { swapped } }
+ { \tl_if_head_eq_charcode_p:VN \l__deriv_num_tmpb_tl - && ! \tl_if_head_eq_charcode_p:VN \l__deriv_num_tmpa_tl - } { \__deriv_sort_reverse:nnn {#1} { sign } { same } }
+ { \tl_if_head_eq_charcode_p:VN \l__deriv_num_tmpa_tl - && ! \tl_if_head_eq_charcode_p:VN \l__deriv_num_tmpb_tl - } { \__deriv_sort_reverse:nnn {#1} { sign } { swapped } }
}
{
\int_compare:nNnTF { \l__deriv_sort_counter_int } = { \l__deriv_sort_max_int }
@@ -1111,8 +1181,8 @@
{
\__deriv_case:nF
{
- { \int_compare_p:nNn { \tl_count:N \l__deriv_sym_tmpa_tl } > { \tl_count:N \l__deriv_sym_tmpb_tl } } { \__deriv_sort_reverse:nnn {#1} { symbol } { same } }
- { \int_compare_p:nNn { \tl_count:N \l__deriv_sym_tmpa_tl } < { \tl_count:N \l__deriv_sym_tmpb_tl } } { \__deriv_sort_reverse:nnn {#1} { symbol } { swapped } }
+ { \int_compare_p:nNn { \tl_count:N \l__deriv_sym_tmpa_tl } > { \tl_count:N \l__deriv_sym_tmpb_tl } } { \__deriv_sort_reverse:nnn {#1} { symbol } { same } }
+ { \int_compare_p:nNn { \tl_count:N \l__deriv_sym_tmpa_tl } < { \tl_count:N \l__deriv_sym_tmpb_tl } } { \__deriv_sort_reverse:nnn {#1} { symbol } { swapped } }
}
{
\int_compare:nNnTF { \l__deriv_sort_counter_int } = { \l__deriv_sort_max_int }
@@ -1125,8 +1195,8 @@
{
\__deriv_case:nF
{
- { \int_compare_p:nNn { \int_abs:n \l__deriv_num_tmpa_tl } > { \int_abs:n \l__deriv_num_tmpb_tl } } { \__deriv_sort_reverse:nnn {#1} { abs } { same } }
- { \int_compare_p:nNn { \int_abs:n \l__deriv_num_tmpa_tl } < { \int_abs:n \l__deriv_num_tmpb_tl } } { \__deriv_sort_reverse:nnn {#1} { abs } { swapped } }
+ { \int_compare_p:nNn { \int_abs:n \l__deriv_num_tmpa_tl } > { \int_abs:n \l__deriv_num_tmpb_tl } } { \__deriv_sort_reverse:nnn {#1} { abs } { same } }
+ { \int_compare_p:nNn { \int_abs:n \l__deriv_num_tmpa_tl } < { \int_abs:n \l__deriv_num_tmpb_tl } } { \__deriv_sort_reverse:nnn {#1} { abs } { swapped } }
}
{
\int_compare:nNnTF { \l__deriv_sort_counter_int } = { \l__deriv_sort_max_int }
@@ -1134,7 +1204,21 @@
{ \__deriv_sort_method:n {#1} }
}
}
-% dv , sort-method , same/swapped
+% dv
+\cs_new_protected:Npn \__deriv_sort_number:n #1
+{
+ \__deriv_case:nF
+ {
+ { \int_compare_p:nNn { \l__deriv_num_tmpa_tl } > { \l__deriv_num_tmpb_tl } } { \__deriv_sort_reverse:nnn {#1} { number } { same } }
+ { \int_compare_p:nNn { \l__deriv_num_tmpa_tl } < { \l__deriv_num_tmpb_tl } } { \__deriv_sort_reverse:nnn {#1} { number } { swapped } }
+ }
+ {
+ \int_compare:nNnTF { \l__deriv_sort_counter_int } = { \l__deriv_sort_max_int }
+ { \sort_return_same: }
+ { \__deriv_sort_method:n {#1} }
+ }
+}
+% dv, sort-method, same/swapped
\cs_new_protected:Npn \__deriv_sort_reverse:nnn #1 #2 #3
{
\exp_args:Nc
@@ -1142,7 +1226,7 @@
{ \sort_return_same: }
{ \sort_return_swapped: }
}
-% mixed-order-tl , sorted-seq , numerical-term, dv
+% mixed-order-tl, sorted-seq, numerical-term, variant
\cs_new_protected:Npn \__deriv_output:NNNn #1 #2 #3 #4
{
\tl_set:Nf #1 { \seq_use:Nn #2 { + } }
@@ -1150,17 +1234,17 @@
\int_compare:nNnF {#3} = { 0 }
{
\tl_if_empty:NTF #1
- { \tl_put_left:NV #1 #3 }
+ { \tl_put_left:NV #1 #3 }
{
\exp_args:Nv \str_case:nnF { l__deriv_#4_sort_numerical_tl }
{
- { last } { \tl_put_right:Nx #1 { + \int_use:N #3 } }
- { first } { \tl_put_left:Nx #1 { \int_use:N #3 + } }
+ { last } { \tl_put_right:Nx #1 { + \int_use:N #3 } }
+ { first } { \tl_put_left:Nx #1 { \int_use:N #3 + } }
}
{
\bool_if:nTF { \tl_if_head_eq_charcode_p:VN #1 - }
- { \tl_put_left:NV #1 #3 }
- { \tl_put_right:Nx #1 { + \int_use:N #3 } }
+ { \tl_put_left:NV #1 #3 }
+ { \tl_put_right:Nx #1 { + \int_use:N #3 } }
}
}
}
@@ -1170,90 +1254,90 @@
%%%%% Declaring Variant %%%%%
-\DeclareDocumentCommand{\NewOdvVariant}{ m m o }
+\DeclareDocumentCommand{\NewDerivative}{ m m o }
{
\cs_if_exist:NTF #1
{
\msg_error:nnxx { deriv } { command-already-defined }
{ \token_to_str:N #1 }
- { \token_to_str:N \NewOdvVariant }
+ { \token_to_str:N \NewDerivative }
}
{
- \deriv_d_preamble:Nnn \l__deriv_dv_tmp_tl {#1} {#3}
- \deriv_d_define:Vnnn \l__deriv_dv_tmp_tl { New } {#1} {#2}
+ \deriv_preamble:NNnnn \l__deriv_cs_name_tl #1 {#2} {#3} { dv }
+ \deriv_dv_define:NVn \NewDocumentCommand \l__deriv_cs_name_tl {#1}
}
}
-\DeclareDocumentCommand{\RenewOdvVariant}{ m m o }
+\DeclareDocumentCommand{\RenewDerivative}{ m m o }
{
\cs_if_exist:NTF #1
{
- \deriv_d_preamble:Nnn \l__deriv_dv_tmp_tl {#1} {#3}
- \deriv_d_define:Vnnn \l__deriv_dv_tmp_tl { Renew } {#1} {#2}
+ \deriv_preamble:NNnnn \l__deriv_cs_name_tl #1 {#2} {#3} { dv }
+ \deriv_dv_define:NVn \RenewDocumentCommand \l__deriv_cs_name_tl {#1}
}
{
- \msg_error:nnxx { deriv } { command-not-defined }
+ \msg_error:nnxx { deriv } { command-already-defined }
{ \token_to_str:N #1 }
- { \token_to_str:N \RenewOdvVariant }
+ { \token_to_str:N \RenewDerivative }
}
}
-\DeclareDocumentCommand{\ProvideOdvVariant}{ m m o }
+\DeclareDocumentCommand{\ProvideDerivative}{ m m o }
{
\cs_if_exist:NF #1
{
- \deriv_d_preamble:Nnn \l__deriv_dv_tmp_tl {#1} {#3}
- \deriv_d_define:Vnnn \l__deriv_dv_tmp_tl { Provide } {#1} {#2}
+ \deriv_preamble:NNnnn \l__deriv_cs_name_tl #1 {#2} {#3} { dv }
+ \deriv_dv_define:NVn \ProvideDocumentCommand \l__deriv_cs_name_tl {#1}
}
}
-\DeclareDocumentCommand{\DeclareOdvVariant}{ m m o }
+\DeclareDocumentCommand{\DeclareDerivative}{ m m o }
{
- \deriv_d_preamble:Nnn \l__deriv_dv_tmp_tl {#1} {#3}
- \deriv_d_define:Vnnn \l__deriv_dv_tmp_tl { Declare } {#1} {#2}
+ \deriv_preamble:NNnnn \l__deriv_cs_name_tl #1 {#2} {#3} { dv }
+ \deriv_dv_define:NVn \DeclareDocumentCommand \l__deriv_cs_name_tl {#1}
}
-\DeclareDocumentCommand{\NewPdvVariant}{ m m o }
+\DeclareDocumentCommand{\NewDifferential}{ m m o }
{
\cs_if_exist:NTF #1
{
\msg_error:nnxx { deriv } { command-already-defined }
{ \token_to_str:N #1 }
- { \token_to_str:N \NewPdvVariant }
+ { \token_to_str:N \NewOdvVariant }
}
{
- \deriv_p_preamble:Nnn \l__deriv_dv_tmp_tl {#1} {#3}
- \deriv_p_define:Vnnn \l__deriv_dv_tmp_tl { New } {#1} {#2}
+ \deriv_preamble:NNnnn \l__deriv_dv_tmp_tl #1 {#2} {#3} { i }
+ \deriv_i_define:NVn \NewDocumentCommand \l__deriv_dv_tmp_tl {#1}
}
}
-\DeclareDocumentCommand{\RenewPdvVariant}{ m m o }
+\DeclareDocumentCommand{\RenewDifferential}{ m m o }
{
\cs_if_exist:NTF #1
{
- \deriv_p_preamble:Nnn \l__deriv_dv_tmp_tl {#1} {#3}
- \deriv_p_define:Vnnn \l__deriv_dv_tmp_tl { Renew } {#1} {#2}
+ \deriv_preamble:NNnnn \l__deriv_dv_tmp_tl #1 {#2} {#3} { i }
+ \deriv_i_define:NVn \RenewDocumentCommand \l__deriv_dv_tmp_tl {#1}
}
{
- \msg_error:nnxx { deriv } { command-already-defined }
+ \msg_error:nnxx { deriv } { command-not-defined }
{ \token_to_str:N #1 }
- { \token_to_str:N \RenewPdvVariant }
+ { \token_to_str:N \RenewOdvVariant }
}
}
-\DeclareDocumentCommand{\ProvidePdvVariant}{ m m o }
+\DeclareDocumentCommand{\ProvideDifferential}{ m m o }
{
\cs_if_exist:NF #1
{
- \deriv_p_preamble:Nnn \l__deriv_dv_tmp_tl {#1} {#3}
- \deriv_p_define:Vnnn \l__deriv_dv_tmp_tl { Provide } {#1} {#2}
+ \deriv_preamble:NNnnn \l__deriv_dv_tmp_tl #1 {#2} {#3} { i }
+ \deriv_i_define:NVn \ProvideDocumentCommand \l__deriv_dv_tmp_tl {#1}
}
}
-\DeclareDocumentCommand{\DeclarePdvVariant}{ m m o }
+\DeclareDocumentCommand{\DeclareDifferential}{ m m o }
{
- \deriv_p_preamble:Nnn \l__deriv_dv_tmp_tl {#1} {#3}
- \deriv_p_define:Vnnn \l__deriv_dv_tmp_tl { Declare } {#1} {#2}
+ \deriv_preamble:NNnnn \l__deriv_dv_tmp_tl #1 {#2} {#3} { i }
+ \deriv_i_define:NVn \DeclareDocumentCommand \l__deriv_dv_tmp_tl {#1}
}
%%%%% slash frac %%%%%
@@ -1260,6 +1344,7 @@
\DeclareDocumentCommand{\slashfrac}{ o m m }
{
+ \group_begin:
\tl_if_novalue:nTF {#1}
{ \__deriv_slashfrac_auto:nn {#2} {#3} }
{
@@ -1270,41 +1355,56 @@
}
{ \__deriv_slashfrac_scale:nnn {#1} {#2} {#3} }
}
+ \group_end:
}
-% numerator , denominator
+% numerator, denominator
\cs_new_protected:Npn \__deriv_slashfrac_auto:nn #1 #2
{
- \__deriv_auto_left:n . \kern-\nulldelimiterspace
+ \__deriv_auto_left:n .
{#1} \middle/ {#2}
- \__deriv_auto_right:n . \kern-\nulldelimiterspace
+ \__deriv_auto_right:n .
}
-% numerator , denominator
+% numerator, denominator
\cs_new_protected:Npn \__deriv_slashfrac_none:nn #1 #2
-{
- {#1} / {#2}
-}
-% scale , numerator , denominator
+{ {#1} / {#2} }
+% scale, numerator, denominator
\cs_new_protected:Npn \__deriv_slashfrac_scale:nnn #1 #2 #3
{
- \cs:w #1 l \cs_end: .
+ \use:c { #1 l } .
{#2}
- \cs:w #1 \cs_end: /
+ \use:c {#1} /
{#3}
- \cs:w #1 r \cs_end: .
+ \use:c { #1 r } .
}
%%%%% Generate variants %%%%%
+\prg_generate_conditional_variant:Nnn \__deriv_show_order:N { c } { T, TF }
+
\cs_generate_variant:Nn \tl_if_head_eq_charcode_p:nN { V }
\cs_generate_variant:Nn \__deriv_set_rubber_length:Nn { c }
-\cs_generate_variant:Nn \__deriv_p_variables:n { V }
-\cs_generate_variant:Nn \__deriv_d_variables:n { V }
-\cs_generate_variant:Nn \deriv_p_define:nnnn { V }
-\cs_generate_variant:Nn \deriv_d_define:nnnn { V }
-\cs_generate_variant:Nn \__deriv_derivset:nn { V, VV }
-\cs_generate_variant:Nn \__deriv_p_define_keys:n { V }
-\cs_generate_variant:Nn \__deriv_d_define_keys:n { V }
+\cs_generate_variant:Nn \__deriv_dv_variables:n { V }
+\cs_generate_variant:Nn \__deriv_dv_define_keys:n { V }
+\cs_generate_variant:Nn \deriv_dv_define:Nnn { NV }
+\cs_generate_variant:Nn \__deriv_i_variables:n { V }
+\cs_generate_variant:Nn \__deriv_i_define_keys:n { V }
+\cs_generate_variant:Nn \deriv_i_define:Nnn { NV }
+\cs_generate_variant:Nn \deriv_set_keys:nn { V }
+\cs_generate_variant:Nn \__deriv_insert_ord:Nnn { c }
+\cs_generate_variant:Nn \__deriv_insert_var:Nnn { NV }
+
+\prg_generate_conditional_variant:Nnn \__deriv_if_novalue:n { f } { T }
+\prg_generate_conditional_variant:Nnn \__deriv_if_novalue:n { V } { TF }
+\cs_generate_variant:Nn \__deriv_mixed_order:NNn { c }
+\cs_generate_variant:Nn \__deriv_eval_term:Nnnn { NV }
+
+\cs_generate_variant:Nn \__deriv_set_default_aux:nnn { V }
+\cs_generate_variant:Nn \__deriv_set_default_from_prop:NN { Nc }
+\cs_generate_variant:Nn \__deriv_update_prop:Nn { c }
+\cs_generate_variant:Nn \__deriv_preamble_aux:nnn { V }
+\cs_generate_variant:Nn \__deriv_var_bool_seq:NNN { c }
+
%%%%% Messages %%%%%
\msg_new:nnnn { deriv } { command-already-defined }
@@ -1316,38 +1416,44 @@
\msg_new:nnnn { deriv } { derivative-not-defined }
{ Derivative~'#1'~is~not~defined! }
-{
- You~have~used~#2~with~a~derivative~that~was~never~defined.
-}
+{ You~have~used~#2~with~a~derivative~that~was~never~defined. }
+
\msg_new:nnnn { deriv } { command-not-defined }
{ Command~'#1'~not~yet~defined! }
-{
- You~have~used~#2~with~a~derivative~that~was~never~defined.
-}
+{ You~have~used~#2~with~a~derivative~that~was~never~defined. }
%%%%% Declaring derivatives %%%%%
-\bool_lazy_or:nnT { \sys_if_engine_luatex_p: } { \sys_if_engine_xetex_p: }
+\derivset{all}
+\bool_lazy_or:nnTF { \sys_if_engine_luatex_p: } { \sys_if_engine_xetex_p: }
{
- \DeclareOdvVariant{\odv}{d}[style-inf = \symup]
- \DeclareOdvVariant{\mdv}{D}[style-inf = \symup]
- \DeclareOdvVariant{\fdv}{\delta}
- \DeclareOdvVariant{\adv}{\Delta}
- \DeclareOdvVariant{\jdv}{\partial}[misc-add-delims = {fun, var}]
- \DeclarePdvVariant{\pdv}{\partial}[sep-inf-ord=1, sep-ord-fun=-2]
+ \DeclareDerivative{\odv}{\symup{d}}
+ \DeclareDerivative{\mdv}{\symup{D}}
+ \DeclareDerivative{\fdv}{\delta}
+ \DeclareDerivative{\adv}{\Delta}
+ \DeclareDerivative{\jdv}{\partial}[fun=true, var=1]
+ \DeclareDerivative{\pdv}{\partial}[style-var=multiple, sep-inf-ord=1, delims-eval=(), delims-eval-/=()]
+ \DeclareDifferential{\odif}{\symup{d}}
+ \DeclareDifferential{\mdif}{\symup{D}}[style-notation=single, style-notation-*=mixed]
+ \DeclareDifferential{\fdif}{\delta}
+ \DeclareDifferential{\adif}{\Delta}
+ \DeclareDifferential{\pdif}{\partial}[style-notation=single, style-notation-*=mixed]
}
-\sys_if_engine_pdftex:T
{
- \DeclareOdvVariant{\odv}{d}[style-inf = \mathrm]
- \DeclareOdvVariant{\mdv}{D}[style-inf = \mathrm]
- \DeclareOdvVariant{\fdv}{\delta}
- \DeclareOdvVariant{\adv}{\Delta}[style-inf = \mathrm]
- \DeclareOdvVariant{\jdv}{\partial}[misc-add-delims = {fun, var}]
- \DeclarePdvVariant{\pdv}{\partial}[sep-inf-ord=1, sep-ord-fun=-2]
+ \DeclareDerivative{\odv}{\mathrm{d}}
+ \DeclareDerivative{\mdv}{\mathrm{D}}
+ \DeclareDerivative{\fdv}{\delta}
+ \DeclareDerivative{\adv}{\Delta}
+ \DeclareDerivative{\jdv}{\partial}[fun=true, var=1]
+ \DeclareDerivative{\pdv}{\partial}[style-var=multiple, sep-inf-ord=1, delims-eval=(), delims-eval-/=()]
+
+ \DeclareDifferential{\odif}{\mathrm{d}}
+ \DeclareDifferential{\mdif}{\mathrm{D}}[style-notation=single, style-notation-*=mixed]
+ \DeclareDifferential{\fdif}{\delta}
+ \DeclareDifferential{\adif}{\Delta}
+ \DeclareDifferential{\pdif}{\partial}[style-notation=single, style-notation-*=mixed]
}
-\derivset{all}
-
\endinput
More information about the tex-live-commits
mailing list.