texlive[51696] Master: derivative (21jul19)

commits+karl at tug.org commits+karl at tug.org
Sun Jul 21 22:50:56 CEST 2019


Revision: 51696
          http://tug.org/svn/texlive?view=revision&revision=51696
Author:   karl
Date:     2019-07-21 22:50:55 +0200 (Sun, 21 Jul 2019)
Log Message:
-----------
derivative (21jul19)

Modified Paths:
--------------
    trunk/Master/tlpkg/bin/tlpkg-ctan-check
    trunk/Master/tlpkg/tlpsrc/collection-mathscience.tlpsrc

Added Paths:
-----------
    trunk/Master/texmf-dist/doc/latex/derivative/
    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/
    trunk/Master/texmf-dist/tex/latex/derivative/derivative.sty
    trunk/Master/tlpkg/tlpsrc/derivative.tlpsrc

Added: trunk/Master/texmf-dist/doc/latex/derivative/README.md
===================================================================
--- trunk/Master/texmf-dist/doc/latex/derivative/README.md	                        (rev 0)
+++ trunk/Master/texmf-dist/doc/latex/derivative/README.md	2019-07-21 20:50:55 UTC (rev 51696)
@@ -0,0 +1,33 @@
+## README for derivative package v0.9 dated 2019-07-21
+
+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:
+
+ - \odv  Ordinary derivative
+ - \pdv  Partial derivative
+ - \fdv  Functional derivtive
+ - \mdv  Material derivative
+ - \adv  Average rate of change
+ - \jdv  Jacobian
+
+### Copyright and license
+
+Copyright 2019 Simon Jensen
+
+This work may be distributed and/or modified under the
+conditions of the LaTeX Project Public License, either version 1.3
+of this license or (at your option) any later version.
+The latest version of this license is in
+  http://www.latex-project.org/lppl.txt
+and version 1.3 or later is part of all distributions of LaTeX
+version 2005/12/01 or later.
+
+This work has the LPPL maintenance status `maintained'.
+
+The Current Maintainer of this work is Simon Jensen.
+
+The bundle contains the files:
+
+     README.md           This file.
+     derivative.sty      The package itself.
+     derivative.pdf      The package documentation in PDF format.
+     derivative.txt      The master file that produced derivative.pdf.
\ No newline at end of file


Property changes on: trunk/Master/texmf-dist/doc/latex/derivative/README.md
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: trunk/Master/texmf-dist/doc/latex/derivative/derivative.pdf
===================================================================
(Binary files differ)

Index: trunk/Master/texmf-dist/doc/latex/derivative/derivative.pdf
===================================================================
--- trunk/Master/texmf-dist/doc/latex/derivative/derivative.pdf	2019-07-21 16:36:17 UTC (rev 51695)
+++ trunk/Master/texmf-dist/doc/latex/derivative/derivative.pdf	2019-07-21 20:50:55 UTC (rev 51696)

Property changes on: trunk/Master/texmf-dist/doc/latex/derivative/derivative.pdf
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+application/pdf
\ No newline at end of property
Added: trunk/Master/texmf-dist/doc/latex/derivative/derivative.tex
===================================================================
--- trunk/Master/texmf-dist/doc/latex/derivative/derivative.tex	                        (rev 0)
+++ trunk/Master/texmf-dist/doc/latex/derivative/derivative.tex	2019-07-21 20:50:55 UTC (rev 51696)
@@ -0,0 +1,1392 @@
+% derivative.tex
+% Copyright 2019 Simon Jensen
+% 
+% This work may be distributed and/or modified under the
+% conditions of the LaTeX Project Public License, either version 1.3
+% of this license or (at your option) any later version.
+% The latest version of this license is in
+% http://www.latex-project.org/lppl.txt
+% and version 1.3 or later is part of all distributions of LaTeX
+% version 2005/12/01 or later.
+% 
+% This work has the LPPL maintenance status `maintained'.
+% 
+% The Current Maintainer of this work is Simon Jensen.
+\NeedsTeXFormat{LaTeX2e}
+
+\documentclass[final,british,10pt]{scrartcl}
+	\reversemarginpar
+\RequirePackage{polyglossia}
+	\setmainlanguage[variant=british]{english}
+\RequirePackage[style=english,english=british]{csquotes}
+\RequirePackage[final,babel,auto]{microtype}
+\RequirePackage{xcolor}
+	\definecolor{RoyalGray}{RGB}{127, 144, 158}
+	\definecolor{RoyalDarkGray}{RGB}{78, 93, 104}
+	\definecolor{RoyalLightGray}{RGB}{250, 250, 250}
+	\definecolor{RoyalRed}{RGB}{157, 16, 45}
+	\definecolor{RoyalBlue}{RGB}{0, 35, 102}
+	\definecolor{RoyalGreen}{RGB}{32, 77, 2}
+
+\RequirePackage{amsmath, amsthm}
+	\allowdisplaybreaks
+	\theoremstyle{remark}
+	\newtheorem*{note}{Note}
+\RequirePackage{unicode-math}
+
+\RequirePackage{booktabs}
+\RequirePackage{tabularx}
+\RequirePackage{siunitx}
+	\sisetup{locale = UK}
+\RequirePackage{hologo}
+\RequirePackage{enumitem}
+\RequirePackage{listings}
+\RequirePackage{imakeidx}
+
+\RequirePackage{mleftright}
+\RequirePackage{xfrac}
+\RequirePackage{derivative}
+	\derivset{all}[scale-auto = mleftmright]
+
+\RequirePackage[unicode]{hyperref}
+\RequirePackage[nameinlink]{cleveref}
+
+\makeatletter
+\ExplSyntaxOn
+
+\def\verbatim{\@beginparpenalty \predisplaypenalty \@verbatim
+	\VerbFont \frenchspacing \@vobeyspaces \@xverbatim}
+
+\tl_new:N \pakkenavn
+\tl_new:N \titel
+\tl_new:N \g_deriv_email
+\tl_new:N \forfatter
+\tl_new:N \g_deriv_dato
+\tl_new:N \g_deriv_version
+
+\seq_new:N \l__deriv_args_seq
+\seq_new:N \l__deriv_marg_args_seq
+\seq_new:N \l__deriv_macro_seq
+\seq_new:N \l__deriv_tmp_seq
+\seq_new:N \l__deriv_def_opt_seq
+\seq_new:N \l__deriv_opt_seq
+\seq_new:N \l__deriv_value_seq
+
+\tl_new:N \l__deriv_tmp_tl
+\tl_new:N \l__deriv_default_tl
+
+\NewDocumentCommand{\Pakkenavn}{ m }{ \tl_gset:Nf \pakkenavn { \tl_trim_spaces:n { #1 } } }
+\NewDocumentCommand{\Titel}    { m }{ \tl_gset:Nf \titel     { \tl_trim_spaces:n { #1 } } }
+\NewDocumentCommand{\Forfatter}{ m }{ \tl_gset:Nf \forfatter { \tl_trim_spaces:n { #1 } } }
+\NewDocumentCommand{\Email}    { m }{ \tl_gset:Nf \g_deriv_email    { \tl_trim_spaces:n { #1 } } }
+\NewDocumentCommand{\Dato}     { m }{ \tl_gset:Nf \g_deriv_dato     { \tl_trim_spaces:n { #1 } } }
+\NewDocumentCommand{\Version}  { m }{ \tl_gset:Nf \g_deriv_version  { \tl_trim_spaces:n { #1 } } }
+\NewDocumentCommand{\default}  { s }
+{
+	\bool_if:nTF {#1}
+	{  \seq_use:Nnnn \l__deriv_def_opt_seq {~and~} { ,~} {~and~}  }
+	{  \seq_use:Nn   \l__deriv_def_opt_seq { ,~}                  }
+}
+
+\NewDocumentCommand{\forside}{}
+{
+	\thispagestyle{empty}
+	
+	\null\vspace{15mm}\noindent
+	
+	\begin{minipage}[t]{\textwidth}
+		\centering
+		\rule{\textwidth}{.4pt} \par \bigskip
+		{ \Huge \bfseries \tl_use:N \titel \par } \bigskip
+		\rule{\textwidth}{.4pt}
+	\end{minipage} \par \vspace{6mm} \noindent
+	
+	\begin{minipage}[t]{0.5\textwidth}
+		\centering
+		\textsl{Written~by:} \par
+		{ \color{RoyalRed} \forfatter \par }
+		{ \color{RoyalRed} \g_deriv_email \par }
+	\end{minipage}
+	\hfill
+	\begin{minipage}[t]{0.5\textwidth}
+		\centering
+		\textsl{Released:} \par
+		{ \color{RoyalRed} \g_deriv_version \par }
+		{ \color{RoyalRed} \g_deriv_dato \par }
+	\end{minipage}
+	
+	\par \vspace{20mm} \noindent
+	
+	\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
+	\clearpage
+}
+
+\newlist{todo}{enumerate}{1}
+\setlist[todo]{label=(\roman{todoi}),~ref=\thesubsection(\roman{todoi})}
+\crefname{todoi}{todo}{todos}
+
+\newlist{revision}{enumerate}{1}
+\setlist[revision]{label=(\roman{revisioni}), ref=\thesubsection(\roman{revisioni})}
+\crefname{revisioni}{revision}{revisions}
+
+\newlist{consideration}{enumerate}{1}
+\setlist[consideration]{label=(\roman{considerationi}), ref=\thesubsection(\roman{considerationi})}
+\crefname{considerationi}{consideration}{considerations}
+
+\renewcommand{\@idxitem}{\par \hangindent 0\p@ }
+\renewcommand{\subitem}{\@idxitem \hspace *{0\p@ }}
+
+\lstset
+{
+	tabsize = 1,
+	columns = fullflexible,
+	basicstyle = \CommonFont,
+	escapechar = \%,
+	alsoletter =  {\\,-},
+	keywords = [0]{style-inf, add-delims,sep-inf-ord,sep-ord-fun},
+	keywordstyle = [0]\OptionFont,
+	keywords = [1]{\\odv, \\mdv, \\fdv, \\adv, \\jdv, \\pdv, \\NewOdvVariant, \\RenewOdvVariant, \\ProvideOdvVariant, \\DeclareOdvVariant, \\NewPdvVariant, \\RenewPdvVariant, \\ProvidePdvVariant, \\DeclarePdvVariant},
+	keywordstyle = [1]\MacroFont,
+	commentstyle = \footnotesize,
+	frame = single,
+	xleftmargin=3.4pt,
+	xrightmargin=3.4pt,
+	rulesep = 0pt,
+	backgroundcolor = \color{RoyalLightGray},
+	rulecolor = \color{RoyalGray}
+}
+
+\lstnewenvironment{definition}{\normalmarginpar}{\reversemarginpar}
+
+\NewDocumentCommand{\marginnote}{ m }
+{
+	\leavevmode
+	\marginline{\leavevmode \CommonFont \color{RoyalDarkGray} \tl_trim_spaces:n {#1} }
+}
+
+\NewDocumentCommand{\print}{ m }
+{
+	\__deriv_print:n {#1}
+	\tl_use:N \l_tmpb_tl
+}
+
+\cs_new:Npn \__deriv_print:n #1
+{
+	\tl_set:Nn \l_tmpa_tl {#1}
+	\regex_replace_all:nnN { . } { \c{string} \0 } \l_tmpa_tl
+	\tl_set:Nx \l_tmpb_tl { \l_tmpa_tl }
+}
+
+\seq_new:N \l__deriv_eks_seq
+
+\NewDocumentCommand{\eks}{ s m }
+{
+	\int_gzero:N \g_tmpa_int
+	\begin{center}
+		\bool_if:nTF {#1}
+		{
+			\__deriv_eks_star:n {#2}
+		}
+		{
+			\__deriv_eks:n {#2}
+		}	
+	\end{center}
+}
+
+\cs_new_protected:Npn \__deriv_eks_star:n #1
+{
+	\seq_set_split:Nnn \l__deriv_eks_seq { ; } { #1 }
+	\tabular{ @{}c@{} }
+	\seq_map_inline:Nn \l__deriv_eks_seq
+	{
+		\int_gincr:N \g_tmpa_int
+		\EksFont
+		\print{##1}
+		
+		\\[0.5em]
+		$ \Longrightarrow \qquad \displaystyle ##1 $
+		\int_compare:nNnF { \g_tmpa_int } = { \seq_count:N \l__deriv_eks_seq }
+		{
+			\\ \addlinespace[0.5em]
+		}
+	}
+	\endtabular
+}
+
+\cs_new_protected:Npn \__deriv_eks:n #1
+{
+	\seq_set_split:Nnn \l__deriv_eks_seq { ; } { #1 }
+	\tabular{ @{}r c l@{} }
+	\seq_map_inline:Nn \l__deriv_eks_seq
+	{
+		\int_gincr:N \g_tmpa_int
+		\EksFont
+		\print{##1}
+		
+		& $ \Longrightarrow $ 
+		& $ \displaystyle ##1 $
+		\int_compare:nNnF { \g_tmpa_int } = { \seq_count:N \l__deriv_eks_seq }
+		{
+			\\ \addlinespace[0.5em]
+		}
+	}
+	\endtabular
+}
+
+\RenewDocumentCommand{\arg}{ m }
+{
+	{ \ArgFont \seq_item:Nn \l__deriv_marg_args_seq {#1} }
+}
+\NewDocumentCommand{\macro}{ s m o }
+{
+	\token_if_macro:NTF {#2}
+	{
+		\tl_set:Nf \l__deriv_tmp_tl { \cs_to_str:N #2 }
+	}
+	{
+		\tl_set:Nf \l__deriv_tmp_tl { \seq_item:Nn \l__deriv_declare_macros_seq {#2} }
+	}
+	
+	{  \MacroFont \cs{ \tl_use:N \l__deriv_tmp_tl }  }
+	
+	\bool_if:nF {#1} {  \exp_args:NV \__deriv_index:nn \l__deriv_tmp_tl { macro }  }
+	
+	\tl_if_novalue:nF {#3}
+	{
+		\group_begin:
+		\__deriv_macro_syntax:n {#3}
+		\group_end:
+	}
+}
+
+\NewDocumentCommand{\DescribeMacro}{ s m m }
+{
+	\__deriv_cs_to_str_seq:Nn \l__deriv_declare_macros_seq {#2}
+	\bool_if:nTF {#1} {\noindent} { \__deriv_init: }
+	
+	\__deriv_index_def:Nn \l__deriv_declare_macros_seq { macro-def }
+	\__deriv_marginpar_macro:NN \MacroFont \l__deriv_declare_macros_seq
+	\__deriv_macro_syntax:n {#3} \hfill
+	\__deriv_end_par:
+}
+
+\NewDocumentCommand{\DescribeArg}{ s m }
+{
+	\seq_set_from_clist:Nn \l__deriv_args_seq {#2}
+	\bool_if:nTF {#1} {\noindent} { \__deriv_init: }
+	
+	\__deriv_marginpar:NN \ArgFont \l__deriv_args_seq
+	\__deriv_end:
+}
+
+\NewDocumentCommand{\DescribeOption}{ s v o m }
+{
+	\seq_set_from_clist:Nn \l__deriv_keys_seq {#2}
+	\bool_if:nTF {#1} {\noindent} {  \__deriv_init:  }
+	
+	\__deriv_index_def:Nn \l__deriv_keys_seq { option-def }
+	\__deriv_marginpar:NN \OptionFont \l__deriv_keys_seq
+	\__deriv_option_syntax:nn {#3} {#4}
+	\__deriv_end_par:
+}
+
+\cs_new_protected:Npn \__deriv_cs_to_str_seq:Nn #1 #2
+{
+	\seq_clear:N #1
+	\seq_set_from_clist:Nn \l_tmpa_seq {#2}
+	
+	\seq_map_inline:Nn \l_tmpa_seq
+	{
+		\exp_args:NNf \seq_put_right:Nn #1 { \cs_to_str:N ##1 }
+	}
+}
+
+\cs_new_protected:Npn \__deriv_index_def:Nn #1 #2
+{
+	\str_case:nn {#2}
+	{
+		{ macro-def  } { \__deriv_index_macro_def:Nn  #1 { macro  } }
+		{ option-def } { \__deriv_index_option_def:Nn #1 { option } }
+	}
+}
+
+\cs_new_protected:Npn \__deriv_index:nn #1 #2
+{
+	\str_case:nn {#2}
+	{
+		{ option } { \__deriv_index_option:nn {#1} {#2} }
+		{ macro  } { \__deriv_index_macro:nn  {#1} {#2} }
+	}
+}
+
+\cs_new_protected:Npn \__deriv_index_macro_def:Nn #1 #2
+{
+	\seq_map_inline:Nn #1
+	{  \index[#2]{##1@\protect{\CommonFont\cs{##1}}|textbf}  }
+}
+\cs_new_protected:Npn \__deriv_index_option_def:Nn #1 #2
+{
+	\seq_map_inline:Nn #1
+	{
+		\seq_set_split:Nnn \l_tmpa_seq {-} {##1}
+		\tl_set:Nx \l_tmpa_tl { \seq_item:Nn \l_tmpa_seq {1}  }
+		\index[#2]{{\l_tmpa_tl}!##1@\protect{\CommonFont##1}|textbf}
+	}
+}
+\cs_new_protected:Npn \__deriv_index_macro:nn #1 #2
+{
+	\index[#2]{#1@\protect{\CommonFont\cs{#1}}}
+}
+\cs_new_protected:Npn \__deriv_index_option:nn #1 #2
+{
+	\seq_set_split:Nnn \l_tmpa_seq {-} {#1}
+	\tl_set:Nx \l_tmpa_tl { \seq_item:Nn \l_tmpa_seq {1}  }
+	\index[#2]{{\l_tmpa_tl}!#1@\protect{\CommonFont#1}}
+}
+
+
+\cs_new_protected:Npn \__deriv_marginpar:NN #1 #2
+{
+	\leavevmode
+	\marginline
+	{
+		\leavevmode
+		#1
+		\seq_use:Nn #2 { \\ }
+	}
+}
+
+\cs_new_protected:Npn \__deriv_marginpar_macro:NN #1 #2
+{
+	\int_zero:N \l_tmpb_int
+	\leavevmode
+	\marginline
+	{
+		\leavevmode
+		#1
+		\seq_map_inline:Nn #2
+		{
+			\cs{##1}
+			\int_incr:N \l_tmpb_int
+			\int_compare:nNnF { \l_tmpb_int } = { \seq_count:N #2 }
+			{  \\  }
+		}
+	}
+}
+
+\cs_new_protected:Npn \__deriv_init:
+{
+	\vspace{0.30\baselineskip}
+	\noindent \ignorespaces
+}
+
+\cs_new_protected:Npn \__deriv_end_par:
+{
+	\par
+	\vspace{0.20\baselineskip}
+	\noindent \ignorespaces
+}
+
+\cs_new_protected:Npn \__deriv_end:
+{
+	\noindent \ignorespaces
+}
+
+\cs_new_protected:Npn \__deriv_macro_syntax:n #1
+{
+	\seq_set_from_clist:Nn \l__deriv_marg_args_seq { #1 }
+	
+	\group_begin:
+	\CommonFontsize
+	\seq_use:Nn \l__deriv_marg_args_seq {}
+	\group_end:
+}
+
+\cs_new_protected:Npn \__deriv_option_syntax:nn #1 #2
+{
+	\__deriv_set_option_seq:Nn \l__deriv_opt_seq {#2}
+	
+	\seq_use:Nn \l__deriv_opt_seq { ,~}
+	
+	\hfill
+	\tl_if_novalue:nF {#1}
+	{
+		\__deriv_set_option_seq:Nn \l__deriv_def_opt_seq {#1}
+		\seq_use:Nn \l__deriv_def_opt_seq { ,~}
+	}
+}
+
+\cs_new_protected:Npn \__deriv_set_option_seq:Nn #1 #2
+{
+	\seq_set_from_clist:Nn \l__deriv_tmp_seq {#2}
+	\seq_clear:N #1
+	
+	\seq_map_inline:Nn \l__deriv_tmp_seq
+	{
+		\tl_if_head_eq_charcode:nNTF {##1} !
+		{
+			\seq_put_right:Nn #1 { { \CommonFontsize \tl_tail:n {##1} } }
+		}
+		{
+			\seq_put_right:Nn #1 { \val{##1} }
+		}
+	}
+}
+
+\DeclareRobustCommand\meta[1]{%
+	\ensuremath\langle
+	\ifmmode \expandafter \nfss at text \fi
+	{%
+		\meta at font@select
+		\edef\meta at hyphen@restore
+		{\hyphenchar\the\font\the\hyphenchar\font}%
+		\hyphenchar\font\m at ne
+		\language\l at nohyphenation
+		#1\/%
+		\meta at hyphen@restore
+	}\ensuremath\rangle
+}
+\def\meta at font@select{\itshape}
+
+\DeclareRobustCommand\cs[1]{{\CommonFont \char`\\#1}}
+\NewDocumentCommand{\marg}{ s m }
+{
+	\bool_if:NTF {#1}
+	{  {\ttfamily\char`\{} { \CommonFontfamily #2 } {\ttfamily\char`\}}  }
+	{  {\ttfamily\char`\{}   \meta{#2}        {\ttfamily\char`\}}  }
+}
+\providecommand\oarg[1]{%
+	{\ttfamily[}\meta{#1}{\ttfamily]}}
+
+\let\garg\marg
+
+\providecommand\targ[1]{
+	{\ttfamily #1}}
+
+\providecommand{\sarg}{ \targ{*} }
+
+\seq_new:N \l__deriv_earg_seq
+
+\NewDocumentCommand{\earg}{ m }
+{
+	\seq_set_from_clist:Nn \l__deriv_earg_seq {#1}
+	
+	\int_zero:N \l_tmpa_int
+	\seq_map_inline:Nn \l__deriv_earg_seq
+	{
+		\int_incr:N \l_tmpa_int
+		\int_if_odd:nTF \l_tmpa_int
+		{
+			{ \ttfamily ##1 }
+		}
+		{
+			\marg{ ##1 }
+		}
+	}
+}
+
+\NewDocumentCommand{\key}{ s m o o }
+{
+	{ \KeyFont #2 }
+	\bool_if:nF {#1}{  \__deriv_index:nn {#2} {option}  }
+	\IfNoValueF{#3}{ { \KeyFont - } \meta{#3} }
+	\IfNoValueF{#4}{ { \KeyFont - } \meta{#4} }
+}
+
+\NewDocumentCommand{\keyval}{ s m m }
+{
+	\group_begin:
+	\seq_set_from_clist:Nn \l__deriv_value_seq {#3}
+	\int_compare:nNnTF { \seq_count:N \l__deriv_value_seq } = { 1 }
+	{
+		\KeyFont #2
+		\bool_if:nF {#1}{  \__deriv_index:nn {#2} {option}  }
+		= \ValFont \seq_use:Nn \l__deriv_value_seq {,}
+	}
+	{
+		\KeyFont #2
+		\bool_if:nF {#1}{  \__deriv_index:nn {#2} {option}  }
+		= \ValFont \{ \seq_use:Nn \l__deriv_value_seq {,} \}
+	}
+	\group_end:
+}
+
+\NewDocumentCommand{\val}{ m }
+{
+	{ \ValFont #1 }
+}
+
+\NewDocumentCommand{\CommonFontsize}{ }{ \small }
+
+\NewDocumentCommand{\CommonFontfamily}{ }{ \ttfamily }
+
+\NewDocumentCommand{\CommonFont}{ }{ \CommonFontsize\CommonFontfamily }
+
+\NewDocumentCommand{\PackageFont}{ }{  \small \sffamily  }
+
+\NewDocumentCommand{\KeyFont}{ }{  \CommonFont }
+
+\NewDocumentCommand{\ValFont}{ }{  \CommonFont  }
+
+\NewDocumentCommand{\EksFont}{ }{  \CommonFont  }
+
+\NewDocumentCommand{\OptionFont}{ }{  \CommonFont \color{RoyalGreen}  }
+
+\NewDocumentCommand{\MacroFont}{ }{  \CommonFont \color{RoyalRed}  }
+
+\NewDocumentCommand{\ArgFont}{ }{  \small \color{RoyalBlue}  }
+
+\NewDocumentCommand{\VerbFont}{ }{  \CommonFont  }
+
+\NewDocumentCommand{\pkg}{ s m }
+{
+	\IfBooleanTF{ #1 }
+	{ { \PackageFont #2.sty } }
+	{ { \PackageFont #2 } }
+	
+}
+
+\NewDocumentCommand{\mypackage}{ }
+{
+	\pkg{\pakkenavn}
+}
+
+\NewDocumentCommand{\tsb}{ m }
+{
+	\textsubscript{#1}
+}
+\NewDocumentCommand{\tcf}{ }
+{
+	\textasciicircum
+}
+\seq_new:N \l__low_seq
+
+\NewDocumentCommand{\low}{ O{0,0} m m }
+{
+	\seq_set_from_clist:Nn \l__low_seq {#1}
+	
+	\mskip -\seq_item:Nn \l__low_seq {1} mu
+	\underbracket
+	{
+		\mskip \seq_item:Nn \l__low_seq {1} mu
+		\vphantom{f}
+		#2
+		\mskip \seq_item:Nn \l__low_seq {2} mu
+	}
+	\sb{\text{#3}}
+	\mskip -\seq_item:Nn \l__low_seq {2} mu
+}
+
+\NewDocumentCommand{\ms}{ m }
+{
+	\group_begin:
+	\text
+	{
+		\scriptsize
+		$\langle$
+		\texttt{#1}
+		$\rangle$
+	}
+	\group_end:
+}
+
+\NewDocumentCommand{\uni}{} % Kræver unicode
+{ \textsuperscript{\texttt{U}} }
+
+\NewDocumentCommand{\pdf}{} % Kræver pdflatex
+{ \textsuperscript{\texttt{P}} }
+
+\NewDocumentCommand{\req}{} % Kræver pakke
+{ \textsuperscript{\texttt{R}} }
+
+\NewDocumentCommand{\tex}{}{\texorpdfstring{\hologo{TeX}}{TeX}}
+\NewDocumentCommand{\pdftex}{}{\texorpdfstring{\hologo{pdfTeX}}{pdfTeX}}
+\NewDocumentCommand{\luatex}{}{\texorpdfstring{\hologo{LuaTeX}}{LuaTeX}}
+\NewDocumentCommand{\xetex}{}{\texorpdfstring{\hologo{XeTeX}}{XeTeX}}
+\NewDocumentCommand{\latex}{ t2 t3 }
+{
+	\bool_if:nTF {#1}
+	{  \texorpdfstring{\hologo{LaTeX2e}}{LaTeX2e}  }
+	{
+		\bool_if:nTF {#2}
+		{  \texorpdfstring{\hologo{LaTeX3}}{LaTeX3}  }
+		{  \LaTeX  }
+	}
+}
+
+\NewDocumentCommand{\ket}{ m }
+{
+	\lvert #1 \rangle
+}
+
+\mathitalicsmode=1
+
+\ExplSyntaxOff
+\makeatother
+
+\Pakkenavn{derivative}
+\Titel{The \pakkenavn{} package}
+\Forfatter{Simon Jensen}
+\Email{sjelatex at gmail.com}
+\Dato{2019-07-21}
+\Version{v0.9}
+
+\hypersetup
+{
+	final = true,
+	bookmarksnumbered = true,
+	colorlinks = true,
+	linkcolor = RoyalRed,
+	urlcolor = RoyalBlue,
+	pdfauthor = \forfatter,
+	pdftitle = \titel,
+	pdfencoding = unicode
+}
+
+\listfiles
+
+\setlength{\marginparwidth}{126pt} % 74.68849pt
+
+\makeindex[name = option, title = Index of Options, intoc=true]
+\makeindex[name = macro, title = Index of Commands, intoc=true]
+
+\indexsetup{level = \subsection*, noclearpage = true, toclevel = subsection}
+
+\begin{document}
+
+\forside
+
+\clearpage
+\tableofcontents
+
+\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. An update will be made before the official release explaining what will be changed and what impact this might cause.
+
+This package started as a personnel 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} 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}
+
+\DescribeMacro*{\odv}{ \sarg, \oarg{order}, \marg{function}, \targ{/}, \marg{variable}, \earg{\_,{point\tsb{1}},\tcf,{point\tsb{2}}} }
+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
+
+\begin{definition}
+	\DeclareOdvVariant{\odv}{d}[style-inf=\mathrm]%\marginnote{\pdftex\\\xetex, \luatex}%
+	\DeclareOdvVariant{\odv}{d}[style-inf=\symup]
+\end{definition}
+
+\DescribeArg*{\arg{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
+
+\eks{ \odv{y}{x} ; \odv*{y}{x} }
+
+\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}.
+
+\DescribeArg{\arg{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
+
+\eks{ \odv[2]{y}{x} ; \odv[n]{y}{x} ; \odv[n+2]{y}{x} }
+
+\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.
+
+\DescribeArg{\arg{3}}
+This is the first mandatory argument that typeset the function that is to be differentiated
+
+\eks{ \odv{f(x)}{x} ; \odv{e^{\sin(x)}}{x} } 
+
+\noindent The function is simply typeset in the numerator or next to the fraction.
+
+\DescribeArg{\arg{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
+
+\eks{ \odv{y}{x} ; \odv{y}/{x} }
+
+\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}.
+
+\DescribeArg{\arg{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
+
+\eks{ \odv{f}{x} ; \odv{f}{y} }
+
+\noindent The variable is always typeset in the denominator.
+
+\DescribeArg{\arg{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
+
+\eks{ \odv{y}{x}_{x_1} ; \odv{y}{x}^{x_2} ; \odv{y}{x}_{x_1}^{x_2} ; \odv{y}{x}^{x_2}_{x_1} }
+
+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.
+
+\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}.
+
+\DescribeMacro{\mdv}{ \sarg, \oarg{order}, \marg{function}, \targ{/}, \marg{variable}, \earg{\_,{point\tsb{1}},\tcf,{point\tsb{2}}} }
+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]
+\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)
+\end{equation*}
+
+\DescribeMacro{\fdv}{ \sarg, \oarg{order}, \marg{function}, \targ{/}, \marg{variable}, \earg{\_,{point\tsb{1}},\tcf,{point\tsb{2}}} }
+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}%
+\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
+	,
+\end{equation*}
+respectively.
+
+\DescribeMacro{\adv}{ \sarg, \oarg{order}, \marg{function}, \targ{/}, \marg{variable}, \earg{\_,{point\tsb{1}},\tcf,{point\tsb{2}}} }
+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}
+\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}
+\end{equation*}
+
+\DescribeMacro{\jdv}{ \sarg, \oarg{order}, \marg{function}, \targ{/}, \marg{variable}, \earg{\_,{point\tsb{1}},\tcf,{point\tsb{2}}} }
+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}[add-delims={fun,var}]%\marginnote{\pdftex, \xetex, \luatex}%
+\end{definition}
+
+\noindent which gives
+\begin{equation*}
+	\jdv{f,g,h}{x,y,z}
+\end{equation*}
+
+
+\clearpage	
+\section{Partial derivative}
+
+\DescribeMacro*{\pdv}{ \sarg, \oarg{cs-orders}, \oarg{mixed order}, \marg{function}, \targ{/}, \marg{cs-variables}, \earg{\_,{point\tsb{1}},\tcf,{point\tsb{2}}} }
+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
+
+\begin{definition}
+	\DeclarePdvVariant{\pdv}{\partial}[sep-inf-ord=1, sep-ord-fun=-2]%\marginnote{\pdftex, \xetex, \luatex}%
+\end{definition}
+
+\DescribeArg*{\arg{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
+
+\eks{ \pdv{f}{x,y} ; \pdv*{f}{x,y} }
+
+\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}.
+
+\DescribeArg{\arg{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
+
+\eks{ \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} }
+
+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.
+
+\DescribeArg{\arg{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
+
+\eks{ \pdv[4n+2k, 3k+n]{ f(x,y) }{ x,y } ; \pdv[4n+2k, 3k+n][5(n+k)]{ f(x,y) }{ x,y } }
+
+\noindent This argument is also subject to change, see \cref{consid:RemoveMixedOrder} for more information.
+
+\DescribeArg{\arg{4}}
+This is the first mandatory argument that typeset the function that is to be partially differentiated as shown below
+
+\eks{ \pdv{ f(x,y,z) }{ x, y, z } ; \pdv{ e^x \sin(y) \ln(z) }{ x, y, z } }
+
+\noindent The function is simply typeset in the numerator or next to the fraction.
+
+\DescribeArg{\arg{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
+
+\eks{ \pdv{f}{x,y} ; \pdv{f}/{x,y} }
+
+\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}.
+
+\DescribeArg{\arg{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
+
+\eks{ \pdv{f}{x} ; \pdv{f}{x,y} }
+
+\noindent The variables are typeset in the denominator with a $\partial$ inserted to the left of them.
+
+\DescribeArg{\arg{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
+
+\eks{ \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)} }
+
+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.
+
+\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}.
+
+\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. 
+
+\DescribeMacro{\derivset}{ \marg{derivative}, \oarg{key=value} }
+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.
+
+\DescribeArg{\arg{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.
+
+\DescribeArg{\arg{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}[\marg*{\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.
+
+\subsection{Categories}
+This section seeks to give a detailed description of each category.
+
+\begin{itemize}
+	\item The \key*{style}[\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*{delims}[\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*{scale}[\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*{sep}[\dots][\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*{switch}[\dots] keys serves to change an argument's behaviour by swapping the effect of an optional character's presence.
+	\item The \key*{sort}[\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*{mics}[\dots] keys are miscellaneous keys that does not belong to any of the above categories.
+\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.
+\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.
+
+\subsubsection*{Style}
+\DescribeOption*{style-inf}[\cs{mathnormal}\pdf, \cs{symnormal}\uni]{ !\meta{math-font-style} }
+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.
+
+\DescribeOption{style-frac}[\cs{frac}]{ !\meta{fraction} }
+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.
+
+\DescribeOption{style-frac-/}[\cs{slashfrac}]{ !\meta{fraction} }
+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}$.
+
+\subsubsection*{Scaling}
+\DescribeOption*{scale-eval}[auto]{ auto, none, big, Big, bigg, Bigg }
+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.
+
+\DescribeOption{scale-eval-/}[auto]{ auto, none, big, Big, bigg, Bigg }
+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.
+
+\DescribeOption{scale-fun}[auto]{ auto, none, big, Big, bigg, Bigg }
+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.
+
+\DescribeOption{scale-var}[auto]{ auto, none, big, Big, bigg, Bigg }
+This key sets the size of the delimiters used around the variable. The scaling is used whenever \keyval{misc-add-delims}{fun} is used. The key's default value is set to scale the delimiters automatically.
+
+\DescribeOption{scale-frac}[auto]{ auto, none, big, Big, bigg, Bigg }
+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.
+
+\DescribeOption{scale-frac-/}[auto]{ auto, none, big, Big, bigg, Bigg }
+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.
+
+\subsubsection*{Delimiters}
+\DescribeOption*{delims-eval}[.~\cs{rvert}]{ !\meta{left delimiter}\meta{right delimiter} }
+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.
+
+\DescribeOption{delims-eval-/}[.~\cs{rvert}]{ !\meta{left delimiter}\meta{right delimiter} }
+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.
+
+\DescribeOption{delims-fun}[(~)]{ !\meta{left delimiter}\meta{right delimiter} }
+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.
+
+\DescribeOption{delims-var}[(~)]{ !\meta{left delimiter}\meta{right delimiter} }
+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.
+
+\DescribeOption{delims-frac}[(~)]{ !\meta{left delimiter}\meta{right delimiter} }
+This key sets the left and right delimiters used to around the variable- 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.
+
+\DescribeOption{delims-frac-/}[(~)]{ !\meta{left delimiter}\meta{right delimiter} }
+This key sets the left and right delimiters used to around the variable- 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.
+
+\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{  \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}
+\end{equation*}
+where it have been split into three to give a better overview.
+
+\DescribeOption{sep-inf-ord}[0]{ !\meta{cs-numbers} }
+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}.
+
+\DescribeOption{sep-inf-fun}[0]{ !\meta{cs-numbers} }
+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}.
+
+\DescribeOption{sep-ord-fun}[0]{ !\meta{cs-numbers} }
+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}.
+
+\DescribeOption{sep-inf-var}[0]{ !\meta{cs-numbers} }
+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}.
+
+\DescribeOption{sep-var-ord}[0]{ !\meta{cs-numbers} }
+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}.
+
+\DescribeOption{sep-eval-sb}[0]{ !\meta{cs-numbers} }
+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}.
+
+\DescribeOption{sep-eval-sp}[0]{ !\meta{cs-numbers} }
+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}.
+
+\subsubsection*{Switches}
+\DescribeOption*{switch-*}[false]{ true, false }
+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}),
+
+\eks{ \derivset{\odv}[switch-*=false] \odv{y}{x} ; \derivset{\odv}[switch-*=true] \odv{y}{x} }
+
+\noindent The key's default value is \default.
+
+\DescribeOption{switch-/}[false]{ true, false }
+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}),
+
+\eks{ \derivset{\odv}[switch-/=false] \odv{y}{x} ; \derivset{\odv}[switch-/=true] \odv{y}{x} }
+
+\noindent The key's default value is \default.
+
+\subsubsection*{Miscellaneous}
+\DescribeOption*{ misc-add-delims, misc-remove-delims }{ fun, var, frac }
+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
+
+\eks{\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}}
+
+\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
+
+\eks{\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}}
+
+\noindent These two keys and this local behaviour are subject to change, see \cref{revis:add_remove,consid:add_remove_local} for more information. 
+
+
+\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}
+\DescribeOption*{style-inf}[\cs{mathnormal}\pdf, \cs{symnormal}\uni]{ !\meta{math-font-style} }
+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.
+
+\DescribeOption{style-frac}[\cs{frac}]{ !\meta{fraction} }
+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}.
+
+\DescribeOption{style-frac-/}[\cs{slashfrac}]{ !\meta{fraction} }
+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}$.
+
+\subsubsection*{Scaling}
+\DescribeOption*{scale-eval}[auto]{ auto, none, big, Big, bigg, Bigg }
+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.
+
+\DescribeOption{scale-eval-/}[auto]{ auto, none, big, Big, bigg, Bigg }
+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.
+
+\DescribeOption{scale-fun}[auto]{ auto, none, big, Big, bigg, Bigg }
+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.
+
+\DescribeOption{scale-var}[auto]{ auto, none, big, Big, bigg, Bigg }
+This key sets the size of the delimiters used around the variable. The scaling is used whenever \keyval{misc-add-delims}{fun} is used. The key's default value is set to scale the delimiters automatically.
+
+\DescribeOption{scale-frac}[auto]{ auto, none, big, Big, bigg, Bigg }
+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.
+
+\DescribeOption{scale-frac-/}[auto]{ auto, none, big, Big, bigg, Bigg }
+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.
+
+\subsubsection*{Delimiters}
+\DescribeOption*{delims-eval}[(~)]{ !\meta{left delimiter}\meta{right delimiter} }
+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.
+
+\DescribeOption{delims-eval-/}[(~)]{ !\meta{left delimiter}\meta{right delimiter} }
+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.
+
+\DescribeOption{delims-fun}[(~)]{ !\meta{left delimiter}\meta{right delimiter} }
+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.
+
+\DescribeOption{delims-var}[(~)]{ !\meta{left delimiter}\meta{right delimiter} }
+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.
+
+\DescribeOption{delims-frac}[(~)]{ !\meta{left delimiter}\meta{right delimiter} }
+This key sets the left and right delimiters used to around the variable- 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.
+
+\DescribeOption{delims-frac-/}[(~)]{ !\meta{left delimiter}\meta{right delimiter} }
+This key sets the left and right delimiters used to around the variable- 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.
+
+\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*}
+where it have been split into four to give a better overview.
+
+\DescribeOption{sep-inf-ord}[0]{ !\meta{cs-number} }
+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}.
+
+\DescribeOption{sep-inf-fun}[0]{ !\meta{cs-number} }
+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}.
+
+\DescribeOption{sep-ord-fun}[0]{ !\meta{cs-number} }
+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}.
+
+\DescribeOption{sep-inf-var}[0]{ !\meta{cs-number} }
+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}.
+
+\DescribeOption{sep-var-ord}[0]{ !\meta{cs-number} }
+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}.
+
+\DescribeOption{sep-var-inf}[3]{ !\meta{cs-number} }
+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}.
+
+\DescribeOption{sep-ord-inf}[3]{ !\meta{cs-number} }
+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}.
+
+\DescribeOption{sep-eval-sb}[-4]{ !\meta{cs-number} }
+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}.
+
+\DescribeOption{sep-eval-sp}[-4]{ !\meta{cs-number} }
+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}.
+
+\subsubsection*{Switches}
+\DescribeOption*{switch-*}[false]{ true, false }
+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}),
+
+\eks{ \derivset{\pdv}[switch-/=false] \pdv{y}{x} ; \derivset{\pdv}[switch-/=true] \pdv{y}{x} }
+
+\noindent The key's default value is \default.
+
+\DescribeOption{switch-/}[false]{ true, false }
+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}),
+
+\eks{ \derivset{\pdv}[switch-*=false] \pdv{y}{x} ; \derivset{\pdv}[switch-*=true] \pdv{y}{x} }
+
+\noindent The key's default value is \default.
+
+\subsubsection*{Miscellaneous}
+\DescribeOption*{ misc-add-delims, misc-remove-delims }{ fun, var, frac }
+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
+
+\eks{\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}}
+
+\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
+
+\eks{\derivset{\pdv}[misc-add-delims=var] \pdv*{\pdv{y}{x}}{x}}
+
+\noindent These two keys and this local behaviour are subject to change, see \cref{revis:add_remove,consid:add_remove_local} for more information.
+
+\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}.
+
+\DescribeOption{sort-method}[sign, symbol, abs]{abs, sign, symbol}
+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.
+
+\eks*{\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}}
+
+\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.
+
+\DescribeOption{sort-numerical}[auto]{auto, first, last}
+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
+
+\eks*{\derivset{\pdv}[sort-numerical=first] \pdv[n,2]{f}{x,y}; \derivset{\pdv}[sort-numerical=last] \pdv[-n,2]{f}{x,y}}
+
+\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.
+
+\DescribeOption{sort-sign-reverse}[false]{true, false}
+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.
+
+\DescribeOption{sort-symbol-reverse}[false]{true, false}
+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.
+
+\DescribeOption{sort-abs-reverse}[false]{true, false}
+The sorting algorithm \val{number} 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.
+
+\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}[\marg*{all},\oarg{key=value}].
+
+\DescribeOption*{scale-auto}[leftright]{ leftright, mleftmright\req }
+This package uses \cs{left} and \cs{right} to automatically scale delimiters. The value \val{mleftmright} requires the \pkg{mleftright} package, which makes this package use \cs{mleft} and \cs{mright} instead.
+
+
+\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.
+
+\subsection{Variants of the ordinary derivative} \label{ssec:CreateOdvVariant}
+\DescribeMacro*{\NewOdvVariant, \RenewOdvVariant, \ProvideOdvVariant, \DeclareOdvVariant}{\meta{control-sequence}, \meta{inf-d}, \oarg{key=value}}
+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:
+
+\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.
+	\item \macro{3} is similar to \cs{ProvideDocumentCommand} of the \pkg{xparse} package and will define \arg{1} if it does not have an existing definition. It will not issue any errors.
+	\item \macro{4} is similar to \cs{DeclareDocumentCommand} of the \pkg{xparse} package and will always define the \arg{1} with the new definition regardless of whether it already exists.
+\end{itemize}
+
+\DescribeArg*{\arg{1}}
+The first argument is the macro name of the derivative that is to be defined.
+
+\DescribeArg{\arg{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 argument must be a \emph{single token} thought this is subject to change, see \cref{consid:infd_single_token}.
+
+\DescribeArg{\arg{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.
+
+\subsection{Variants of the partial derivative} \label{ssec:CreatePdvVariant}
+\DescribeMacro{\NewPdvVariant, \RenewPdvVariant, \ProvidePdvVariant, \DeclarePdvVariant}{\meta{control-sequence}, \meta{inf-p}, \oarg{key=value}}
+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:
+
+\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.
+	\item \macro{3} is similar to \cs{ProvideDocumentCommand} of the \pkg{xparse} package and will define \arg{1} if it does not have an existing definition. It will not issue any errors.
+	\item \macro{4} is similar to \cs{DeclareDocumentCommand} of the \pkg{xparse} package and will always define the \arg{1} with the new definition regardless of whether it already exists.
+\end{itemize}
+
+\DescribeArg*{\arg{1}}
+The first argument is the macro name of the derivative that is to be defined.
+
+\DescribeArg{\arg{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}. The argument must be a \emph{single token} thought this is subject to change, see \cref{consid:infd_single_token}.
+
+\DescribeArg{\arg{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.
+
+
+\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.
+
+\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.
+\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.
+
+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 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}
+\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[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
+\begin{equation*}
+	\derivset{\pdv}[sort-method = {symbol,sign,abs}]
+	\pdv[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[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}
+\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
+\begin{equation*}
+	\derivset{\pdv}[sort-method = {sign,symbol}]
+	\pdv[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}
+\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
+\begin{equation*}
+	\derivset{\pdv}[sort-method = symbol]
+	\pdv[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}
+\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.
+
+\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.
+
+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
+\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}
+\end{align*}
+These three options should satisfy every need, but there might come more options, see \cref{consid:sort_numerical}.
+
+\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
+\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}
+\end{align*}
+
+
+\clearpage
+\section{Miscellaneous} 
+
+\subsection{Slashfrac}\label{ssec:slashfrac}
+\DescribeMacro*{\slashfrac}{ \oarg{scale}, \marg{numerator}, \marg{denominator} }
+A text-styled fraction i.e. $\slashfrac{a}{b}$, is commonly used in text-mode. While \macro{\slashfrac}[\marg*{a},\marg*{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.
+
+\DescribeArg{\arg{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}
+
+\eks{\slashfrac[auto]{y_f}{x} ; \slashfrac[none]{y_f}{x} ; \slashfrac[big]{y_f}{x} ; \slashfrac[Big]{y_f}{x} ; \slashfrac[bigg]{y_f}{x} ; \slashfrac[Bigg]{y_f}{x}}
+
+This argument is subject to change, see \cref{consid:slashfrac_opt,consid:slashfrac_def_scale} for more information.
+
+\DescribeArg{\arg{2}}
+This argument typeset the fraction's numerator.
+
+\DescribeArg{\arg{3}}
+This argument typeset the fraction's denominator.
+
+
+\clearpage
+\section{To do} 
+
+\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.
+\end{todo}
+
+\subsection{Future changes}
+The list describes what \emph{will be changed} in the package in a later release.
+\begin{revision}
+	\item A complete rewrite of the options \key*{misc-add-delims} and \key*{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}
+\end{revision}
+
+\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*{order}{\marg{cs-orders}}.
+		\item Such an option should not be possible to be set with \macro*{\derivset} or in the definition of a new derivative (or maybe if one really needs a lot of higher order derivative).
+	\end{itemize}
+	\item With the above consideration, than it would only be natural to remove the mixed order and then have an option \keyval*{mixed-order}{\marg{mixed-order}}. Likewise, it should not be possible to be set with \macro*{\derivset} or in the definition of a new derivative. \label{consid:RemoveMixedOrder}
+	\item Currently \macro*{\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}
+	\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 reason I have not done it 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*{misc-add-delims} and \key*{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 Varaint} should be a single token, e.g. meaning that \macro*{\NewOdvVariant}[\marg*{\cs{myvariant}},\marg*{\cs{partial}\_\cs{mu}}] is not allowed but \macro*{\NewOdvVariant}[\marg*{\cs{myvariant}},\marg*{\marg*{\cs{partial}\_\cs{mu}}}] is. It can easily be change to accept a multi token input. \label{consid:infd_single_token}
+	\item Should I add the option to \key*{sort-numerical}, so that it is treated as a symbolic term instead of a numerical term? \label{consid:sort_numerical}
+	\item Should I add a sorting algorithm that order the terms according to their number (including sign)? \label{consid:sort_number}
+	\item I am considering making the optional argument of \macro*{\slashfrac} into a \oarg{key=value} argument with something like \keyval*{scale}{\marg{scaling}}. \label{consid:slashfrac_opt}
+	\item Should the default scaling for \macro*{\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}
+\end{consideration}
+
+\clearpage
+\addsec{Index}
+Numbers in bold  refer to the page where the entry is defined.
+\printindex[option]
+\printindex[macro]
+
+\end{document}
\ No newline at end of file


Property changes on: trunk/Master/texmf-dist/doc/latex/derivative/derivative.tex
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: trunk/Master/texmf-dist/tex/latex/derivative/derivative.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/derivative/derivative.sty	                        (rev 0)
+++ trunk/Master/texmf-dist/tex/latex/derivative/derivative.sty	2019-07-21 20:50:55 UTC (rev 51696)
@@ -0,0 +1,1337 @@
+% derivative.sty
+% Copyright 2019 Simon Jensen
+% 
+% This work may be distributed and/or modified under the
+% conditions of the LaTeX Project Public License, either version 1.3
+% of this license or (at your option) any later version.
+% The latest version of this license is in
+% http://www.latex-project.org/lppl.txt
+% and version 1.3 or later is part of all distributions of LaTeX
+% version 2005/12/01 or later.
+% 
+% This work has the LPPL maintenance status `maintained'.
+% 
+% The Current Maintainer of this work is Simon Jensen.
+
+\NeedsTeXFormat{LaTeX2e}
+
+\RequirePackage{xparse}[2018/05/09]
+\ProvidesExplPackage{derivative}{2019/07/21}{0.9}{Nice and easy derivatives}
+
+%%%%%  Useful conditionals  %%%%%
+
+\prg_new_conditional:Npnn \__if_novalue_blank:n #1 { T , F , TF }
+{
+	\tl_if_novalue:nTF {#1}
+	{ \prg_return_true: }
+	{
+		\tl_if_blank:nTF {#1}
+		{ \prg_return_true:  }
+		{ \prg_return_false: }
+	}
+}
+
+\prg_new_conditional:Npnn \__if_novalue_blank_or:nn #1 #2 { F, TF }
+{
+	\__if_novalue_blank:nTF {#1}
+	{
+		\__if_novalue_blank:nTF {#2}
+		{ \prg_return_true:  }
+		{ \prg_return_false: }
+	}
+	{ \prg_return_false: }
+}
+
+\prg_new_conditional:Npnn \__show_order:N #1 { T, TF }
+{
+	\quark_if_no_value:NTF #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:  }
+			}
+		}
+	}
+}
+
+\cs_new:Npn \__deriv_case:n #1
+{  \exp:w \__deriv_case_begin:nTF {#1} { } { }  }
+
+\cs_new:Npn \__deriv_case:nT #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}  }
+
+\cs_new:Npn \__deriv_case: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  }
+
+\cs_new:Npn \__deriv_case:w #1#2
+{
+	\bool_if:nTF {#1}
+	{  \__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  }
+
+%%%%%  slash frac  %%%%%
+
+\DeclareDocumentCommand{\slashfrac}{ o m m }
+{
+	\tl_if_novalue:nTF {#1}
+	{ \__deriv_slashfrac_auto:nn {#2} {#3} }
+	{
+		\str_case:nnF {#1}
+		{
+			{ auto } { \__deriv_slashfrac_auto:nn {#2} {#3} }
+			{ none } { \__deriv_slashfrac_none:nn {#2} {#3} }
+		}
+		{ \__deriv_slashfrac_scale:nnn {#1} {#2} {#3} }
+	}
+}
+% numerator , denominator
+\cs_new_protected:Npn \__deriv_slashfrac_auto:nn #1 #2
+{
+	\__deriv_auto_left:n  . \kern-\nulldelimiterspace
+	{#1} \middle/ {#2}
+	\__deriv_auto_right:n . \kern-\nulldelimiterspace
+}
+% numerator , denominator
+\cs_new_protected:Npn \__deriv_slashfrac_none:nn #1 #2
+{
+	{#1} / {#2}
+}
+% scale , numerator , denominator
+\cs_new_protected:Npn \__deriv_slashfrac_scale:nnn #1 #2 #3
+{
+	\cs:w #1 l \cs_end: .
+	{#2} 
+	\cs:w #1   \cs_end: /
+	{#3}
+	\cs:w #1 r \cs_end: .
+}
+
+%%%%%  Variables for settings of odv, pdv and variants  %%%%%
+
+\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_derivset_tl
+
+\seq_new:N \l__deriv_var_seq
+\seq_new:N \l__deriv_rubber_seq
+
+%%%%%  Variables for odv  %%%%%
+
+\seq_new:N \l__deriv_d_variant_seq
+
+\tl_new:N \l__deriv_d_order_tl
+
+%%%%%  Variables for pdv and mixed order (mo)  %%%%%
+
+\seq_new:N \l__deriv_p_variant_seq
+
+\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_p_var_seq
+\seq_new:N \l__deriv_p_order_seq
+\seq_new:N \l__deriv_p_mo_seq
+
+\int_new:N \l__deriv_vmo_int
+
+\tl_new:N \l__deriv_sym_tmpa_tl
+\tl_new:N \l__deriv_num_tmpa_tl
+\tl_new:N \l__deriv_sym_tmpb_tl
+\tl_new:N \l__deriv_num_tmpb_tl
+\tl_new:N \l__deriv_input_tl
+
+\seq_new:N \l__deriv_input_seq
+\seq_new:N \l__deriv_extract_seq
+\seq_new:N \l__deriv_unsorted_seq
+\seq_new:N \l__deriv_sorted_seq
+
+\seq_new:N \l__deriv_symbol_seq
+\seq_new:N \l__deriv_number_seq
+\seq_new:N \l__deriv_rebuild_seq
+
+\int_new:N \l__deriv_tmpa_int
+
+\int_new:N \l__deriv_numerical_int
+\int_new:N \l__deriv_sort_counter_int
+\int_new:N \l__deriv_sort_max_int
+
+\int_new:N \l__deriv_position_int
+\int_new:N \l__deriv_rebuild_int
+
+\regex_const:Nn \c__deriv_pattern_regex { \A([\+\-]?\d*)(.*) }
+
+%%%%%%  Key-val for all  %%%%%%
+
+\keys_define:nn { deriv-all-settings }
+{
+	scale-auto .choice:,
+	scale-auto / leftright .code:n =
+	{
+		\cs_set_eq:NN \__deriv_auto_left:n \left
+		\cs_set_eq:NN \__deriv_auto_right:n \right
+	},
+	scale-auto / mleftmright .code:n =
+	{
+		\cs_set_eq:NN \__deriv_auto_left:n \mleft
+		\cs_set_eq:NN \__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
+{
+	\keys_define:nn { deriv-d-#1 }
+	{
+		style-inf .code:n = { \cs_set_eq:cN { __deriv_#1_style_inf:n } ##1 },
+		
+		style-frac .code:n = { \cs_set_eq:cN { __deriv_#1_style_frac:n } ##1 },
+		style-frac .default:n = { \frac },
+		
+		style-frac-/ .code:n = { \cs_set_eq:cN { __deriv_#1_style_frac_slash:n } ##1 },
+		style-frac-/ .default:n = { \slashfrac },
+		
+		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 },
+		
+		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 },
+		
+		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 },
+		
+		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 = { .\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 }
+	}
+	\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
+{
+	\keys_define:nn { deriv-p-#1 }
+	{
+		style-inf .code:n = { \cs_set_eq:cN { __deriv_#1_style_inf:n } ##1 },
+		
+		style-frac .code:n = { \cs_set_eq:cN { __deriv_#1_style_frac:n } ##1 },
+		style-frac .default:n = { \frac },
+		
+		style-frac-/ .code:n = { \cs_set_eq:cN { __deriv_#1_style_frac_slash:n } ##1 },
+		style-frac-/ .default:n = { \slashfrac },
+		
+		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 },
+		
+		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 },
+		
+		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 },
+		
+		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 }
+	}
+	\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 } }
+	}
+}
+
+\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} }
+	{
+		\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 }
+			}
+		}
+	}
+}
+% dv , key=val clist
+\cs_new_protected:Npn \__deriv_d_set_keys:nn #1 #2
+{
+	\tl_if_novalue:nTF {#2}
+	{
+		\keys_set:nn { deriv-d-#1 }
+		{
+			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
+		}
+	}
+	{ \keys_set:nn { deriv-d-#1 } {#2} }
+}
+% key=val clist
+\cs_new_protected:Npn \__deriv_p_set_keys:nn #1 #2
+{
+	\tl_if_novalue:nTF {#2}
+	{
+		\keys_set:nn { deriv-p-#1 }
+		{
+			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-p-#1 } {#2} }
+}
+% 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  %%%%%
+
+\DeclareDocumentCommand{\NewOdvVariant}{ 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 }
+	}
+	{
+		\deriv_d_preamble:Nnn \l__deriv_dv_tmp_tl {#1} {#3}
+		\deriv_d_define:Vnnn  \l__deriv_dv_tmp_tl { New } {#1} {#2}
+	}
+}
+
+\DeclareDocumentCommand{\RenewOdvVariant}{ 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}
+	}
+	{
+		\msg_error:nnxx { deriv } { command-not-defined }
+		{ \token_to_str:N #1               }
+		{ \token_to_str:N \RenewOdvVariant }
+	}
+}
+
+\DeclareDocumentCommand{\ProvideOdvVariant}{ 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}
+	}
+}
+
+\DeclareDocumentCommand{\DeclareOdvVariant}{ 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}
+}
+
+\cs_new_protected:Npn \deriv_d_preamble:Nnn #1 #2 #3
+{
+	\tl_set:Nx #1 { \cs_to_str:N #2 }
+	\seq_if_in:NVF \l__deriv_d_variant_seq #1
+	{
+		\seq_put_left:NV \l__deriv_d_variant_seq #1
+		\__deriv_d_variables:V #1
+		\__deriv_d_define_keys:V #1
+	}
+	\__deriv_derivset:VV #1 \c_novalue_tl
+	\tl_if_novalue:nF {#3} { \__deriv_derivset:Vn #1 {#3} }
+}
+
+\cs_new_protected:Npn \deriv_d_define:nnnn #1 #2 #3 #4
+{
+	\use:c { #2 DocumentCommand }{#3}{ s o m t/ m !e{\sb^} }
+	{
+	\group_begin:
+		\exp_args:Nnc \bool_xor:nnTF {##4} { l__deriv_#1_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_#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} }
+		}
+	\group_end:
+	}
+}
+
+\DeclareDocumentCommand{\NewPdvVariant}{ 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 }
+	}
+	{
+		\deriv_p_preamble:Nnn \l__deriv_dv_tmp_tl {#1} {#3}
+		\deriv_p_define:Vnnn  \l__deriv_dv_tmp_tl { New } {#1} {#2}
+	}
+}
+
+\DeclareDocumentCommand{\RenewPdvVariant}{ 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}
+	}
+	{
+		\msg_error:nnxx { deriv } { command-already-defined }
+		{ \token_to_str:N #1               }
+		{ \token_to_str:N \RenewPdvVariant }
+	}
+}
+
+\DeclareDocumentCommand{\ProvidePdvVariant}{ 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}
+	}
+}
+
+\DeclareDocumentCommand{\DeclarePdvVariant}{ 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}
+}
+
+\cs_new_protected:Npn \deriv_p_preamble:Nnn #1 #2 #3
+{
+	\tl_set:Nx #1 { \cs_to_str:N #2 }
+	\seq_if_in:NVF \l__deriv_p_variant_seq #1
+	{
+		\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} }
+}
+
+\cs_new_protected:Npn \deriv_p_define:nnnn #1 #2 #3 #4
+{
+	\use:c { #2 DocumentCommand }{#3}{ s o o m t/ m !e{\sb^} }
+	{
+	\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} }
+		}
+	\group_end:
+	}
+}
+% dv
+\cs_new_protected:Npn \__deriv_d_variables:n #1
+{
+	\__deriv_new:nnnn {#1} { scale  } { tl     } { eval, eval_slash, fun, var, frac, frac_slash }
+	\__deriv_new:nnnn {#1} { delims } { tl     } { eval, eval_slash, fun, var, frac, frac_slash }
+	\__deriv_new:nnnn {#1} { sep    } { muskip } { inf_ord, inf_fun, ord_fun, var_ord, inf_var, eval_sb, eval_sp }
+	\__deriv_new:nnnn {#1} { switch } { bool   } { star, slash }
+	\__deriv_new:nnnn {#1} { mics   } { bool   } { fun, var, frac }
+}
+% dv
+\cs_new_protected:Npn \__deriv_p_variables:n #1
+{
+	\__deriv_new:nnnn {#1} { scale  } { tl     } { eval, eval_slash, fun, var, frac, frac_slash }
+	\__deriv_new:nnnn {#1} { delims } { tl     } { eval, eval_slash, fun, var, frac, frac_slash }
+	\__deriv_new:nnnn {#1} { sep    } { muskip } { inf_ord, inf_fun, ord_fun, inf_var, var_ord, var_inf, ord_inf, eval_sb, eval_sp }
+	\__deriv_new:nnnn {#1} { switch } { bool   } { star, slash }
+	\__deriv_new:nnnn {#1} { sort   } { clist  } { method }
+	\__deriv_new:nnnn {#1} { sort   } { tl     } { numerical }
+	\__deriv_new:nnnn {#1} { sort   } { bool   } { sign_reverse, symbol_reverse, abs_reverse }
+	\__deriv_new:nnnn {#1} { mics   } { bool   } { fun, var, frac }
+}
+% dv , sub-category , data-type , 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 #3_new:c \cs_end: { l__deriv_#1_#2_##1_#3 } }
+}
+
+%%%%%  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
+{
+	\__deriv_set_order:Nn \l__deriv_d_order_tl {#3}
+	\__deriv_evaluation_slash:nnnn {#2} {#6} {#7}
+	{
+		\__deriv_fraction_slash:nn {#2}
+		{
+			\use:c { __deriv_#2_style_frac_slash:n }
+			{ \__deriv_d_numerator_nofun:Nn #1 {#2}      }
+			{ \__deriv_d_denominator:Nnn    #1 {#2} {#5} }
+		}
+		
+		\__deriv_function:nn {#2} {#4}
+	}
+}
+% inf , dv , order , function , variable , sb-point , sp-point
+\cs_new_protected:Npn \__deriv_odv_star:Nnnnnnn #1 #2 #3 #4 #5 #6 #7
+{
+	\__deriv_set_order:Nn \l__deriv_d_order_tl {#3}
+	\__deriv_evaluation:nnnn {#2} {#6} {#7}
+	{
+		\__deriv_fraction:nn {#2}
+		{
+			\use:c { __deriv_#2_style_frac:n }
+			{ \__deriv_d_numerator_nofun:Nn #1 {#2}      }
+			{ \__deriv_d_denominator:Nnn    #1 {#2} {#5} }
+		}
+		\__deriv_function:nn {#2} {#4}
+	}
+}
+% inf , dv , order , function , variable , sb-point , sp-point
+\cs_new_protected:Npn \__deriv_odv_slash:Nnnnnnn #1 #2 #3 #4 #5 #6 #7
+{
+	\__deriv_set_order:Nn \l__deriv_d_order_tl {#3}
+	\__deriv_evaluation_slash:nnnn {#2} {#6} {#7}
+	{
+		\__deriv_fraction_slash:nn {#2}
+		{
+			\use:c { __deriv_#2_style_frac_slash:n }
+			{ \__deriv_d_numerator_fun:Nnn #1 {#2} {#4} }
+			{ \__deriv_d_denominator:Nnn   #1 {#2} {#5} }
+		}
+	}
+}
+% inf , dv , order , function , variable , sb-point , sp-point
+\cs_new_protected:Npn \__deriv_odv_none:Nnnnnnn #1 #2 #3 #4 #5 #6 #7
+{
+	\__deriv_set_order:Nn \l__deriv_d_order_tl {#3}
+	\__deriv_evaluation:nnnn {#2} {#6} {#7}
+	{
+		\__deriv_fraction:nn {#2}
+		{
+			\use:c { __deriv_#2_style_frac:n }
+			{ \__deriv_d_numerator_fun:Nnn #1 {#2} {#4} }
+			{ \__deriv_d_denominator:Nnn   #1 {#2} {#5} }
+		}
+	}
+}
+% inf , dv , function
+\cs_new_protected:Npn \__deriv_d_numerator_fun:Nnn #1 #2 #3
+{
+	\__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}
+}
+% inf , dv
+\cs_new_protected:Npn \__deriv_d_numerator_nofun:Nn #1 #2
+{
+	\__deriv_insert_inf:Nn #1 {#2}
+	\__deriv_insert_ord:Nnn \l__deriv_d_order_tl {#2} { inf_ord }
+}
+% inf , dv , variable
+\cs_new_protected:Npn \__deriv_d_denominator:Nnn #1 #2 #3
+{
+	\__deriv_insert_inf:Nn #1 {#2}
+	\__deriv_insert_var_ord:Nnn \l__deriv_d_order_tl {#2} {#3}
+}
+
+%%%%%  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
+{
+	\__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}
+	{
+		\__deriv_fraction_slash:nn {#2}
+		{
+			\use:c { __deriv_#2_style_frac_slash:n }
+			{ \__deriv_p_numerator_nofun:Nn #1 {#2} }
+			{ \__deriv_p_denominator:n {#2} }
+		}
+		\__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
+{
+	\__deriv_preparation:NNNnnnn \l__deriv_p_mo_tl \l__deriv_p_denom_tl #1 {#2} {#3} {#4} {#6}
+	\__deriv_evaluation:nnnn {#2} {#7} {#8}
+	{
+		\__deriv_fraction:nn {#2}
+		{
+			\use:c { __deriv_#2_style_frac:n }
+			{ \__deriv_p_numerator_nofun:Nn #1 {#2} }
+			{ \__deriv_p_denominator:n {#2} }
+		}
+		\__deriv_function:nn {#2} {#5}
+	}
+}
+% 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
+{
+	\__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}
+	{
+		\__deriv_fraction_slash:nn {#2}
+		{
+			\use:c { __deriv_#2_style_frac_slash:n }
+			{ \__deriv_p_numerator_fun:Nnn #1 {#2} {#5} }
+			{ \__deriv_p_denominator:n {#2} }
+		}
+	}
+}
+% 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
+{
+	\__deriv_preparation:NNNnnnn \l__deriv_p_mo_tl \l__deriv_p_denom_tl #1 {#2} {#3} {#4} {#6}
+	\__deriv_evaluation:nnnn {#2} {#7} {#8}
+	{
+		\__deriv_fraction:nn {#2}
+		{
+			\use:c { __deriv_#2_style_frac:n }
+			{ \__deriv_p_numerator_fun:Nnn #1 {#2} {#5} }
+			{ \__deriv_p_denominator:n {#2} }
+		}
+	}
+}% inf , dv , function
+\cs_new_protected:Npn \__deriv_p_numerator_fun:Nnn #1 #2 #3
+{
+	\__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}
+}
+% inf , dv
+\cs_new_protected:Npn \__deriv_p_numerator_nofun:Nn #1 #2
+{
+	\__deriv_insert_inf:Nn #1 {#2}
+	\__deriv_insert_ord:Nnn \l__deriv_p_mo_tl {#2} { inf_ord }
+}
+% dv
+\cs_new_protected:Npn \__deriv_p_denominator:n #1
+{
+	\tl_use:N \l__deriv_p_denom_tl %{ \__deriv_insert_mskip:nn {#1} { var_inf } }
+}
+% 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
+{
+	\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_if_novalue:nTF {#6}
+	{
+		\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}
+	}
+	{  \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
+{
+	\int_set:Nn \l__deriv_vmo_int { \seq_count:N #2 - \seq_count:N #3 }
+	\__deriv_case:nF
+	{
+		{ \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: }
+	}
+	{
+		\int_step_inline:nn { -1 * \l__deriv_vmo_int }
+		{ \seq_pop_right:NN #1 \l__deriv_p_tmpa_tl }
+	}
+}
+% \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
+	{
+		\int_incr:N \l__deriv_tmpa_int
+		\seq_pop_left:NN #2 \l__deriv_p_tmpa_tl
+		\tl_if_blank:nF {##1}
+		{
+			\tl_put_right:Nx #3
+			{
+				\__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}  }
+			}
+		}
+	}
+}
+%%%%%  And the rest of the code  %%%%%
+% inf , dv
+\cs_new:Npn \__deriv_insert_inf:Nn #1 #2
+{
+	\exp_not:n
+	{
+		\use:c { __deriv_#2_style_inf:n }
+		{ \tl_use:N #1 }
+	}
+}
+% dv , function
+\cs_new:Npn \__deriv_insert_fun:Nnn #1 #2 #3
+{
+	\tl_if_blank:nF {#3}
+	{
+		\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}
+	}
+}
+% order, dv , variable
+\cs_new:Npn \__deriv_insert_var_ord: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:Nnn #1 {#2} { var_ord }
+	}
+}
+\cs_new:Npn \__deriv_insert_var_ord_sep: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}
+	}
+}
+% dv , name
+\cs_new:Npn \__deriv_insert_mskip:nn #1 #2
+{
+	\str_if_eq:vnF { l__deriv_#1_sep_#2_muskip } { 0.0mu }
+	{ \exp_args:Nc \mskip { l__deriv_#1_sep_#2_muskip } }
+}
+% order , dv , name
+\cs_new:Npn \__deriv_insert_ord:Nnn #1 #2 #3
+{
+	\__show_order:NT #1
+	{
+		\sp
+		{
+			\__deriv_insert_mskip:nn {#2} {#3}
+			\tl_use:N #1
+		}
+	}
+}
+% order , dv , name
+\cs_new:Npn \__deriv_insert_ord:Nn #1 #2
+{
+	\__show_order:NTF #1
+	{
+		\sp
+		{
+			\__deriv_insert_mskip:nn {#2} { var_ord }
+			\tl_use:N #1
+		}
+		\__deriv_insert_mskip:nn {#2} { ord_inf }
+	}
+	{  \__deriv_insert_mskip:nn {#2} { var_inf }  }
+}
+% 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}
+	}
+	{ #2 }
+}
+% 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 }
+}
+% 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 }
+}
+% dv , sub , sup , code-for-fraction
+\cs_new:Npn \__deriv_evaluation:nnnn #1 #2 #3 #4
+{
+	\__if_novalue_blank_or:nnTF {#2} {#3}
+	{ #4 }
+	{
+		\__deriv_add_delims:nnn {#1} { eval } {#4}
+		\__if_novalue_blank:nF {#2} { \sb{ \__deriv_insert_mskip:nn {#1} { eval_sb } #2 } }
+		\__if_novalue_blank:nF {#3} { \sp{ \__deriv_insert_mskip:nn {#1} { eval_sp } #3 } }
+	}
+}
+% dv , sub , sup , code-for-fraction
+\cs_new:Npn \__deriv_evaluation_slash:nnnn #1 #2 #3 #4
+{
+	\__if_novalue_blank_or:nnTF {#2} {#3}
+	{ #4 }
+	{
+		\__deriv_add_delims:nnn {#1} { eval_slash } {#4}
+		\__if_novalue_blank:nF {#2} { \sb{ \__deriv_insert_mskip:nn {#1} { eval_sb } #2 } }
+		\__if_novalue_blank:nF {#3} { \sp{ \__deriv_insert_mskip:nn {#1} { eval_sp } #3 } }
+	}
+}
+% 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}
+}
+% dv , name
+\cs_new:Npn \__deriv_scale_left:nn #1 #2
+{
+	\exp_args:Nv \str_case:nnF { l__deriv_#1_scale_#2_tl }
+	{
+		{ auto } { \__deriv_scale_auto:Nnnn \__deriv_auto_left:n {#1} {#2} { 1 } }
+		{ none } { \__deriv_scale_none:nnn {#1} {#2} { 1 } }
+	}
+	{ \__deriv_scale_big:nnnm {#1} {#2} { 1 } { l } }
+}
+% 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:nnnm {#1} {#2} { 2 } { r } }
+}
+% left/right , dv , 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
+\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
+\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 } }
+}
+
+%%%%%  Calculation of mixed order  %%%%%
+% mixed-order-tl , mixed-order-seq , dv
+\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_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
+\cs_new_protected:Npn \__deriv_replace:NN #1 #2
+{
+	\tl_set:Nf \l__deriv_input_tl { \seq_use:Nn #2 { , } }
+	\tl_remove_all:Nn \l__deriv_input_tl { ~ }
+	\tl_replace_all:Nnn \l__deriv_input_tl { -- } { , }
+	\tl_replace_all:Nnn \l__deriv_input_tl { - } { ,- }
+	\tl_replace_all:Nnn \l__deriv_input_tl { + } { , }
+	
+	\exp_args:NNV \seq_set_from_clist:Nn #1 \l__deriv_input_tl
+}
+% input-seq
+\cs_new_protected:Npn \__deriv_seq_counting:N #1
+{
+	\seq_clear:N \l__deriv_symbol_seq
+	\seq_clear:N \l__deriv_number_seq
+	
+	\seq_map_inline:Nn #1
+	{
+		\__deriv_extract:NNn \l__deriv_sym_tmpa_tl \l__deriv_num_tmpa_tl {##1}
+		
+		\seq_if_in:NVTF \l__deriv_symbol_seq \l__deriv_sym_tmpa_tl
+		{ \__deriv_update_seq:NN \l__deriv_sym_tmpa_tl \l__deriv_num_tmpa_tl }
+		{ \__deriv_add_to_seq:NN \l__deriv_sym_tmpa_tl \l__deriv_num_tmpa_tl }
+	}
+}
+% 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
+	\seq_pop_right:NN \l__deriv_extract_seq #1
+	\seq_pop_right:NN \l__deriv_extract_seq #2
+	
+	\exp_args:NV \str_case:nn #2
+	{
+		{   } { \tl_set:Nn #2 {  1 } }
+		{ - } { \tl_set:Nn #2 { -1 } }
+	}
+}
+% unsorted-seq
+\cs_new:Npn \__deriv_combine_seq:N #1
+{
+	\seq_clear:N #1
+	\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}
+	}
+}
+% unsorted-seq , num-tl, seq-item
+\cs_new_protected:Npn \__deriv_eval_term:NNn #1 #2 #3
+{
+	\__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 }               }
+	}
+	{ \seq_put_left:No #1 { #2 #3 } }
+}
+% 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
+\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
+\cs_new:Npn \__deriv_get_position:NN #1 #2
+{
+	\int_zero:N #1
+	\seq_map_inline:Nn \l__deriv_symbol_seq
+	{
+		\int_incr:N #1
+		\exp_args:NV \tl_if_eq:nnT #2 {##1} { \seq_map_break: }
+	}
+}
+% num-seq , position-int , num-tl
+\cs_new_protected:Npn \__deriv_rebuild_seq:NNN #1 #2 #3
+{	
+	\int_zero:N  \l__deriv_rebuild_int
+	\seq_clear:N \l__deriv_rebuild_seq
+	
+	\seq_map_inline:Nn #1
+	{
+		\int_incr:N \l__deriv_rebuild_int
+		\int_compare:nNnTF \l__deriv_rebuild_int = #2
+		{
+			\tl_set:Nf \l__deriv_num_tmpb_tl { \int_eval:n { ##1 + #3 } }
+			\seq_put_right:NV \l__deriv_rebuild_seq \l__deriv_num_tmpb_tl
+		}
+		{ \seq_put_right:Nn \l__deriv_rebuild_seq {##1} }
+	}
+	\seq_set_eq:NN #1 \l__deriv_rebuild_seq
+}
+% sorted-seq , unsorted-seq , dv
+\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 } }
+	
+	\seq_sort:Nn #2
+	{
+		\__deriv_extract:NNn \l__deriv_sym_tmpa_tl \l__deriv_num_tmpa_tl {##1}
+		\__deriv_extract:NNn \l__deriv_sym_tmpb_tl \l__deriv_num_tmpb_tl {##2}
+		\int_zero:N \l__deriv_sort_counter_int
+		\__deriv_sort_method:n {#3}
+	}
+	\seq_set_eq:NN #1 #2
+}
+% dv
+\cs_new_protected:Npn \__deriv_sort_method:n #1
+{
+	\int_incr:N \l__deriv_sort_counter_int
+	
+	\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}  }
+	}
+}
+% dv
+\cs_new_protected:Npn \__deriv_sort_sign:n #1
+{
+	\__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 } }
+	}
+	{
+		\int_compare:nNnTF { \l__deriv_sort_counter_int } = { \l__deriv_sort_max_int }
+		{ \sort_return_same:             }
+		{ \__deriv_sort_method:n {#1} }
+	}
+}
+% dv
+\cs_new_protected:Npn \__deriv_sort_symbol:n #1
+{
+	\__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:nNnTF { \l__deriv_sort_counter_int } = { \l__deriv_sort_max_int }
+		{ \sort_return_same:             }
+		{ \__deriv_sort_method:n {#1} }
+	}
+}
+% dv
+\cs_new_protected:Npn \__deriv_sort_abs:n #1
+{
+	\__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: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
+	\bool_xor:nnTF { l__deriv_#1_sort_#2_reverse_bool } { \str_if_eq_p:nn {#3} { same } }
+	{ \sort_return_same:    }
+	{ \sort_return_swapped: }
+}
+% mixed-order-tl , sorted-seq , numerical-term, dv
+\cs_new_protected:Npn \__deriv_output:NNNn #1 #2 #3 #4
+{
+	\tl_set:Nf #1 { \seq_use:Nn #2 { + } }
+	
+	\int_compare:nNnF {#3} = { 0 }
+	{
+		\tl_if_empty:NTF #1
+		{  \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 + }  }
+			}
+			{
+				\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_replace_all:Nnn #1 { +- } { - }
+	\tl_if_empty:NT #1 { \tl_set:Nn #1 { 0 } }
+}
+
+%%%%%  Generate variants  %%%%%
+
+\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 }
+
+%%%%%   Messages   %%%%%
+
+\msg_new:nnnn { deriv } { command-already-defined }
+{ Command~'#1'~already~defined! }
+{
+	You~have~used~#2~with~a~command~that~already~has~a~definition. \\
+	The~existing~definition~of~'#1'~will~not~be~altered.
+}
+
+\msg_new:nnnn { deriv } { derivative-not-defined }
+{ Derivative~'#1'~is~not~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.
+}
+
+%%%%%  Declaring derivatives  %%%%%
+
+\bool_lazy_or:nnT { \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]
+	
+}
+\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]
+}
+%\derivset{all}
+
+\endinput


Property changes on: trunk/Master/texmf-dist/tex/latex/derivative/derivative.sty
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Modified: trunk/Master/tlpkg/bin/tlpkg-ctan-check
===================================================================
--- trunk/Master/tlpkg/bin/tlpkg-ctan-check	2019-07-21 16:36:17 UTC (rev 51695)
+++ trunk/Master/tlpkg/bin/tlpkg-ctan-check	2019-07-21 20:50:55 UTC (rev 51696)
@@ -224,7 +224,7 @@
     datetime2-usorbian datetime2-welsh
     dblfloatfix dccpaper dcpic de-macro decimal decorule dehyph dehyph-exptl
     dejavu dejavu-otf
-    delim delimseasy delimset delimtxt denisbdoc dhua
+    delim delimseasy delimset delimtxt denisbdoc derivative dhua
     diadia diagbox diagmac2 dialogl diagnose dice dichokey
     dickimaw dictsym diffcoeff digiconfigs dijkstra din1505
     dinat dinbrief dingbat directory dirtree dirtytalk disser ditaa dithesis

Modified: trunk/Master/tlpkg/tlpsrc/collection-mathscience.tlpsrc
===================================================================
--- trunk/Master/tlpkg/tlpsrc/collection-mathscience.tlpsrc	2019-07-21 16:36:17 UTC (rev 51695)
+++ trunk/Master/tlpkg/tlpsrc/collection-mathscience.tlpsrc	2019-07-21 20:50:55 UTC (rev 51696)
@@ -60,6 +60,7 @@
 depend delim
 depend delimseasy
 depend delimset
+depend derivative
 depend diffcoeff
 depend digiconfigs
 depend dijkstra

Added: trunk/Master/tlpkg/tlpsrc/derivative.tlpsrc
===================================================================


More information about the tex-live-commits mailing list