% derivative.tex
% Copyright 2019-2020 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[unicode]{hyperref}
\RequirePackage[nameinlink]{cleveref}

\makeatletter
\ExplSyntaxOn

\tl_new:N \pakkenavn
\tl_new:N \titel
\tl_new:N \email
\tl_new:N \forfatter
\tl_new:N \dato
\tl_new:N \version

\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 \email { \tl_trim_spaces:n { #1 } } }
\NewDocumentCommand{\Dato}     { m }{ \tl_gset:Nf \dato  { \tl_trim_spaces:n { #1 } } }
\NewDocumentCommand{\Version}  { m }{ \tl_gset:Nf \version  { \tl_trim_spaces:n { #1 } } }

\NewDocumentCommand{\mypackage}{ } {  \pkg{\pakkenavn}  }

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\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} \email \par }
	\end{minipage}
	\hfill
	\begin{minipage}[t]{0.5\textwidth}
		\centering
		\textsl{Released:} \par
		{ \color{RoyalRed} v\version \par }
		{ \color{RoyalRed}  \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
}

\lstset
{
	tabsize = 1,
	columns = fullflexible,
	basicstyle = \ttfamily\upshape\small,
	escapechar = \%,
	alsoletter =  {\\,-},
	keywords = [0]{style-inf, mics-add-delims,sep-inf-ord,sep-ord-fun},
	keywordstyle = [0]\__mydoc_option_font:,
	keywords = [1]{\\odv, \\mdv, \\fdv, \\adv, \\jdv, \\pdv, \\NewOdvVariant, \\RenewOdvVariant, \\ProvideOdvVariant, \\DeclareOdvVariant, \\NewPdvVariant, \\RenewPdvVariant, \\ProvidePdvVariant, \\DeclarePdvVariant},
	keywordstyle = [1]\__mydoc_function_font:,
	commentstyle = \footnotesize,
	frame = single,
	xleftmargin=3.4pt,
	xrightmargin=3.4pt,
	rulesep = 0pt,
	backgroundcolor = \color{RoyalLightGray},
	rulecolor = \color{RoyalGray}
}

\lstnewenvironment{definition}{\normalmarginpar}{\reversemarginpar}

\newlist{todo}{enumerate}{1}
\setlist[todo]{label=(\roman{todoi}), ref=\thesubsection(\roman{todoi})}
\crefname{todoi}{todo}{todos}

\newlist{changes}{enumerate}{1}
\setlist[changes]{label=(\roman{changesi}), ref=\thesubsection(\roman{changesi})}
\crefname{changesi}{change}{changes}

\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@ }}

\NewDocumentCommand{\marginnote}{ m }
{
	\leavevmode
	\marginline{\leavevmode \ttfamily\upshape\small \color{RoyalDarkGray} \tl_trim_spaces:n {#1} }
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\NewDocumentCommand{\ket}{ m }
{
	\lvert #1 \rangle
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\NewDocumentCommand{\pkg}{ m }
{
	\group_begin:
	\sffamily \upshape \small #1
	\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{\xmark}{}
{
	\textcolor{red}{\ensuremath{\mathord{\mathpalette\bigcdot@{}}}}
}
\NewDocumentCommand{\cmark}{}
{
	\textcolor{green}{\ensuremath{\checkmark}}
}

\NewDocumentCommand{\answer}{ m m }
{
	#1
	\textbf{Conclusion:}
	\c_space_tl
	\group_begin:
	\slshape
	#2
	\group_end:
}

\newcommand*{\bigcdot@scalefactor}{1.25}
\newcommand*{\bigcdot@widthfactor}{1.15}
\newcommand*{\bigcdot@}[2]{
	% #1: math style
	% #2: unused
	\sbox0{$#1\vcenter{}$}% math axis
	\sbox2{$#1\vectimes\m@th$}
	\hbox to \bigcdot@widthfactor\wd2{
		\hfil
		\raise\ht0\hbox{
			\scalebox{\bigcdot@scalefactor}{
				\lower\ht0\hbox{$#1\vectimes\m@th$}
			}
		}
		\hfil
	}
}










\tl_new:N \l__mydoc_ch_version_tl
\tl_new:N \l__mydoc_ch_date_tl
\tl_new:N \l__mydoc_ch_change_tl

\bool_new:N \l__mydoc_ch_beta_bool
\bool_new:N \l__mydoc_ch_change_bool

\keys_define:nn { mydoc/changelog }
{
	version .tl_set:N = \l__mydoc_ch_version_tl,
	version .default:n = \c_novalue_tl,
	
	date .tl_set:N = \l__mydoc_ch_date_tl,
	date .default:n = \c_novalue_tl,
	
	beta .bool_set:N = \l__mydoc_ch_beta_bool,
	beta .default:n = {false}
}

\let\mydoc_item:\item

\DeclareDocumentCommand{\item}{ }
{
	\mydoc_item:
	\bool_if:NT \l__mydoc_ch_change_bool
	{
		\tl_use:N \l__mydoc_ch_change_tl
		\bool_set_false:N \l__mydoc_ch_change_bool
	}
}

\DeclareDocumentEnvironment{change}{ o }
{
	\IfNoValueTF{#1}
	{  \keys_set:nn { mydoc/changelog } { version, date, beta     }  }
	{  \keys_set:nn { mydoc/changelog } { version, date, beta, #1 }  }
	
	\mydoc_change_set:
	\mydoc_change_begin:
}
{
	\mydoc_change_end:
}

\cs_new_protected:Npn \mydoc_change_set:
{
	\bool_set_true:N \l__mydoc_ch_change_bool
	\tl_set:Nn \l__mydoc_ch_change_tl
	{
		\leavevmode
		\marginline
		{
			\upshape \scriptsize \ttfamily
			%\leavevmode
			\null\vspace{-3.5\baselineskip}\null
			\tabular[t]{ r }
			\toprule
			v\tl_use:N \l__mydoc_ch_version_tl
			\\
			\tl_use:N \l__mydoc_ch_date_tl
			\bool_if:NT \l__mydoc_ch_beta_bool
			{  \\ \midrule \color{RoyalRed} Beta  }
			\\ \bottomrule
			\endtabular
		}
		\ignorespaces
	}
}

\cs_new_protected:Npn \mydoc_change_begin:
{
	\itemize
}

\cs_new_protected:Npn \mydoc_change_end:
{
	\enditemize
	\let\item\mydoc_item:
}

\NewDocumentEnvironment{changelog}{ }
{
	\mydoc_ch_begin:
}
{
	\mydoc_ch_end:
}

\cs_new_protected:Npn \mydoc_ch_begin:
{
}

\cs_new_protected:Npn \mydoc_ch_end:
{
}

\tl_new:N \l__mydoc_number_tl
\tl_new:N \l_mydoc_index_item_tl
\tl_new:N \l_mydoc_index_subitem_tl
\tl_new:N \l_mydoc_index_entry_tl

\seq_new:N \l__mydoc_macro_arg_seq

\seq_new:N \l__mydoc_group_seq
\seq_new:N \l__mydoc_type_seq
\seq_new:N \l__mydoc_function_seq
\seq_new:N \g__mydoc_syntax_seq
\seq_new:N \l__deriv_earg_seq

\int_new:N \l__mydoc_earg_int
\int_new:N \l__mydoc_function_int
\int_new:N \l__mydoc_option_int

\bool_new:N \l__mydoc_number_bool

\tl_set:Nn \l__mydoc_number_tl {0123456789}

\seq_new:N \l__mydoc_example_seq
\int_new:N \g__mydoc_example_int

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\cs_new_protected:Npn \mydoc_define_vars_keys:nnnn #1 #2 #3 #4
{
	\seq_set_from_clist:Nn \l__mydoc_group_seq {#4}
	\seq_map_inline:Nn \l__mydoc_group_seq
	{
		\mydoc_define_var:nnnn {#1} {#2} {#3} {##1}
		\mydoc_define_key:nnnn {#1} {#2} {#3} {##1}
	}
}

\cs_new_protected:Npn \mydoc_define_var:nnnn #1 #2 #3 #4
{  \use:c { #3_new:c } { #2__mydoc_#1_#4_#3 }  }

\cs_new_protected:Npn \mydoc_define_key:nnnn #1 #2 #3 #4
{
	\str_if_eq:nnTF {#2} { g }
	{  \keys_define:nn { mydoc/#1 } { #4 .#3_#2set:c = { #2__mydoc_#1_#4_#3 } }  }
	{  \keys_define:nn { mydoc/#1 } { #4 .#3_set:c = { #2__mydoc_#1_#4_#3 } }  }
}

%\cs_new_protected:Npn \mydoc_define_inital:nnn #1 #2 #3
%{  \keys_define:nn { mydoc/#1 } { #3 .initial:n = {#2} }  }

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\cs_new_protected:Npn \mydoc_set_keys:nn #1 #2
{
	\keys_set:nn { mydoc/#1 } {#2}
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\cs_new_protected:Npn \mydoc_define_font_i:n #1
{
	\mydoc_define_vars_keys:nnnn {#1} { l } { tl } { colour, family, shape, size }
	
	\cs_new_protected:cpn { __mydoc_#1_font: }
	{
		\color    { \use:c { l__mydoc_#1_colour_tl } }
		\tl_use:c { l__mydoc_#1_family_tl }
		\tl_use:c { l__mydoc_#1_shape_tl  }
		\tl_use:c { l__mydoc_#1_size_tl   }
	}
}

\cs_new_protected:Npn \mydoc_define_font_ii:n #1
{
	\mydoc_define_vars_keys:nnnn {#1} { l } { tl   } { colour, family, shape, size }
	\mydoc_define_vars_keys:nnnn {#1} { l } { bool } { colourb, familyb, shapeb, sizeb }
	
	\cs_new_protected:cpn { __mydoc_#1_font: }
	{
		\bool_if:cT { l__mydoc_#1_colourb_bool } {  \color    { \use:c { l__mydoc_#1_colour_tl } }  }
		\bool_if:cT { l__mydoc_#1_familyb_bool } {  \tl_use:c { l__mydoc_#1_family_tl }  }
		\bool_if:cT { l__mydoc_#1_shapeb_bool  } {  \tl_use:c { l__mydoc_#1_shape_tl  }  }
		\bool_if:cT { l__mydoc_#1_sizeb_bool   } {  \tl_use:c { l__mydoc_#1_size_tl   }  }
	}
}

\cs_new_protected:Npn \mydoc_define_index:n #1
{
	\mydoc_define_vars_keys:nnnn {#1} { l } { bool } { index }
	\mydoc_define_vars_keys:nnnn {#1} { l } { bool } { definition }
}

\cs_new_protected:Npn \mydoc_define_default:n #1
{
	\mydoc_define_vars_keys:nnnn {#1} { g } { clist } { default }
	\mydoc_define_vars_keys:nnnn {#1} { l } { tl    } { sepa    }
	\mydoc_define_vars_keys:nnnn {#1} { l } { tl    } { sepb    }
	\mydoc_define_vars_keys:nnnn {#1} { l } { tl    } { sepc    }
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\cs_new_protected:Npn \mydoc_define_type:nn #1 #2
{
	\seq_set_from_clist:Nn \l__mydoc_type_seq {#2}
	\seq_map_inline:Nn \l__mydoc_type_seq
	{
		\str_case:nn {##1}
		{
			{ font_i  } { \mydoc_define_font_i:n  {#1} }
			{ font_ii } { \mydoc_define_font_ii:n {#1} }
			{ index   } { \mydoc_define_index:n   {#1} }
			{ default } { \mydoc_define_default:n {#1} }
		}
	}
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\mydoc_define_type:nn { function } { font_i, index   }
\mydoc_define_type:nn { macro    } { font_i, index   }
\mydoc_define_type:nn { syntax   } { font_i          }
\mydoc_define_type:nn { argument } { font_i,         }
\mydoc_define_type:nn { arg      } { font_i,         }
\mydoc_define_type:nn { option   } { font_i, index   }
\mydoc_define_type:nn { key      } { font_i, index   }
\mydoc_define_type:nn { values   } { font_i, default }
\mydoc_define_type:nn { val      } { font_i          }
\mydoc_define_type:nn { example  } { font_i          }
\mydoc_define_type:nn { marg     } { font_ii         }
\mydoc_define_type:nn { narg     } { font_ii         }
\mydoc_define_type:nn { oarg     } { font_ii         }
\mydoc_define_type:nn { targ     } { font_ii         }
\mydoc_define_type:nn { meta     } { font_ii         }
\mydoc_define_type:nn { cs       } { font_ii         }

\mydoc_set_keys:nn { function } { colour = RoyalRed,   family = \ttfamily, shape = \upshape, size = \small, index = true, definition = true }
\mydoc_set_keys:nn { macro    } { colour = black,      family = \ttfamily, shape = \upshape, size = \small, index = true, definition = false }
\mydoc_set_keys:nn { syntax   } { colour = black,      family = \rmfamily, shape = \upshape, size = \small }
\mydoc_set_keys:nn { argument } { colour = RoyalBlue,  family = \rmfamily, shape = \upshape, size = \small }
\mydoc_set_keys:nn { arg      } { colour = black,      family = \rmfamily, shape = \upshape, size = \small }
\mydoc_set_keys:nn { option   } { colour = RoyalGreen, family = \ttfamily, shape = \upshape, size = \small, index = true, definition = true }
\mydoc_set_keys:nn { key      } { colour = black,      family = \ttfamily, shape = \upshape, size = \small, index = true, definition = false }
\mydoc_set_keys:nn { values   } { colour = black,      family = \ttfamily, shape = \upshape, size = \small, default = \c_novalue_tl, sepa = { ,~}, sepb = { ,~}, sepc = { ,~} }
\mydoc_set_keys:nn { val      } { colour = black,      family = \ttfamily, shape = \upshape, size = \small }
\mydoc_set_keys:nn { example  } { colour = black,      family = \ttfamily, shape = \upshape, size = \small }
\mydoc_set_keys:nn { marg     } { colour = black,      family = \ttfamily, shape = \upshape, size = \small, colourb = true, familyb = true, shapeb = true, sizeb = true }
\mydoc_set_keys:nn { narg     } { colour = black,      family = \ttfamily, shape = \upshape, size = \small, colourb = true, familyb = true, shapeb = true, sizeb = true }
\mydoc_set_keys:nn { oarg     } { colour = black,      family = \ttfamily, shape = \upshape, size = \small, colourb = true, familyb = true, shapeb = true, sizeb = true }
\mydoc_set_keys:nn { targ     } { colour = black,      family = \ttfamily, shape = \upshape, size = \small, colourb = true, familyb = true, shapeb = true, sizeb = true }
\mydoc_set_keys:nn { meta     } { colour = black,      family = \rmfamily, shape = \slshape, size = \small, colourb = true, familyb = true, shapeb = true, sizeb = true }
\mydoc_set_keys:nn { cs       } { colour = black,      family = \rmfamily, shape = \upshape, size = \small, colourb = true, familyb = true, shapeb = true, sizeb = true }

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\prg_new_protected_conditional:Npnn \mydoc_if_int:n #1 { T, F, TF }
{
	\tl_map_inline:Nn {#1}
	{
		\tl_if_in:NnTF \l__mydoc_number_tl {##1}
		{ \bool_set_true:N \l__mydoc_number_bool }
		{ \tl_map_break:n { \bool_set_false:N \l__mydoc_number_bool } }
	}
	\bool_if:NTF \l__mydoc_number_bool
	{ \prg_return_true:  }
	{ \prg_return_false: }
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\cs_new_protected:Npn \mydoc_vspace:n #1
{
	\vspace{#1\baselineskip}
}

\cs_new_protected:Npn \mydoc_margin:n #1
{
	\leavevmode
	\marginline
	{
		\leavevmode
		#1
	}
	\ignorespaces
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\cs_new_protected:Npn \__mydoc_function_begin:n #1
{
	\par
	\bool_if:NF {#1} {  \mydoc_vspace:n { 0.3 }  }
	\@afterindentfalse \@afterheading
}

\cs_new_protected:Npn \__mydoc_function_end:
{
	\seq_gclear:N \g__mydoc_syntax_seq
	\par \noindent \ignorespacesafterend
}

\cs_new_protected:Npn \__mydoc_function_margin:n #1
{
	\seq_set_from_clist:Nn \l__mydoc_function_seq {#1}
	\int_zero:N \l__mydoc_function_int
	
	\mydoc_margin:n
	{
		\__mydoc_function_font:
		\seq_map_inline:Nn \l__mydoc_function_seq
		{
			\int_incr:N \l__mydoc_function_int
			\mydoc_cs_to_str:N ##1
			\mydoc_index_cs:Nnn ##1 { function } { macro }
			\int_compare:nNnF { \l__mydoc_function_int } = { \seq_count:N \l__mydoc_function_seq }
			{  \\  }
		}
	}
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\cs_new_protected:Npn \__mydoc_syntax_begin:
{  \ignorespaces  }

\cs_new_protected:Npn \mydoc_syntax:n #1
{
	\seq_gset_from_clist:Nn \g__mydoc_syntax_seq {#1}
	
	\__mydoc_syntax_font:
	\seq_use:Nn \g__mydoc_syntax_seq { }
}

\cs_new_protected:Npn \__mydoc_syntax_end:
{  \par \mydoc_vspace:n { 0.2 } \noindent \ignorespacesafterend  }

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\cs_new_protected:Npn \__mydoc_argument_begin:n #1
{
	\par
	\bool_if:NF {#1} {  \mydoc_vspace:n { 0.3 }  }
	\@afterindentfalse \@afterheading
}

\cs_new_protected:Npn \__mydoc_argument_end:
{
	\par\noindent\ignorespacesafterend
}

\cs_new_protected:Npn \__mydoc_argument_margin:n #1
{
	\mydoc_margin:n
	{
		\mydoc_set_keys:nn { marg     } { colourb = false, familyb = false, shapeb = false, sizeb = false }
		\mydoc_set_keys:nn { narg     } { colourb = false, familyb = false, shapeb = false, sizeb = false }
		\mydoc_set_keys:nn { oarg     } { colourb = false, familyb = false, shapeb = false, sizeb = false }
		\mydoc_set_keys:nn { targ     } { colourb = false, familyb = false, shapeb = false, sizeb = false }
		\mydoc_set_keys:nn { meta     } { colourb = false, familyb = true,  shapeb = true,  sizeb = false }
		\mydoc_set_keys:nn { cs       } { colourb = false, familyb = false, shapeb = false, sizeb = false }
		\__mydoc_argument_font:
		\mydoc_if_int:nTF {#1}
		{  \seq_item:Nn \g__mydoc_syntax_seq {#1}  }
		{  #1                                      }
	}
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\cs_new_protected:Npn \__mydoc_option_begin:n #1
{
	\par
	\bool_if:NF {#1} {  \mydoc_vspace:n { 0.3 }  }
	\@afterindentfalse \@afterheading
}

\cs_new_protected:Npn \__mydoc_option_end:
{
	\seq_clear:N \l__mydoc_option_seq
	\par \noindent \ignorespacesafterend
}

\cs_new_protected:Npn \__mydoc_option_margin:n #1
{
	\seq_set_from_clist:Nn \l__mydoc_option_seq {#1}
	\int_zero:N \l__mydoc_option_int
	
	\mydoc_margin:n
	{
		\__mydoc_option_font:
		\seq_map_inline:Nn \l__mydoc_option_seq
		{
			\int_incr:N \l__mydoc_option_int
			##1
			\mydoc_index_key:nnn {##1} { option } { option }
			\int_compare:nNnF { \l__mydoc_option_int } = { \seq_count:N \l__mydoc_option_seq }
			{  \\  }
		}
	}
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\cs_new_protected:Npn \__mydoc_values_begin:
{  \ignorespaces  }

\cs_new_protected:Npn \mydoc_values:n #1
{
	\seq_gset_from_clist:Nn \g__mydoc_values_seq  {#1}
	
	\__mydoc_values_font:
	\seq_use:Nn \g__mydoc_values_seq { ,~}
	
	\exp_args:Nf \tl_if_novalue:nF { \clist_item:Nn \g__mydoc_values_default_clist { 1 } }
	{
		\hfill
		\mydoc_clist_use:n { values }
	}
}

\cs_new_protected:Npn \mydoc_clist_use:n #1
{
	\clist_use:cnnn { g__mydoc_#1_default_clist }
	{ \tl_use:c { l__mydoc_#1_sepa_tl } }
	{ \tl_use:c { l__mydoc_#1_sepb_tl } }
	{ \tl_use:c { l__mydoc_#1_sepc_tl } }
}

\cs_new_protected:Npn \__mydoc_values_end:
{  \par \mydoc_vspace:n { 0.2 } \noindent \ignorespacesafterend  }

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\DeclareDocumentEnvironment{example}{ s o b }
{  \__mydoc_example_begin:nn {#1} {#3}  }
{  \__mydoc_example_end:                }

\cs_new_protected:Npn \__mydoc_example_begin:nn #1 #2
{
	\seq_set_split:Nnn \l__deriv_example_seq { \\ } {#2}
	\bool_if:nTF {#1}
	{
		\center \tabular{ @{} c @{} }
		\__mydoc_example_content:Nnn \l__deriv_example_seq { \\[0.5em] } { \qquad }
	}
	{
		\center \tabular{ @{} r c l @{} }
		\__mydoc_example_content:Nnn \l__deriv_example_seq { & } { $ & $ }
	}
}

\cs_new_protected:Npn \__mydoc_example_content:Nnn #1 #2 #3
{
	\int_gzero:N \g__mydoc_example_int
	\seq_map_inline:Nn #1
	{
		\int_gincr:N \g__mydoc_example_int
		\__mydoc_example_font:
		\__mydoc_print:n {##1}
		#2
		$\Longrightarrow #3 \displaystyle ##1 $
		\int_compare:nNnF { \g__mydoc_example_int } = { \seq_count:N #1 }
		{  \\ \addlinespace[0.5em]  }
	}
}

\cs_new_protected:Npn \__mydoc_example_end:
{
	\endtabular
	\endcenter
}

\tl_new:N \l__mydoc_print_tmp_tl
\cs_new_protected:Npn \__mydoc_print:n #1
{
	\tl_set:Nn \l__mydoc_print_tmp_tl {#1}
	\regex_replace_all:nnN { . } { \c{string} \0 } \l__mydoc_print_tmp_tl
	\tl_use:N \l__mydoc_print_tmp_tl
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\DeclareDocumentEnvironment{function}{ s o m }
{
	\tl_if_novalue:nF {#2} { \mydoc_set_keys:nn { function } {#2} }
	\__mydoc_function_begin:n  {#1}
	\__mydoc_function_margin:n {#3}
}
{
	\__mydoc_function_end:
}

\DeclareDocumentEnvironment{syntax}{ o b }
{
	\tl_if_novalue:nF {#1} { \mydoc_set_keys:nn { syntax } {#1} }
	\__mydoc_syntax_begin:
	\mydoc_syntax:n {#2}
}
{
	\__mydoc_syntax_end:
}

\DeclareDocumentEnvironment{argument}{ s o m }
{
	\tl_if_novalue:nF {#2} { \mydoc_set_keys:nn { argument } {#2} }
	\__mydoc_argument_begin:n  {#1}
	\__mydoc_argument_margin:n {#3}
}
{
	\__mydoc_argument_end:
}

\DeclareDocumentEnvironment{option}{ s o m }
{
	\tl_if_novalue:nF {#2} { \mydoc_set_keys:nn { option } {#2} }
	\__mydoc_option_begin:n  {#1}
	\__mydoc_option_margin:n {#3}
}
{
	\__mydoc_option_end:
}

\DeclareDocumentEnvironment{values}{ o b }
{
	\tl_if_novalue:nF {#1} { \mydoc_set_keys:nn { values } {#1} }
	\__mydoc_values_begin:
	\mydoc_values:n {#2}
}
{
	\__mydoc_values_end:
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\DeclareDocumentCommand{\default}{ s O{values} }
{
	\group_begin:
	\mydoc_default:nn {#1} {#2}
	\group_end:
}

\cs_new_protected:Npn \mydoc_default:nn #1 #2
{
	\bool_if:nTF {#1}
	{  \clist_use:cnnn { g__mydoc_#2_default_clist } {~and~} { ,~} {~and~}  }
	{  \clist_use:cn   { g__mydoc_#2_default_clist } { ,~}                  }
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\DeclareDocumentCommand{\macro}{ o m o }
{
	\group_begin:
	\tl_if_novalue:nF {#1} { \mydoc_set_keys:nn { macro } { #1 } }
	\mydoc_macro:nn {#2} {#3}
	\group_end:
}

\cs_new_protected:Npn \mydoc_macro:nn #1 #2
{
	\__mydoc_macro_font:
	\mydoc_if_int:nTF {#1}
	{
		\tl_set:Nx \l__mydoc_marg_tl { \seq_item:Nn \l__mydoc_function_seq {#1}  }
		\mydoc_cs_to_str:x { \seq_item:Nn \l__mydoc_function_seq {#1} }
		\exp_args:NV \mydoc_index_cs:Nnn \l__mydoc_marg_tl { macro } { macro }
	}
	{
		\mydoc_cs_to_str:N #1
		\mydoc_index_cs:Nnn #1 { macro } { macro }
	}
	\tl_if_novalue:nF {#2}
	{
		\seq_set_from_clist:Nn \l__mydoc_macro_arg_seq {#2}
		\seq_map_function:NN \l__mydoc_macro_arg_seq \mydoc_arg:n
	}
}

\DeclareDocumentCommand{\arg}{ o m }
{
	\group_begin:
	\mydoc_arg:n {#2}
	\group_end:
}

\cs_new_protected:Npn \mydoc_arg:n #1
{
	\__mydoc_arg_font:
	\mydoc_if_int:nTF {#1}
	{  \seq_item:Nn \g__mydoc_syntax_seq {#1}  }
	{  #1                                      }
}

\DeclareDocumentCommand{\key}{ o m }
{
	\group_begin:
	\tl_if_novalue:nF {#1} { \mydoc_set_keys:nn { key } {#1} }
	\mydoc_key:n {#2}
	\group_end:
}

\AtBeginDocument{
	\DeclareDocumentCommand{\val}{ o m }
	{
		\group_begin:
		\tl_if_novalue:nF {#1} { \mydoc_set_keys:nn { val } {#1} }
		\mydoc_val:n {#2}
		\group_end:
	}
}
\DeclareDocumentCommand{\keyval}{ o m m }
{
	\group_begin:
	\tl_if_novalue:nF {#1} { \mydoc_set_keys:nn { key } {#1} }
	\mydoc_keyval:nn {#2} {#3}
	\group_end:
}

\cs_new_protected:Npn \mydoc_key:n #1
{
	\__mydoc_key_font:
	#1
	\mydoc_index_key:nnn {#1} { key } { option }
}

\cs_new_protected:Npn \mydoc_val:n #1
{
	\__mydoc_key_font:
	#1
}

\cs_new_protected:Npn \mydoc_keyval:nn #1 #2
{
	\group_begin:
	\mydoc_key:n {#1}
	=
	\mydoc_val:n {#2}
	\group_end:
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\cs_new_protected:Npn \mydoc_index_cs:Nnn #1 #2 #3
{
	\tl_set:Nf \l_mydoc_index_item_tl { \cs_to_str:N #1 }
	\tl_set:Nx \l_mydoc_index_entry_tl { \cstostr{#1} }
	
	\bool_if:cT  { l__mydoc_#2_index_bool }
	{
		\bool_if:cTF { l__mydoc_#2_definition_bool }
		{  \mydoc_index:VVnn \l_mydoc_index_item_tl \l_mydoc_index_entry_tl {#3} { textbf     }  }
		{  \mydoc_index:VVnn \l_mydoc_index_item_tl \l_mydoc_index_entry_tl {#3} { textnormal }  }
	}
}

\cs_new_protected:Npn \mydoc_index_key:nnn #1 #2 #3
{
	\seq_set_split:Nnn \l__mydoc_index_seq { - } {#1}
	\tl_set:Nx \l_mydoc_index_item_tl { \seq_item:Nn \l__mydoc_index_seq {1} }
	\tl_set:Nx \l_mydoc_index_subitem_tl {#1}
	\tl_set:Nx \l_mydoc_index_entry_tl   {#1}
	
	\bool_if:cT  { l__mydoc_#2_index_bool }
	{
		\bool_if:cTF { l__mydoc_#2_definition_bool }
		{  \mydoc_index:VVVnn \l_mydoc_index_item_tl \l_mydoc_index_subitem_tl \l_mydoc_index_entry_tl {#3} { textbf     }  }
		{  \mydoc_index:VVVnn \l_mydoc_index_item_tl \l_mydoc_index_subitem_tl \l_mydoc_index_entry_tl {#3} { textnormal }  }
	}
}

\cs_new_protected:Npn \mydoc_index:nnnn #1 #2 #3 #4
{
	\index[#3]{#1@\protect{#2}|#4}
}

\cs_new_protected:Npn \mydoc_index:nnnnn #1 #2 #3 #4 #5
{
	\index[#4]{#1!#2@\protect{#3}|#5}
}
\cs_generate_variant:Nn \mydoc_index:nnnnn { VVV }
\cs_generate_variant:Nn \mydoc_index:nnnn  { VV  }

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\DeclareDocumentCommand{\tsb}{ m }{ \textsubscript{#1} }

\DeclareDocumentCommand{\meta}{ m }
{
	\ensuremath{\langle}
	\group_begin:
	\__mydoc_meta_font:
	#1
	\group_end:
	\ensuremath{\rangle}
}

\DeclareDocumentCommand{\marg}{ m }
{
	\group_begin:
	\mydoc_marg:n {#1}
	\group_end:
}
\DeclareDocumentCommand{\narg}{ m }
{
	\group_begin:
	\mydoc_narg:n {#1}
	\group_end:
}
\DeclareDocumentCommand{\oarg}{ m }
{
	\group_begin:
	\mydoc_oarg:n {#1}
	\group_end:
}
\DeclareDocumentCommand{\earg}{ m }
{
	\group_begin:
	\mydoc_earg:n {#1}
	\group_end:
}
\DeclareDocumentCommand{\targ}{ m }
{
	\group_begin:
	\mydoc_targ:n {#1}
	\group_end:
}
\DeclareDocumentCommand{\sarg}{ }
{
	\group_begin:
	\mydoc_sarg:
	\group_end:
}
\DeclareDocumentCommand{\cs}{ m }
{
	\group_begin:
	\mydoc_cs:n {#1}
	\group_end:
}

\cs_new:Npn \mydoc_marg:n #1
{
	\__mydoc_marg_font:
	\mydoc_arg_delim_format:n { \{ }
	\meta{#1}
	\mydoc_arg_delim_format:n { \} }
}

\cs_new:Npn \mydoc_narg:n #1
{
	\__mydoc_narg_font:
	\mydoc_arg_delim_format:n { \{ }
	#1
	\mydoc_arg_delim_format:n { \} }
}

\cs_new:Npn \mydoc_oarg:n #1
{
	\__mydoc_oarg_font:
	\mydoc_arg_delim_format:n { [ }
	\meta{#1}
	\mydoc_arg_delim_format:n { ] }
}

\cs_new:Npn \mydoc_earg:n #1
{
	\seq_set_from_clist:Nn \l__deriv_earg_seq {#1}
	
	\int_zero:N \l__mydoc_earg_int
	\seq_map_inline:Nn \l__deriv_earg_seq
	{
		\int_incr:N \l__mydoc_earg_int
		\int_if_odd:nTF \l__mydoc_earg_int
		{  \mydoc_arg_delim_format:n {##1}  }
		{  \mydoc_marg:n {##1}              }
	}
}

\cs_new:Npn \mydoc_targ:n #1
{
	\__mydoc_targ_font:
	\mydoc_arg_delim_format:n {#1}
}

\cs_new:Npn \mydoc_sarg:
{  \mydoc_targ:n { * }  }

\cs_new:Npn \mydoc_cs:n #1
{
	\__mydoc_cs_font:
	\mydoc_arg_delim_format:n { \\#1 }
}

\cs_new:Npn \mydoc_arg_delim_format:n #1
{
	\group_begin:
	\ttfamily \char` #1
	\group_end:
}

\DeclareDocumentCommand{\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
}

\DeclareDocumentCommand{\ms}{ m }
{
	\group_begin:
	\text
	{
		\scriptsize
		$\langle$
		\texttt{#1}
		$\rangle$
	}
	\group_end:
}

\cs_new_protected:Npn \mydoc_cs_to_str:N #1
{  \char` \\ \cs_to_str:N #1  }

\cs_new_protected:Npn \mydoc_cs_to_str:n #1
{  \char` \\ \cs_to_str:N #1  }
\cs_generate_variant:Nn \mydoc_cs_to_str:n { x }

\DeclareDocumentCommand{\cstostr}{ m }
{  \mydoc_cs_to_str:N #1 }

\ExplSyntaxOff
\makeatother

\Pakkenavn{derivative}
\Titel{The \pakkenavn{} package}
\Forfatter{Simon Jensen}
\Email{sjelatex@gmail.com}
\Dato{2019/02/03}
\Version{0.97}

\RequirePackage{derivative}[\dato]
	\derivset{all}[scale-auto = mleftmright]

\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}

\def\indexspace{}

\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. The next update, version \texttt{v1.0}, will contain the changes specified in \cref{sec:todo}.
	
	This package started as a personal package a few years ago that I used in various projects. Firstly, it was written in \tex{} and \latex, which gave rise to various errors as the complexity of the package grew larger and ended up as a spaghetti code. Therefore, the code was rewritten into the \latex3 language and may now be easily maintained. Originally this package was written because there did not exist any great package for derivatives. It was first much later that I discovered the \pkg{diffcoeff} package, which does a good job. However, at this time, I had already written much of the code with no documentation. 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}
	
	\begin{function}*{\odv}
		\begin{syntax}
			\sarg, \oarg{order}, \marg{function}, \targ{/}, \marg{variable}, \earg{\_, point\tsb{1}, \^, point\tsb{2}}
		\end{syntax}
		The ordinary derivative \macro{1} is defined with a set of mandatory and optional arguments that either typeset specific parts or changing the style of the derivative. In this package, the ordinary derivative is defined with an upright lowercase d, because it is used by many nowadays books, as
		
		\begin{definition}
			\DeclareOdvVariant{\odv}{d}[style-inf=\mathrm]%\marginnote{\pdftex\\\xetex, \luatex}%
			\DeclareOdvVariant{\odv}{d}[style-inf=\symup]
		\end{definition}
		
		\begin{argument}*{1}
			The first argument of \macro{1} is an optional star that determines where the function is typeset; either in the numerator of the fraction or next to the fraction. Using the option \keyval{switch-*}{false}, the function is typeset in the numerator when the star is absent, and next to the fraction when the star is present as shown below
			
			\begin{example}
				\odv{y}{x} \\
				\odv*{y}{x}
			\end{example}
			
			\noindent The effect of the star's presence can be switched around using \keyval{switch-*}{true} i.e. the equations in the above example are exchanged, as described in \cref{ssec:odv_options}.
		\end{argument}
		
		\begin{argument}{2}
			The second argument is optional and is written inside square brackets. This argument is used to set the order of differentiation as seen below
			
			\begin{example}
				\odv[2]{y}{x} \\
				\odv[n]{y}{x} \\
				\odv[n+2]{y}{x}
			\end{example}
			
			\noindent The order may be a number, a symbol and a combination hereof, because it is simply typeset there. This is different from how the partial derivative's mixed order is typeset, which is computed. The order \textit{is not} automatically sorted as the mixed order for the partial derivative. This argument is subject to change, see \cref{consid:order2keyval} for more information.
		\end{argument}
		
		\begin{argument}{3}
			This is the first mandatory argument that typeset the function that is to be differentiated
			
			\begin{example}
				\odv{f(x)}{x} \\
				\odv{e^{\sin(x)}}{x}
			\end{example}
			
			\noindent The function is simply typeset in the numerator or next to the fraction.
		\end{argument}
		
		\begin{argument}{4}
			The fourth argument is an optional slash written \emph{between the function and the variable} and determines which fraction style the derivative is typeset with, as described in \cref{ssec:odv_options}. Using the option \keyval{switch-/}{false} and the package's default settings, the derivative is typeset with \cs{frac} when the slash is absent, and \cs{slashfrac}\footnote{which is a macro defined by the package, see \cref{ssec:slashfrac} for more information.\label{foot:sfrac}} when the slash is present, as shown below
			
			\begin{example}
				\odv{y}{x} \\
				\odv{y}/{x}
			\end{example}
			
			\noindent As for the star argument, the effect of the slash's presence can be switched around using \keyval{switch-/}{true} i.e. the equations in the above example are exchanged, as described in \cref{ssec:odv_options}.
		\end{argument}
		
		\begin{argument}{5}
			This is the second and final mandatory argument, which purpose is to typeset the variable in which the function is differentiated with respect to as shown below
			
			\begin{example}
				\odv{f}{x} \\
				\odv{f}{y}
			\end{example}
			
			\noindent The variable is always typeset in the denominator.
		\end{argument}
		
		\begin{argument}{6}
			This is the last optional argument that specifies the point(s) of evaluation. It is an \emph{e-type} argument in the \pkg{xparse} language and given as \verb|e{_^}|. This means that the subscript \verb|_| and superscript \verb|^| accepts an argument given in braces. Moreover, the order of \verb|_| and \verb|^| is independent as shown below
			
			\begin{example}
				\odv{y}{x}_{x_1} \\
				\odv{y}{x}^{x_2} \\
				\odv{y}{x}_{x_1}^{x_2} \\
				\odv{y}{x}^{x_2}_{x_1}
			\end{example}
			
			The common way to specify the point of evaluation is using the subscript argument. If needed, the second point of evaluation can be specified with the superscript argument.
		\end{argument}
		
	\end{function}
	
	\subsection{Variants}
	This package offers four variants of the ordinary derivative: Material derivative \macro{\mdv}, functional derivative \macro{\fdv}, the average rate of change \macro{\adv} and the Jacobian \macro{\jdv}. A unique feature of this package, is that you can define your own variants of the ordinary derivative as described in \cref{ssec:CreateOdvVariant}.
	
	\begin{function}{\mdv}
		\begin{syntax}
			\sarg, \oarg{order}, \marg{function}, \targ{/}, \marg{variable}, \earg{\_, point\tsb{1}, \^, point\tsb{2}}
		\end{syntax}
		The material derivative is used in some branches of physics (e.g. thermodynamic, fluid dynamic etc.). It is only natural for a physics student as me to define such a variant, that used an upright uppercase D. In this package, the material derivative is defined as
		
		\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*}
	\end{function}
	
	\begin{function}{\fdv}
		\begin{syntax}
			\sarg, \oarg{order}, \marg{function}, \targ{/}, \marg{variable}, \earg{\_, point\tsb{1}, \^, point\tsb{2}}
		\end{syntax}
		The functional derivative is used in the calculus of variation and uses a lowercase delta. With the package's default settings, it will use an italic delta. In this package, the functional derivative is defined as
		
		\begin{definition}
			\DeclareOdvVariant{\fdv}{\delta}%\marginnote{\pdftex, \xetex, \luatex}%
		\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.
	\end{function}
	
	\begin{function}{\adv}
		\begin{syntax}
			\sarg, \oarg{order}, \marg{function}, \targ{/}, \marg{variable}, \earg{\_, point\tsb{1}, \^, point\tsb{2}}
		\end{syntax}
		The average rate of change is defined to use an upright uppercase delta with the packages default settings. In this package, the average rate of change is defined as
		
		\begin{definition}
			\DeclareOdvVariant{\adv}{\Delta}[style-inf=\mathrm]%\marginnote{\pdftex\\\xetex, \luatex}%
			\DeclareOdvVariant{\adv}{\Delta}
		\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*}
	\end{function}
	
	\begin{function}{\jdv}
		\begin{syntax}
			\sarg, \oarg{order}, \marg{function}, \targ{/}, \marg{variable}, \earg{\_, point\tsb{1}, \^, point\tsb{2}}
		\end{syntax}
		The Jacobian is defined to use an italic partial differential with the package's default settings. Also a pair of parentheses is automatically inserted around the function and variable. In this package, the Jacobian is defined as
		
		\begin{definition}
			\DeclareOdvVariant{\jdv}{\partial}[misc-add-delims={fun,var}]%\marginnote{\pdftex, \xetex, \luatex}%
		\end{definition}
		
		\noindent which gives
		\begin{equation*}
		\jdv{f,g,h}{x,y,z}
		\end{equation*}
	\end{function}
	
	
	
	
	
	
	\clearpage	
	\section{Partial derivative}
	
	\begin{function}*{\pdv}
		\begin{syntax}
			\sarg, \oarg{cs-orders}, \oarg{mixed order}, \marg{function}, \targ{/}, \marg{cs-variables}, \earg{\_,point\tsb{1},\^,point\tsb{2}}
		\end{syntax}
		The partial derivative \macro{1} is defined with a set of mandatory and optional arguments that either typeset specific parts or changing the style of the derivative. In this package, the partial derivative is defined with an italic partial differential as
		
		\begin{definition}
			\DeclarePdvVariant{\pdv}{\partial}[sep-inf-ord=1, sep-ord-fun=-2]%\marginnote{\pdftex, \xetex, \luatex}%
		\end{definition}
		
		\begin{argument}*{1}
			The first argument of \macro{1} is an optional star that determines where the function is typeset; either in the numerator of the fraction or next to the fraction. Using the
			option \keyval{switch-*}{false}, the function is typeset in the numerator when the star is absent, and next to the fraction when the star is present as shown below
			
			\begin{example}
				\pdv{f}{x,y} \\
				\pdv*{f}{x,y}
			\end{example}
			
			\noindent The effect of the star's presence can be switched around using \keyval{switch-*}{true} i.e. the equations in the above example are exchanged, as described in \cref{ssec:pdv_options}.
		\end{argument}
		
		\begin{argument}{2}
			The second argument is optional and is written inside square brackets. This argument is used to set the order of differentiation for each of the variables and should be given in a comma-separated list e.g. \texttt{[1,2,3]} as shown below
			
			\begin{example}
				\pdv[2,3]{f}{x,y} \\
				\pdv[\beta,a,n+2a]{f}{x,y,z} \\
				\pdv[2,n^2,n^2-1]{f}{x,y,z}
			\end{example}
			
			The orders may consist numbers, symbols and a combination hereof. Notice, that the mixed order is automatically calculated and sorted based on the variables orders by the package. See \cref{ssec:pdv_options,ssec:overall_order} for more information. This argument is subject to change, see \cref{consid:order2keyval} for more information.
		\end{argument}
		
		\begin{argument}{3}
			If you, unfortunately, come to the conclusion, that you are unsatisfied with how the package typeset the mixed order or if it gives a wrong result, then you can overwrite it with this argument. The use of this argument completely bypass the automatic calculation and sorting done by the package, and simply typeset the mixed order as you wrote it as shown below
			
			\begin{example}
				\pdv[4n+2k, 3k+n]{ f(x,y) }{ x,y } \\
				\pdv[4n+2k, 3k+n][5(n+k)]{ f(x,y) }{ x,y }
			\end{example}
			
			\noindent This argument is also subject to change, see \cref{consid:RemoveMixedOrder} for more information.
		\end{argument}
		
		\begin{argument}{4}
			This is the first mandatory argument that typeset the function that is to be partially differentiated as shown below
			
			\begin{example}
				\pdv{ f(x,y,z) }{ x, y, z } \\
				\pdv{ e^x \sin(y) \ln(z) }{ x, y, z }
			\end{example}
			
			\noindent The function is simply typeset in the numerator or next to the fraction.
		\end{argument}
		
		\begin{argument}{5}
			The fifth argument is an optional slash written \emph{between the function and the variables} and determines which fraction style the derivative is typeset with, as described in \cref{ssec:pdv_options}. Using the option \keyval{switch-/}{false} and the package's default settings, the derivative is typeset with \cs{frac} when the slash is absent and \cs{slashfrac}\footref{foot:sfrac} when the slash is present, as shown below
			
			\begin{example}
				\pdv{f}{x,y} \\
				\pdv{f}/{x,y}
			\end{example}
			
			\noindent As for the star argument, the effect of the slash's presence can be switched around using \keyval{switch-/}{true} i.e. the equations in the above example are exchanged, as described in \cref{ssec:pdv_options}.
		\end{argument}
		
		\begin{argument}{6}
			This is the second and final mandatory argument, which purpose is to typeset the variables in which the function is partially differentiated with respect to. The variables are given in a comma-separated list e.g. \texttt{\{x, y, z\}}, as shown below
			
			\begin{example}
				\pdv{f}{x} \\
				\pdv{f}{x,y}
			\end{example}
			
			\noindent The variables are typeset in the denominator with a $\partial$ inserted to the left of them.
		\end{argument}
		
		\begin{argument}{7}
			This is the last optional argument that specifies the point(s) of evaluation or variables held constant.
			It is an \emph{e-type} argument in the \pkg{xparse} language and given as \verb|e{_^}|. This means that the
			subscript \verb|_| and superscript \verb|^| accepts an argument given in braces. Moreover, the order
			of \verb|_| and \verb|^| is independent as shown below
			
			\begin{example}
				\pdv{f}{x,y}_{(x_1,y_1)} \\
				\pdv{f}{x,y}^{(x_2,y_2)} \\
				\pdv{f}{x,y}_{(x_1,y_1)}^{(x_2,y_2)} \\
				\pdv{f}{x,y}^{(x_2,y_2)}_{(x_1,y_1)}
			\end{example}
			
			The subscript argument is commonly used as the point of evaluation or variables held constant. If needed, the superscript argument may be used for the second point of evaluation.
		\end{argument}
	\end{function}
	
	\subsection{Variants}
	This package does not define any variants of the partial derivative. However, a unique feature of this package, is that you can define your own variants of the partial derivative as described in \cref{ssec:CreatePdvVariant}.
	
	
	
	
	
	
	\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. 
	
	\begin{function}{\derivset}
		\begin{syntax}
			\marg{derivative}, \oarg{key=value}
		\end{syntax}
		The package options can be set either in the preamble or in the document using the \macro{1} command. The options may also be set when defining a new derivative. Currently, there is no other way to set the options however this is subject to change, see \cref{consid:order2keyval} for more information.
		
		\begin{argument}{1}
			A mandatory argument that determines which derivative the \emph{key=value} pairs is assigned to, where the allowed \meta{main-category} are the derivatives defined by the packages and you, see \cref{ssec:CreateOdvVariant,ssec:CreatePdvVariant}. The special value \texttt{all} is also allowed, which gives access to the options that applies to \textit{all} derivatives.
		\end{argument}
		
		\begin{argument}{2}
			This optional argument accepts its input as a comma-separated list of \emph{key=value} pairs. Leaving out \arg{2} sets the options to the packages default settings for the chosen \arg{1} e.g. \macro{\derivset}[\narg{\macro{\odv}}] sets the options for the ordinary derivative to the packages default settings. This argument is subject to change, see \cref{consid:DerivsetOptional} for more information.
		\end{argument}
	\end{function}
	
	\subsection{Categories}
	This section seeks to give a detailed description of each category.
	
	\begin{itemize}
		\item The \key[index=false]{style-\meta{\dots}} keys sets either the font style or the fraction style of \meta{\dots}. The font styles \cs{mathnormal}/\cs{symnormal} and \cs{mathrm}/\cs{symup} are commonly used in literature. The fraction style can be either \cs{frac}, \cs{dfrac}, \cs{tfrac}, \cs{sfrac}\req{}, \cs{slashfrac}\footref{foot:sfrac} and many more.
		\item The \key[index=false]{delims-\meta{\dots}} keys sets the delimiters used around the \meta{\dots}. The Rule of Two applies here: \enquote{Always two there are, no more, no less. A left and a right delimiter}. The allowed delimiters are those that can be scaled with \cs{left}, \cs{big} etc.
		\item The \key[index=false]{scale-\meta{\dots}} keys sets the size of the \meta{\dots}'s delimiters. The values \texttt{big}, \texttt{Big}, \texttt{bigg}, and \texttt{Bigg} are self-explanatory and internally a left and right version are used e.g. \cs{bigl} and \cs{bigr}. The value \texttt{none} inserts the delimiters (except periods) unscaled. While the value \texttt{auto} scales the delimiters automatically using \cs{left} and \cs{right}.
		\item The \key[index=false]{sep-\meta{\dots}-\meta{\dots}} keys inserts math space between \meta{\dots} and \meta{\dots} using \cs{mskip}. These keys accepts a comma-separated list of numbers \texttt{\{x,y,z\}} that are internally used to form the syntax \texttt{x mu plus y mu minus z mu}.
		\item The \key[index=false]{switch-\meta{\dots}} keys serves to change an argument's behaviour by swapping the effect of an optional character's presence.
		\item The \key[index=false]{sort-\meta{\dots}} keys deals with the sorting algorithm behind the mixed order, where you can choose the sorting method that suits you best. These keys are unique to the partial derivative and variants of it.
		\item The \key[index=false]{mics-\meta{\dots}} keys are miscellaneous keys that does not belong to any of the above categories.
	\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}
	
	\begin{option}*{style-inf}
		\begin{values}[default = { \cs{mathnormal}\pdf, \cs{symnormal}\uni }]
			\meta{math-font-style}
		\end{values}
		The font style of the infinitesimal for the chosen derivative is set by this key. The default font style is \default*. If an upright font is preferred then \cs{mathrm}\pdf{} and \cs{symup}\uni{} could be used, or if an italic font then \cs{mathnormal}\pdf{} and \cs{symit}\uni.
	\end{option}
	
	\begin{option}{style-frac}
		\begin{values}[default = \cs{frac}]
			\meta{fraction}
		\end{values}
		The derivative uses the fraction set by this key whenever \keyval{switch-/}{false} and the slash argument is absent. The key's default value is the usual fraction \default.
	\end{option}
	
	\begin{option}{style-frac-/}
		\begin{values}[default = \cs{slashfrac}]
			\meta{fraction}
		\end{values}
		The derivative uses the fraction set by this key whenever \keyval{switch-/}{false} and the slash argument is present. The key's default value is a text-styled fraction \default\footref{foot:sfrac} i.e. on the form $\derivset{\odv}[style-frac-/=\slashfrac, switch-/=false] \odv{y}/{x}$.
	\end{option}
	
	\subsubsection*{Scaling}
	
	\begin{option}*{scale-eval}
		\begin{values}[default = auto]
			auto, none, big, Big, bigg, Bigg
		\end{values}
		This key sets the size of the delimiters used for the point of evaluation. This scaling is used whenever \keyval{switch-/}{false} and the slash argument is absent. The key's default value is set to scale the delimiters automatically.
	\end{option}
	
	\begin{option}{scale-eval-/}
		\begin{values}[default = auto]
			auto, none, big, Big, bigg, Bigg
		\end{values}
		This key sets the size of the delimiters used for the point of evaluation. This scaling is used whenever \keyval{switch-/}{false} and the slash argument is present. The key's default value is set to scale the delimiters automatically.
	\end{option}
	
	\begin{option}{scale-fun}
		\begin{values}[default = auto]
			auto, none, big, Big, bigg, Bigg
		\end{values}
		This key sets the size of the delimiters used around the function. The scaling is used whenever \keyval{misc-add-delims}{fun} is used. The key's default value is set to scale the delimiters automatically.
	\end{option}
	
	\begin{option}{scale-var}
		\begin{values}[default = auto]
			auto, none, big, Big, bigg, Bigg
		\end{values}
		This key sets the size of the delimiters used around the variable. The scaling is used whenever \keyval{misc-add-delims}{var} is used. The key's default value is set to scale the delimiters automatically.
	\end{option}
	
	\begin{option}{scale-frac}
		\begin{values}[default = auto]
			auto, none, big, Big, bigg, Bigg
		\end{values}
		This key sets the size of the delimiters used for around the fraction. This scaling is used whenever \keyval{switch-/}{false}, the slash argument is absent and \keyval{misc-add-delims}{frac} is used. The key's default value is set to scale the delimiters automatically.
	\end{option}
	
	\begin{option}{scale-frac-/}
		\begin{values}[default = auto]
			auto, none, big, Big, bigg, Bigg
		\end{values}
		This key sets the size of the delimiters used for around the fraction. This scaling is used whenever \keyval{switch-/}{false}, the slash argument is present and \keyval{misc-add-delims}{frac} is used. The key's default value is set to scale the delimiters automatically.
	\end{option}
	
	\subsubsection*{Delimiters}
	
	\begin{option}*{delims-eval}
		\begin{values}[default = .~\cs{rvert}]
			\meta{left delimiter}\meta{right delimiter}
		\end{values}
		This key sets the left and right delimiters used to indicate the point of evaluation. These delimiters are inserted whenever \keyval{switch-/}{false} and the slash argument is absent. The default left and right delimiters is a period\footnote{which doesn't output anything.\label{foot:period_no_output}} and a vertical bar, respectively.
	\end{option}
	
	\begin{option}{delims-eval-/}
		\begin{values}[default = .~\cs{rvert}]
			\meta{left delimiter}\meta{right delimiter}
		\end{values}
		This key sets the left and right delimiters used to indicate the point of evaluation. These delimiters are inserted whenever \keyval{switch-/}{false} and the slash argument is present. The default left and right delimiters is a period\footref{foot:period_no_output} and a vertical bar, respectively.
	\end{option}
	
	\begin{option}{delims-fun}
		\begin{values}[default = (~)]
			\meta{left delimiter}\meta{right delimiter}
		\end{values}
		This key sets the left and right delimiters used to around the function and these are inserted whenever \keyval{misc-add-delims}{fun} is used. The key's default left and right delimiters are a left and a right parenthesis, respectively.
	\end{option}
	
	\begin{option}{delims-var}
		\begin{values}[default = (~)]
			\meta{left delimiter}\meta{right delimiter}
		\end{values}
		This key sets the left and right delimiters used to around the variable and these are inserted whenever \keyval{misc-add-delims}{var} is used. The key's default left and right delimiters are a left and a right parenthesis, respectively.
	\end{option}
	
	\begin{option}{delims-frac}
		\begin{values}[default = (~)]
			\meta{left delimiter}\meta{right delimiter}
		\end{values}
		This key sets the left and right delimiters used to around the fraction in the derivative e.g. $\derivset{\odv}[misc-add-delims=frac] \odv*{y}{x}$ These delimiters are inserted whenever \keyval{switch-/}{false}, the slash argument is absent and \keyval{misc-add-delims}{frac} is used. The key's default left and right delimiters are a left and a right parenthesis, respectively.
	\end{option}
	
	\begin{option}{delims-frac-/}
		\begin{values}[default = (~)]
			\meta{left delimiter}\meta{right delimiter}
		\end{values}
		This key sets the left and right delimiters used to around the fraction in the derivative e.g. $\derivset{\odv}[misc-add-delims=frac] \odv*{y}/{x}$ These delimiters are inserted whenever \keyval{switch-/}{false}, the slash argument is present and \keyval{misc-add-delims}{frac} is used. The key's default left and right delimiters are a left and a right parenthesis, respectively.
	\end{option}
	
	\subsubsection*{Math spacing}
	The options in this subsection inserts extra horizontal math space. The below equation illustrates where the space is inserted
	\begin{equation*}
	\frac{  \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 has been split into three to give a better overview.
	
	\begin{option}{sep-inf-ord}
		\begin{values}[default = 0]
			\meta{cs-numbers}
		\end{values}
		This key sets the math space that is inserted in the infinitesimal's power left to the order. It is only inserted when the order is different from \num{1}. The key's default value is \default{} \texttt{mu}.
	\end{option}
	
	\begin{option}{sep-inf-fun}
		\begin{values}[default = 0]
			\meta{cs-numbers}
		\end{values}
		This key sets the math space that is inserted between the infinitesimal and the function when the order \emph{is equal} to \num{1}. The space is only inserted when a non-blank function is printed \emph{in the numerator}. The key's default value is \default{} \texttt{mu}.
	\end{option}
	
	\begin{option}{sep-ord-fun}
		\begin{values}[default = 0]
			\meta{cs-numbers}
		\end{values}
		This key sets the math space that is inserted between the infinitesimal and the function when the order \emph{is different} from \num{1}. The space is only inserted when a non-blank function is printed \emph{in the numerator}. The key's default value is \default{} \texttt{mu}.
	\end{option}
	
	\begin{option}{sep-inf-var}
		\begin{values}[default = 0]
			\meta{cs-numbers}
		\end{values}
		This key sets the math space that is inserted between the infinitesimal and the variable. The space is only inserted when a non-blank variable is given. The key's default value is \default{} \texttt{mu}.
	\end{option}
	
	\begin{option}{sep-var-ord}
		\begin{values}[default = 0]
			\meta{cs-numbers}
		\end{values}
		This key sets the math space that is inserted in the variable's power left to the order. The space is only inserted when the order is different from \num{1}. The key's default value is \default{} \texttt{mu}.
	\end{option}
	
	\begin{option}{sep-eval-sb}
		\begin{values}[default = 0]
			\meta{cs-numbers}
		\end{values}
		This key sets the math space that is inserted in the evaluation subscript left to the point of evaluation. The space is only inserted when a non-blank subscript is given. The key's default value is \default{} \texttt{mu}.
	\end{option}
	
	\begin{option}{sep-eval-sp}
		\begin{values}[default = 0]
			\meta{cs-numbers}
		\end{values}
		This key sets the math space that is inserted in the evaluation superscript left to the point of evaluation. The space is only inserted when a non-blank superscript is given. The key's default value is \default{} \texttt{mu}.
	\end{option}
	
	\subsubsection*{Switches}
	
	\begin{option}*{switch-*}
		\begin{values}[default = false]
			true, false
		\end{values}
		The effect of the star's presence can be switched with the value \val{true}. That is, the function is typeset next to the fraction when the star is absent and in the numerator when the star is present. As an example, compare below where the option is turned on (\val{true}) and off (\val{false}),
		
		\begin{example}
			\derivset{\odv}[switch-*=false] \odv{y}{x} \\
			\derivset{\odv}[switch-*=true]  \odv{y}{x}
		\end{example}
		
		\noindent The key's default value is \default.
	\end{option}
	
	\begin{option}{switch-/}
		\begin{values}[default = false]
			true, false
		\end{values}
		The effect of the slash's presence can be switched with the value \val{true}. That is, the derivative is typeset with the fraction set by \key{style-frac-/} when the slash is absent and with the fraction set by \key{style-frac} when the slash is present. As an example, compare below where the option is turned on (\val{true}) and off (\val{false}),
		
		\begin{example}
			\derivset{\odv}[switch-/=false] \odv{y}{x} \\
			\derivset{\odv}[switch-/=true]  \odv{y}{x}
		\end{example}
		
		\noindent The key's default value is \default.
	\end{option}
	
	\subsubsection*{Miscellaneous}
	
	\begin{option}*{misc-add-delims, misc-remove-delims}
		\begin{values}
			fun, var, frac
		\end{values}
		These two keys accepts its input as an comma-separated list of values such that
		\begin{verbatim}
		\derivset{\odv}[misc-add-delims=fun]
		\derivset{\odv}[misc-add-delims={fun,var}]
		\derivset{\odv}[misc-add-delims={fun,var,frac}]
		\end{verbatim}
		are all valid, and the same goes for  \key{misc-remove-delims}. The key \key{misc-add-delims}{} is used to insert the delimiters around the key's values, while \key{misc-remove-delims}{} is used to remove the inserted delimiters. The next example shows the key \key{misc-add-delims} in action
		
		\begin{example}
			\derivset{\odv}[misc-add-delims=fun]            \odv{y}{x} \\
			\derivset{\odv}[misc-add-delims={fun,var}]      \odv{y}{x} \\
			\derivset{\odv}[misc-add-delims={fun,var,frac}] \odv{y}{x}
		\end{example}
		
		\noindent All the above applies to \key{misc-remove-delims}{} as well, except it removes the delimiters. The effect of the key \key{misc-add-delims}{} is turned off (\val{false}) locally inside a derivative. This is to ensure that the option is not applied to more than one derivative when nested as shown below
		
		\begin{example}
			\derivset{\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}
		\end{example}
		
		\noindent These two keys and this local behaviour are subject to change, see \cref{revis:add_remove,consid:add_remove_local} for more information. 
	\end{option}
	
	
	\subsection{Partial derivative} \label{ssec:pdv_options}
	The options in this subsection are available for the partial derivative \macro{\pdv} and variants hereof that are defined by the package and you.
	
	\subsubsection*{Style}
	
	\begin{option}*{style-inf}
		\begin{values}[default = { \cs{mathnormal}\pdf, \cs{symnormal}\uni }]
			\meta{math-font-style}
		\end{values}
		The font style of the infinitesimal for the chosen derivative is set by this key. The default font style is \default*. If an upright font is preferred then \cs{mathrm}\pdf{} and \cs{symup}\uni{} could be used, or if an italic font then \cs{mathnormal}\pdf{} and \cs{symit}\uni.
	\end{option}
	
	\begin{option}{style-frac}
		\begin{values}[default = \cs{frac}]
			\meta{fraction}
		\end{values}
		The derivative uses the fraction set by this key whenever \keyval{switch-/}{false} and the slash argument is absent. The key's default value is the usual fraction \cs{frac}.
	\end{option}
	
	\begin{option}{style-frac-/}
		\begin{values}[default = \cs{slashfrac}]
			\meta{fraction}
		\end{values}
		The derivative uses the fraction set by this key whenever \keyval{switch-/}{false} and the slash argument is present. The key's default value is a text-styled fraction \default\footref{foot:sfrac} i.e. on the form $\derivset{\pdv}[style-frac-/=\slashfrac, switch-/=false] \pdv{f}/{x,y}$.
	\end{option}
	
	\subsubsection*{Scaling}
	
	\begin{option}*{scale-eval}
		\begin{values}[default = auto]
			auto, none, big, Big, bigg, Bigg
		\end{values}
		This key sets the size of the delimiters used for the point of evaluation. This scaling is used whenever \keyval{switch-/}{false} and the slash argument is absent. The key's default value is set to scale the delimiters automatically.
	\end{option}
	
	\begin{option}{scale-eval-/}
		\begin{values}[default = auto]
			auto, none, big, Big, bigg, Bigg
		\end{values}
		This key sets the size of the delimiters used for the point of evaluation. This scaling is used whenever \keyval{switch-/}{false} and the slash argument is present. The key's default value is set to scale the delimiters automatically.
	\end{option}
	
	\begin{option}{scale-fun}
		\begin{values}[default = auto]
			auto, none, big, Big, bigg, Bigg
		\end{values}
		This key sets the size of the delimiters used around the function. The scaling is used whenever \keyval{misc-add-delims}{fun} is used. The key's default value is set to scale the delimiters automatically.
	\end{option}
	
	\begin{option}{scale-var}
		\begin{values}[default = auto]
			auto, none, big, Big, bigg, Bigg
		\end{values}
		This key sets the size of the delimiters used around the variable. The scaling is used whenever \keyval{misc-add-delims}{var} is used. The key's default value is set to scale the delimiters automatically.
	\end{option}
	
	\begin{option}{scale-frac}
		\begin{values}[default = auto]
			auto, none, big, Big, bigg, Bigg
		\end{values}
		This key sets the size of the delimiters used for around the fraction. This scaling is used whenever \keyval{switch-/}{false}, the slash argument is absent and \keyval{misc-add-delims}{frac} is used. The key's default value is set to scale the delimiters automatically.
	\end{option}
	
	\begin{option}{scale-frac-/}
		\begin{values}[default = auto]
			auto, none, big, Big, bigg, Bigg
		\end{values}
		This key sets the size of the delimiters used for around the fraction. This scaling is used whenever \keyval{switch-/}{false}, the slash argument is present and \keyval{misc-add-delims}{frac} is used. The key's default value is set to scale the delimiters automatically.
	\end{option}
	
	\subsubsection*{Delimiters}
	
	\begin{option}*{delims-eval}
		\begin{values}[default = (~)]
			\meta{left delimiter}\meta{right delimiter}
		\end{values}
		This key sets the left and right delimiters used to indicate the point of evaluation. These delimiters are inserted whenever \keyval{switch-/}{false} and the slash argument is absent. The key's default left and right delimiters are a left and a right parenthesis, respectively.
	\end{option}
	
	\begin{option}{delims-eval-/}
		\begin{values}[default = (~)]
			\meta{left delimiter}\meta{right delimiter}
		\end{values}
		This key sets the left and right delimiters used to indicate the point of evaluation. These delimiters are inserted whenever \keyval{switch-/}{false} and the slash argument is present. The key's default left and right delimiters are a left and a right parenthesis, respectively.
	\end{option}
	
	\begin{option}{delims-fun}
		\begin{values}[default = (~)]
			\meta{left delimiter}\meta{right delimiter}
		\end{values}
		This key sets the left and right delimiters used to around the function and these are inserted whenever \keyval{misc-add-delims}{fun} is used. The key's default left and right delimiters are a left and a right parenthesis, respectively.
	\end{option}
	
	\begin{option}{delims-var}
		\begin{values}[default = (~)]
			\meta{left delimiter}\meta{right delimiter}
		\end{values}
		This key sets the left and right delimiters used to around the variable and these are inserted whenever \keyval{misc-add-delims}{var} is used. The key's default left and right delimiters are a left and a right parenthesis, respectively.
	\end{option}
	
	\begin{option}{delims-frac}
		\begin{values}[default = (~)]
			\meta{left delimiter}\meta{right delimiter}
		\end{values}
		This key sets the left and right delimiters used to around the fraction in the derivative e.g. $\derivset{\pdv}[misc-add-delims=frac] \pdv*{y}{x}$. These delimiters are inserted whenever \keyval{switch-/}{false}, the slash argument is absent and \keyval{misc-add-delims}{frac} is used. The key's default left and right delimiters are a left and a right parenthesis, respectively.
	\end{option}
	
	\begin{option}{delims-frac-/}
		\begin{values}[default = (~)]
			\meta{left delimiter}\meta{right delimiter}
		\end{values}
		This key sets the left and right delimiters used to around the fraction in the derivative e.g. $\derivset{\pdv}[misc-add-delims=frac] \pdv*{y}/{x}$. These delimiters are inserted whenever \keyval{switch-/}{false}, the slash argument is present and \keyval{misc-add-delims}{frac} is used. The key's default left and right delimiters are a left and a right parenthesis, respectively.
	\end{option}
	
	\subsubsection*{Math spacing}
	The options in this subsection inserts extra horizontal math space. The below equation illustrates where the space is inserted
	\begin{equation*}
	\frac{  \partial \ms{inf-fun} f  }{  \partial \ms{inf-var} x  }
	\qquad
	\frac{  \partial^{ \ms{inf-ord} 2 } \ms{ord-fun} f  }{  \partial x \ms{var-inf} \partial y  }
	\qquad
	\frac{  \partial^{ 3 } f  }{  \partial x^{ \ms{var-ord} 2 } \ms{ord-inf} \partial y  }
	\qquad 
	\mleft( \frac{ \partial f}{ \partial x } \mright)_{ \ms{eval-sb} (x_1,y_1)}^{ \ms{eval-sp} (x_2,y_2)}
	\end{equation*}
	where it have been split into four to give a better overview.
	
	\begin{option}{sep-inf-ord}
		\begin{values}[default = 0]
			\meta{cs-number}
		\end{values}
		This key sets the math space that is inserted in the infinitesimal's power left to the mixed order. It is only inserted when the mixed order is different from \num{1}. The key's default value is \default{} \texttt{mu}.
	\end{option}
	
	\begin{option}{sep-inf-fun}
		\begin{values}[default = 0]
			\meta{cs-number}
		\end{values}
		This key sets the math space that is inserted between the infinitesimal and the function when the mixed order \emph{is equal} to \num{1}. The space is only inserted when a non-blank function is printed \emph{in the numerator}. The key's default value is \default{} \texttt{mu}.
	\end{option}
	
	\begin{option}{sep-ord-fun}
		\begin{values}[default = 0]
			\meta{cs-number}
		\end{values}
		This key sets the math space that is inserted between the infinitesimal and the function when the mixed order \emph{is different} from \num{1}. The space is only inserted when a non-blank function is printed \emph{in the numerator}. The key's default value is \default{} \texttt{mu}.
	\end{option}
	
	\begin{option}{sep-inf-var}
		\begin{values}[default = 0]
			\meta{cs-number}
		\end{values}
		This key sets the math space that is inserted between the infinitesimal and the following variable. The space is only inserted when a non-blank variable is given. The key's default value is \default{} \texttt{mu}.
	\end{option}
	
	\begin{option}{sep-var-ord}
		\begin{values}[default = 0]
			\meta{cs-number}
		\end{values}
		This key sets the math space that is inserted in a variable's power left to the order. The space is only inserted when the order is different from \num{1}. The key's default value is \default{} \texttt{mu}.
	\end{option}
	
	\begin{option}{sep-var-inf}
		\begin{values}[default = 3]
			\meta{cs-number}
		\end{values}
		They key sets the math space that is inserted between a variable and the following infinitesimal. The space is only inserted when the variable's order \emph{is equal} to \num{1}. It is only inserted when more than one non-blank variables are given. The key's default value is \default{} \texttt{mu}.
	\end{option}
	
	\begin{option}{sep-ord-inf}
		\begin{values}[default = 3]
			\meta{cs-number}
		\end{values}
		They key sets the math space that is inserted between a variable and the following infinitesimal. The space is only inserted when the variable's order \emph{is different} from \num{1}. It is only inserted when more than one non-blank variables are given. The key's default value is \default{} \texttt{mu}.
	\end{option}
	
	\begin{option}{sep-eval-sb}
		\begin{values}[default = -4]
			\meta{cs-number}
		\end{values}
		This key sets the math space that is inserted in the evaluation subscript left to the point of evaluation. The space is only inserted when a non-blank subscript is given. The key's default value is \default{} \texttt{mu}.
	\end{option}
	
	\begin{option}{sep-eval-sp}
		\begin{values}[default = -4]
			\meta{cs-number}
		\end{values}
		This key sets the math space that is inserted in the evaluation superscript left to the point of evaluation. The space is only inserted when a non-blank superscript is given. The key's default value is \default{} \texttt{mu}.
	\end{option}
	
	\subsubsection*{Switches}
	
	\begin{option}*{switch-*}
		\begin{values}[default = false]
			true, false
		\end{values}
		The effect of the star's presence can be switched with the value \val{true}. That is, the function is typeset next to the fraction when the star is absent and in the numerator when the star is present. As an example, compare below where the option is turned on (\val{true}) and off (\val{false}),
		
		\begin{example}
			\derivset{\pdv}[switch-/=false] \pdv{y}{x} \\
			\derivset{\pdv}[switch-/=true]  \pdv{y}{x}
		\end{example}
		
		\noindent The key's default value is \default.
	\end{option}
	
	\begin{option}{switch-/}
		\begin{values}[default = false]
			true, false
		\end{values}
		The effect of the slash's presence can be switched with the value \val{true}. That is, the derivative is typeset with the fraction set by \key{style-frac-/} when the slash is absent and with the fraction set by \key{style-frac} when the slash is present. As an example, compare below where the option is turned on (\val{true}) and off (\val{false}),
		
		\begin{example}
			\derivset{\pdv}[switch-/=false] \pdv{y}{x} \\
			\derivset{\pdv}[switch-/=true]  \pdv{y}{x}
		\end{example}
		
		\noindent The key's default value is \default.
	\end{option}
	
	\subsubsection*{Miscellaneous}
	
	\begin{option}*{misc-add-delims, misc-remove-delims}
		\begin{values}
			fun, var, frac
		\end{values}
		These two keys accepts its input as an comma-separated list of values such that
		\begin{verbatim}
		\derivset{\pdv}[misc-add-delims=fun]
		\derivset{\pdv}[misc-add-delims={fun,var}]
		\derivset{\pdv}[misc-add-delims={fun,var,frac}]
		\end{verbatim}
		are all valid, and the same goes for  \key{misc-remove-delims}. The key \key{misc-add-delims}{} is used to insert the delimiters around the key's values, while \key{misc-remove-delims}{} is used to remove the inserted delimiters. The next example shows the key \key{misc-add-delims} in action
		
		\begin{example}
			\derivset{\pdv}[misc-add-delims=fun]            \pdv{y}{x} \\
			\derivset{\pdv}[misc-add-delims={fun,var}]      \pdv{y}{x} \\
			\derivset{\pdv}[misc-add-delims={fun,var,frac}] \pdv{y}{x}
		\end{example}
		
		\noindent All the above applies to \key{misc-remove-delims}{} as well, except it removes the delimiters. The effect of the key \key{misc-add-delims}{} is turned off (\val{false}) locally inside a derivative. This is to ensure that the option is not applied to more than one derivative when nested as shown below
		
		\begin{example}
			\derivset{\pdv}[misc-add-delims=var] \pdv*{\pdv{y}{x}}{x}
		\end{example}
		
		\noindent These two keys and this local behaviour are subject to change, see \cref{revis:add_remove,consid:add_remove_local} for more information.
	\end{option}
	
	\subsubsection*{Sort}
	The keys given in this subsection will be briefly described here and a more in-depth description will be given in \cref{ssec:overall_order}.
	
	\begin{option}{sort-method}
		\begin{values}[default = {sign, symbol, abs}]
			abs, sign, symbol
		\end{values}
		This key sets the sorting method behind the mixed order using build in algorithms. The symbolic terms in the mixed order is sorted by sign, symbolic length and absolute value by the \val{sign}, \val{symbol} and \val{abs} algorithms, respectively. The key takes its input as a comma-separated list of values, accepting up to three values e.g.
		
		\begin{example}*
			\derivset{\pdv}[sort-method=sign]              \pdv[c+kn,-b+2a]{f}{x,y} \\
			\derivset{\pdv}[sort-method={sign,symbol}]     \pdv[c+kn,-b+2a]{f}{x,y} \\
			\derivset{\pdv}[sort-method={sign,symbol,abs}] \pdv[c+kn,-b+2a]{f}{x,y}
		\end{example}
		
		\noindent are valid inputs. Note how the terms in the mixed order are ordered using different sorting methods. This key is further described in \cref{ssec:sort-method}. The key's default value uses all three algorithms as \default.
	\end{option}
	
	\begin{option}{sort-numerical}
		\begin{values}[default = auto]
			auto, first, last
		\end{values}
		This key determines where the numerical term\footnote{The numerical term is the sum of all the orders that does not contain any symbols, but solely consist of numbers.\label{foot:numerical-term}} is placed in the mixed order. Using the values \val{first} and \val{last}, then the numerical term will \emph{always} be placed as the first and last term in the mixed order, respectively. While the value \val{auto} will automatically determine where to place the numerical term depending on the sign of the first symbolic term; it is placed as the first and last term if the sign is negative and positive, respectively. This is shown below
		
		\begin{example}*
			\derivset{\pdv}[sort-numerical=first] \pdv[n,2]{f}{x,y}  \\
			\derivset{\pdv}[sort-numerical=last]  \pdv[-n,2]{f}{x,y}
		\end{example}
		
		\noindent where the value \val{auto} would have placed the numerical term opposite in both equations. The key is further described in \cref{ssec:sort-numerical}, and its default value is \default.
	\end{option}
	
	\begin{option}{sort-sign-reverse}
		\begin{values}[default = false]
			true, false
		\end{values}
		The sorting algorithm \val{sign} separates the positive and negative terms where the former is placed first and the latter last. The value \val{true} will reverse this ordering such that the negative terms is placed first and the positive terms last. See \cref{ssec:sort-reverse} for more information.
	\end{option}
	
	\begin{option}{sort-symbol-reverse}
		\begin{values}[default = false]
			true, false
		\end{values}
		The sorting algorithm \val{symbol} separates the terms by their symbolic length, where the terms are ordered in a descending manner according to their length. If the value \val{true} is used, then the terms will ordered in a ascending manner instead. See \cref{ssec:sort-reverse} for more information.
	\end{option}
	
	\begin{option}{sort-abs-reverse}
		\begin{values}[default = false]
			true, false
		\end{values}
		The sorting algorithm \val{abs} separates the terms by their absolute value, where the terms are ordered in a descending manner. If the value \val{true} is used, then the terms will ordered in a ascending manner instead. See \cref{ssec:sort-reverse} for more information.
	\end{option}
	
	\subsection{All derivatives} \label{ssec:both_options}
	The options in this subsection are applied to all of the derivatives that are defined by the package and you, because some options should be consisting regardless of the derivatives. The options are accessed using \macro{\derivset}[\narg{all},\oarg{key=value}].
	
	\begin{option}{scale-auto}
		\begin{values}[default = leftright]
			leftright, mleftmright\req
		\end{values}
		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.
	\end{option}
	
	
	
	
	
	
	\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}
	
	\begin{function}*{\NewOdvVariant, \RenewOdvVariant, \ProvideOdvVariant, \DeclareOdvVariant}
		\begin{syntax}
			\meta{control-sequence}, \marg{infinitesimal}, \oarg{key=value}
		\end{syntax}
		This family of commands are used to define a variant of the ordinary derivative with the macro name \arg{1}. Moreover, the new derivative will use \arg{2} as its infinitesimal and inherit the package's default settings given in \cref{ssec:odv_options}, but they may be overwritten with \arg{3}. The difference between them, is as follows:
		\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}
		
		\begin{argument}{1}
			The first argument is the macro name of the derivative that is to be defined.
		\end{argument}
		
		\begin{argument}{2}
			While the second argument makes the derivative \arg{1} use \arg{2} as the infinitesimal, like \enquote{d} is used as the infinitesimal in the ordinary derivative \macro{\odv}.
		\end{argument}
		
		\begin{argument}{3}
			The optional argument accepts its input as a comma-separated list of \emph{key=value} pairs, which overrides the package's default options for the keys given. Leaving out this argument, then the derivative will use the package's default settings.
		\end{argument}
	\end{function}
	
	\subsection{Variants of the partial derivative} \label{ssec:CreatePdvVariant}
	
	\begin{function}*{\NewPdvVariant, \RenewPdvVariant, \ProvidePdvVariant, \DeclarePdvVariant}
		\begin{syntax}
			\meta{control-sequence}, \marg{infinitesimal}, \oarg{key=value}
		\end{syntax}
		This family of commands are used to define a variant of the partial derivative with the macro name \arg{1}. Moreover, the new derivative will use \arg{2} as its infinitesimal and inherit the package's default options given in \cref{ssec:pdv_options}, but they may be overwritten with \arg{3}. The difference between them is as follows:
		
		\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}
		
		\begin{argument}{1}
			The first argument is the macro name of the derivative that is to be defined.
		\end{argument}
		
		\begin{argument}{2}
			While the second argument makes the derivative \arg{1} use \arg{2} as the infinitesimal, like \enquote{$\partial$} is used as the infinitesimal in the partial derivative \macro{\pdv}.
		\end{argument}
		
		\begin{argument}{3}
			The optional argument accepts its input as a comma-separated list of \emph{key=value} pairs, which overrides the package's default options for the keys given. Leaving out this argument, then the derivative will use the package's default settings.
		\end{argument}
	\end{function}
	
	
	
	
	
	\clearpage
	\section{The mixed order} \label{ssec:overall_order}
	
	\subsection{Sorting algorithms} \label{ssec:sort-method}
	A unique feature of this package is that the sorting method behind the mixed order may be changed using built-in algorithms and there are currently three algorithms available: \val{sign}, \val{symbol} and \val{abs} which are explained below. The algorithms have been chosen such that it the terms in the mixed order may be arranged in many ways with as few algorithms as possible to suit your liking. A sorting method may consist of up to three algorithms which are applied in layers.
	
	\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}
	\begin{function}*{\slashfrac}
		\begin{syntax}
			\oarg{scale}, \marg{numerator}, \marg{denominator}
		\end{syntax}
		A text-styled fraction i.e. $\slashfrac{a}{b}$, is commonly used in text-mode. While \macro{\slashfrac}[\narg{a},\narg{b}] is certainly longer to write than \texttt{a/b}, which only requires three keystrokes, but for the implementation of text-styled derivatives, a macro is needed anyway.
		
		\begin{argument}{1}
			The optional argument is the scaling parameter for the slash and takes the inputs as shown below. Leaving out \arg{1} sets the scaling parameter to \val{auto}
			\begin{example}
				\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}
			\end{example}
			This argument is subject to change, see \cref{consid:slashfrac_opt,consid:slashfrac_def_scale} for more information.
		\end{argument}
		
		\begin{argument}{2}
			This argument typeset the fraction's numerator.
		\end{argument}
		
		\begin{argument}{3}
			This argument typeset the fraction's denominator.
		\end{argument}
	\end{function}
	
	
	
	
	
	
	
	\clearpage
	\section{To do}\label{sec:todo}
	
	Entries marked with \cmark{} will be implemented in a future release specified in the entry. Entries marked with \xmark{} will not be implemented.
	
	\subsection{Future implementation}
	The list describes what \emph{will be added} to the package in a later release.
	\begin{todo}
		\item Define commands that can create variants of infinitesimal like $\symup{d}$, $\partial$, $\delta$ etc. for use in integrals $\int f(x) \mathop{}\!\symup{d}x$, in differential equations $\pdv{f}{x} \mathop{}\! \symup{d}x + \pdv{f}{y}\mathop{}\! \symup{d}y$ and a shorthand notation of the partial derivative $\partial_{xx}f(x,y)$.
		\item Implement the option to turn off the sorting of the terms in the mixed order. This could be made as a \val{draft} / \val{final} option.
	\end{todo}
	
	\subsection{Future changes}
	The list describes what \emph{will be changed} in the package in a later release.
	\begin{changes}
		\item A complete rewrite of the options \key[index=false]{misc-add-delims} and \key[index=false]{misc-remove-delims} is necessary so that they have a clearer syntax. Moreover, the value \val{var} needs to work differently (and correctly) for the partial derivatives and variants hereof (pretty much useless here). \label{revis:add_remove}
	\end{changes}
	
	\subsection{Future considerations}
	The list describes what \emph{might be changed or added} to the package in a later release.
	\begin{consideration}
		\item As mentioned earlier in the documentation, I heavily consider to change the optional argument \oarg{order} to a \oarg{key=value} argument. Of course this will lead to some changes: \label{consid:order2keyval}
		\begin{itemize}
			\item I would need a way to set the order of differentiation. I am thinking of something like a key value option; \keyval[index=false]{order}{\marg{cs-orders}}.
			%
			\item Such an option should not be possible to be set with \macro[index=false]{\derivset} or in the definition of a new derivative (or maybe if one really needs a lot of higher order derivative).
		\end{itemize}
		\answer{\cmark}{I truly believe this is the right way forward and is coming in the next release. More features can easily be added in a key-value style. The order argument will be replaced with a key-value argument and a order key introduced; \texttt{ord=\meta{order}}.}
		%
		\item With the above consideration, than it would only be natural to remove the mixed order and then have an option \keyval[index=false]{mixed-order}{\marg{mixed-order}}. Likewise, it should not be possible to be set with \macro[index=false]{\derivset} or in the definition of a new derivative. \label{consid:RemoveMixedOrder} \\
		\answer{\cmark}{The mixed order argument will be removed due to the introduction of a key-value argument as mentioned above in the next release. The mixed order can be set with the knew key \texttt{m-ord=\meta{mixed-order}}.}
		%
		\item Currently \macro[index=false]{\derivset}'s optional argument \oarg{key=val}, when not given, sets the derivatives options to the package default settings. This should probably be changed to the options set in the definition of the derivative. \label{consid:DerivsetOptional} \\
		\answer{\cmark}{I believe this would a nice change for the future, but I do not have the time to make the implementation for the next release.}
		%
		\item It can become rather cumbersome to read a derivative with a very long function. To ease this up, I am considering to add a switch that exchange the variable and the function arguments. But this might be against the \latex{} way of using arguments, which is the reason it have not been done and I would like feedback on it. \label{consid:Fun_Var_switch}
		%
		\item Should I add a key, possible a switch, that turn on/off the local behaviour \key[index=false]{misc-add-delims} and \key[index=false]{misc-remove-delims} inside derivative? \label{consid:add_remove_local}
		% 
		\item It was mentioned in \cref{sec:createvariants}, that the second argument of \cs{\ldots Variant} should be a single token, e.g. meaning that \macro[index=false]{\NewOdvVariant}[\narg{\cs{myvariant}},\narg{\cs{partial}\_\cs{mu}}] is not allowed but \macro[index=false]{\NewOdvVariant}[\narg{\cs{myvariant}},\narg{\{\cs{partial}\_\cs{mu}\}}] is. It can easily be change to accept a multi token input. \\
		\answer{\cmark}{This have already been changed in version 0.95, since it is an unnecessary constraint.}
		%
		\item Should I add the option to \key[index=false]{sort-numerical}, so that it is treated as a symbolic term instead of a numerical term? \label{consid:sort_numerical}
		\\ \answer{\cmark}{Yes. Yes I should. This feature will be added in the next release.}
		%
		\item Should I add a sorting algorithm that order the terms according to their number (including sign)? \label{consid:sort_number}
		\\ \answer{\cmark}{Yes. Yes I should. This feature will be added in the next release.}
		%
		\item I am considering making the optional argument of \macro[index=false]{\slashfrac} into a \oarg{key=value} argument with something like \keyval[index=false]{scale}{\marg{scaling}}. \label{consid:slashfrac_opt} \\
		\answer{\cmark}{I want an key-value implementation like this in the future, but it will not be added it the next release.}
		%
		\item Should the default scaling for \macro[index=false]{\slashfrac} be \val{auto} or \val{none}? Or should it be possible to set it with something like \cs{slashfracset}\oarg{key=value}? \label{consid:slashfrac_def_scale} \\
		\answer{\xmark}{The package default should be \val{auto}, but it will be possible to change it, when the key-value is implemented or \macro[index=false]{\slashfrac}.}
	\end{consideration}
	
	
	
	
	
	
	\clearpage
	\addsec{Index}
	Numbers in bold  refer to the page where the entry is defined.
	
	\printindex[option]
	\printindex[macro]
	
	
	
	
	
	
	\clearpage
	\addsec{Change history}
	
	\setlength{\marginparwidth}{75pt}
	
	\begin{changelog}
		\begin{change}[version = 0.9,  date = 2019-07-21, beta = true]
			\item First release of the package. The package is currently in a beta version.
		\end{change}
		\bigskip
		\begin{change}[version = 0.95, date = 2019-09-18, beta = true]
			\item \emph{Please ignore this version, since it contained the wrong \pkg{.sty} and \pkg{.pdf} files} \texttt{:(}.
			%\item Second beta release of the package.
			\item Removed the single token restriction of the infinitesimal since it made no sense.
			\item Fixed the documentation errors and typos.
			\item Minor fixes to the code.
		\end{change}
		\begin{change}[version = 0.95b, date = 2019-09-21, beta = true]
			\item Contains the correct \pkg{.sty} and \pkg{.pdf} files \texttt{:)}.
			\item One minor code fix.
		\end{change}
		\begin{change}[version = 0.96, date = 2019-12-22, beta = true]
			\item Fixed the double superscript issue for higher order derivative when the variable contained a superscript.
		\end{change}
		\begin{change}[version = 0.97, date = 2020-02-03, beta = true]
			\item Fixed the argument specifier of {\small\verb|\__deriv_scale_big:nnnn|} when it was used (it was used with \texttt{:nnnm}).
		\end{change}
	\end{changelog}
\end{document}