% file `diffcoeff5.def'
% definitions for variant forms
% 2025/12/19
% Andrew Parsloe ajparsloe@gmail.com
% 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% material derivative
\difdef { f, s } { D }
  { op-symbol = \mathrm{D} }
% math italic
\difdef { f, s, c } { d' } 
  {
    op-symbol      = d,
    op-order-nudge = 1 mu,
    *slash-sep    = { 0 mu, -1 mu }
  }
\difdef { f, s, c } { D' } 
  {
    op-symbol  = D,
    op-order-nudge = 1 mu,
    *slash-sep    = -1 mu
  }
% Greek 
\difdef { f, s } { gd }
  { op-symbol = \delta }
\difdef { f, s } { gD }
  { op-symbol = \Delta }
% nabla, tensor calc. acceleration
\difdef { f, s } { n } 
  {
    op-symbol     = \nabla,
    op-symbol-alt = \mathrm{d},
    *slash-sep    = { -2mu, 0mu }
  }
% tfrac, nonscalable
\difdef { f, fp } { t }
  {
    style             = tfrac  ,
    derivand-sep      = 1 mu plus 1 mu minus 1 mu,
    multi-term-sep    = 0 mu   ,
    term-sep-adjust   = 0 mu   ,
    lvwrap-sup-nudge  = 0 mu   ,
    outer-Ldelim      = \bigl (,
    outer-Rdelim      = \bigr ),
    elbowroom         = -2 mu  ,
    sub-nudge         = -3 mu
  }
% pt of eval -- sq. bracket
\difdef { f, fp, s, sp } { ] } 
  {
    outer-Ldelim = \left [ ,
    outer-Rdelim = \right ],
    elbowroom    = 1 mu,
    sub-nudge    = 0 mu
  }
% long var wrap
\difdef { f, fp } { (dv) } 
  { long-var-wrap = (dv) }
\difdef { f, fp } { dv } 
  { long-var-wrap = dv }
\difdef { f, fp } { dv_ } 
  { 
    long-var-wrap = dv,
    var-sup-nudge = -1 mu
  }
%%%%%%%%%% slash fraction %%%%%%%%%%
% sfrac split-level
\difdef { s, sp } { s }
  {
    style             = sfrac,
    slash-sep         = { -2 mu, -1 mu },
    derivand-sep      = 0 mu ,
    multi-term-sep    = 0 mu ,
    term-sep-adjust   = 0 mu ,
    var-sup-nudge     = 0 mu ,
    lvwrap-sup-nudge  = 0 mu
  }
\difdef { s } { s } { *slash-sep = { -1 mu, -1 mu } }
\difdef { s } { sd }
  {
    style             = sfrac,
    op-symbol         = \delta,
    slash-sep         = { -2 mu, -1 mu },
    derivand-sep      = 0 mu ,
    multi-term-sep    = 0 mu ,
    term-sep-adjust   = 0 mu ,
    var-sup-nudge     = 0 mu ,
    lvwrap-sup-nudge  = 0 mu
  }
% sfrac, no op symbols
\NewDocumentCommand \difsfrac { O{-2mu,-1mu} m m } 
  {{ 
    \difdef { s } { s } { op-symbol=, slash-sep={#1} }
    \difs.s.{#2}{#3}
  }}
% \NewDocumentCommand \difsfrac { D[,{-2} D-]{1} m m } 
  % { { 
    % \difdef{s}{s}{op-symbol=,slash-sep={#1mu,-#2mu} }
    % \difs.s.{#3}{#4}
  % }}
% slash frac: 0=scalable, 1=big, 
% %2=Big, 3=bigg, 4=Bigg but > 1
% generally gives eyesores
\difdef { s, sp } { 0 }
  {
    style         = auto     ,
    outer-Ldelim  = \left [  ,
    outer-Rdelim  = \right ] ,
    sub-nudge     = 0 mu     ,
    *inner-Ldelim = \mleft ( ,
    *inner-Rdelim = \mright ),
    *outer-Ldelim = \left [  ,
    *outer-Rdelim = \right ]
  }
\difdef { s, sp } { 1 }
  {
    style          =  big   ,
    outer-Ldelim   = \bigl (,
    outer-Rdelim   = \bigr ),
    sub-nudge      = -2 mu  ,
    *inner-wrap    = true   ,
    *inner-Ldelim  = \bigl (,
    *inner-Rdelim  = \bigr ),
    *outer-Ldelim  = \bigl [,
    *outer-Rdelim  = \bigr ]
  }
% \cdots generic slash fraction
\difdef { s, sp } { cd } { dots = \cdots }
% pt of eval -- pipe
\difdef { f, fp, s, sp } { | } 
  {
    outer-Ldelim = \left . ,
    outer-Rdelim = \right |,
    sub-nudge    = 0 mu
  }
%%%%%%%%%% compact %%%%%%%%%%
% D operator
\difdef { c } { D }
  { 
    op-symbol    = \mathrm{D}, 
    op-sub-nudge = -2 mu
  }
\difdef { c } { D' }
  { 
    op-symbol    = D, 
    op-sub-nudge = -2 mu
  }
% bold
\difdef { c } { bD } 
  { 
    op-symbol    = \mathbf{D}, 
    op-sub-nudge = -2 mu
  }
% differential style
\difdef { c, cp } { dl } 
  { 
    style           = dl,
    multi-term-sep  = 1 mu,
    term-sep-adjust = -1 mu
  }
% attach superscript to the d
\difdef { c, cp } { d^ } 
  { 
    style           = d^,
    multi-term-sep  = 1 mu,
    term-sep-adjust = -1 mu
  }
% doubly compact
\difdef { cp } { cc } 
  {
    style           =  cc  ,
    op-order-nudge  =  1 mu,
    multi-term-sep  =  0 mu,
    term-sep-adjust = -1 mu,
    var-sup-nudge   =  0 mu
  }
% \difdef { cp } { cc } { difcc-var-ord = ##1 }
% \difdef { cp } { cc } { difcc-var-ord = :##1 }
% \difdef { cp } { cc } { difcc-var-ord = \mathbf{##1} }
\NewDocumentCommand \difccp { s s O{1}} 
  { \IfBooleanTF #1 { \difcp.cc.**[#3]<1> } { \difcp.cc.[#3]<1> } }
%%%%%%%%%% differentials %%%%%%%%%%
% partial
\difdef { l } { p } { op-symbol = \partial }
\NewDocumentCommand \dlp {} { \dl.p. }
% bold variable
\difdef { l } { b }
  { op-symbol = \mathrm{d}\mathbf }
% d^n x
\difdef { l } { dn }{ style = d^ }
% line element: Pythagoras
\difdef { l } { + }
  {
    multi-term-sep  = 0 mu +,
    term-sep-adjust = 0 mu  ,
    outer-Ldelim    =
  }
% line element: Minkowski
\difdef { l } { - }
  {
    multi-term-sep  = 0 mu -,
    term-sep-adjust = 0 mu  ,
    outer-Ldelim    =
  }
%%%%%%%%%% jacobian %%%%%%%%%%
% slash fraction
\difdef { j } { / } { style = / }
% split level
\difdef { j } { s } { style = sfrac }
%%%%%%%%%% \Braket %%%%%%%%%%
\difdef{ s }{ bk }
  {
      slash-tok = ,
      op-symbol =  ,
      multi-term-sep = 3mu\middle|\mskip3mu ,
      outer-Ldelim=\left\langle ,
      outer-Rdelim=\right\rangle
  }
\NewDocumentCommand \Braket { m }
  {	\difs.bk.<\negmu>{}{#1}[] }
