%%
%% This is file `mattens.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% mattens.dtx  (with options: `package')
%% 
%% Copyright (C) 2001--2022 Danie Els
%% 
%% -------------------------------------------------------------------
%%                      The mattens package
%%                  for vector/tensor typesetting
%% -------------------------------------------------------------------
%% This work may be distributed and/or modified under the conditions
%% of the LaTeX Project Public License, either version 1.3c 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.3c or later is part of all distributions of LaTeX
%% version 2008/12/01 or later.
%% 
%% This work has the LPPL maintenance status 'maintained'.
%% 
%% This Current Maintainer of this work is Danie Els (dnjels@gmail.com)
%% -------------------------------------------------------------------
%% 
%% \CharacterTable
%%  {Upper-case    \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
%%   Lower-case    \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
%%   Digits        \0\1\2\3\4\5\6\7\8\9
%%   Exclamation   \!     Double quote  \"     Hash (number) \#
%%   Dollar        \$     Percent       \%     Ampersand     \&
%%   Acute accent  \'     Left paren    \(     Right paren   \)
%%   Asterisk      \*     Plus          \+     Comma         \,
%%   Minus         \-     Point         \.     Solidus       \/
%%   Colon         \:     Semicolon     \;     Less than     \<
%%   Equals        \=     Greater than  \>     Question mark \?
%%   Commercial at \@     Left bracket  \[     Backslash     \\
%%   Right bracket \]     Circumflex    \^     Underscore    \_
%%   Grave accent  \`     Left brace    \{     Vertical bar  \|
%%   Right brace   \}     Tilde         \~}
%%

\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{mattens}[2022/03/01
                          v1.3b
                          Matrix/Tensors (DNJ Els)]
\newcommand*{\MT@SymbStrt}{}
\newcommand*{\SetSymbStrut}[1]{\renewcommand*{\MT@SymbStrt}{#1}}
\SetSymbStrut{\relax}
\DeclareOption{mathstrut}{\SetSymbStrut{\mathstrut}}
\newcommand*{\MT@SymbFnt}{}
\newcommand*{\SetSymbFont}[1]{\renewcommand*{\MT@SymbFnt}{#1}}
\SetSymbFont{\boldsymbol}
\DeclareOption{noformat}{\SetSymbFont{\relax}}
\DeclareOption*{%
    \PackageWarning{mattens}{Unknown option: \CurrentOption}}
\ProcessOptions\relax
\RequirePackage{amsmath}
\newcommand{\MT@Overarrow}[2]{\overarrow@{\rightarrowfill@}{#1}{#2}}
\newcommand{\MT@Underarrow}[2]{\underarrow@{\rightarrowfill@}{#1}{#2}}
\newcommand{\MT@Overline}[2]{{#1\overline{#2}}}
\newcommand{\MT@Underline}[2]{{#1\underline{#2}}}
\AtBeginDocument{%
   \@ifl@aded{def}{pdftex}%
      {\newcommand*{\xusebox}[1]{\mathord{{\usebox{#1}}}}}%
      {\let\xusebox\usebox}%
}
\newmuskip{\MT@Askip}
\newmuskip{\MT@Bskip}
\newmuskip{\MT@SPskip}
\newmuskip{\MT@SBskip}
\newcommand*{\SetArrowSkip}[1]{\MT@Askip#1}
\newcommand*{\SetBarSkip}[1]{\MT@Bskip#1}
\newcommand*{\SetSymSupSkip}[1]{\MT@SPskip#1}
\newcommand*{\SetSymSubSkip}[1]{\MT@SBskip#1}
\SetArrowSkip{0mu}
\SetBarSkip{1mu}
\SetSymSubSkip{0mu}
\SetSymSupSkip{0mu}
\newmuskip\MT@SubSkip
\newmuskip\MT@SupSkip
\newcommand*{\MT@accent}{}
\newcommand*{\MT@cmd}{}
\newcommand*{\MT@@cmd}{}
\newcommand*{\MT@bold}{}
\DeclareRobustCommand*{\aS}{%
   \let\MT@cmd=\MT@OverAandB%
   \let\MT@@cmd=\MT@Overarrow%
   \MT@SupSkip=\MT@Askip%
   \MT@SubSkip=\MT@SBskip%
   \MT@Tensor}
\DeclareRobustCommand*{\bS}{%
   \let\MT@cmd=\MT@OverAandB%
   \let\MT@@cmd=\MT@Overline%
   \MT@SupSkip=\MT@Bskip%
   \MT@SubSkip=\MT@SBskip%
   \MT@Tensor}%
\DeclareRobustCommand*{\Sa}{%
   \let\MT@cmd=\MT@UnderAandB%
   \let\MT@@cmd=\MT@Underarrow%
   \MT@SupSkip=\MT@SPskip%
   \MT@SubSkip=\MT@Askip%
   \MT@Tensor}
\DeclareRobustCommand*{\Sb}{%
   \let\MT@cmd=\MT@UnderAandB%
   \let\MT@@cmd=\MT@Underline%
   \MT@SupSkip=\MT@SPskip%
   \MT@SubSkip=\MT@Bskip%
   \MT@Tensor}
\DeclareRobustCommand*{\bSb}{%
   \let\MT@cmd=\MT@DoubleAandB%
   \let\MT@@cmd=\MT@@bSb%
   \MT@SupSkip=\MT@Bskip%
   \MT@SubSkip=\MT@Bskip%
   \MT@Tensor}
\DeclareRobustCommand*{\aSb}{%
   \let\MT@cmd=\MT@DoubleAandB%
   \let\MT@@cmd=\MT@@aSb%
   \MT@SupSkip=\MT@Askip%
   \MT@SubSkip=\MT@Bskip%
   \MT@Tensor}
\DeclareRobustCommand*{\bSa}{%
   \let\MT@cmd=\MT@DoubleAandB%
   \let\MT@@cmd=\MT@@bSa%
   \MT@SupSkip=\MT@Bskip%
   \MT@SubSkip=\MT@Askip%
   \MT@Tensor}
\DeclareRobustCommand*{\aSa}{%
   \let\MT@cmd=\MT@DoubleAandB%
   \let\MT@@cmd=\MT@@aSa%
   \MT@SupSkip=\MT@Askip%
   \MT@SubSkip=\MT@Askip%
   \MT@Tensor}
\DeclareRobustCommand*{\bCSb}{%
   \let\MT@cmd=\MT@DoubleAandB%
   \let\MT@@cmd=\MT@@bCSb%
   \MT@SupSkip=\MT@Bskip%
   \MT@SubSkip=\MT@Bskip%
   \MT@Tensor}
\DeclareRobustCommand*{\aCSa}{%
   \let\MT@cmd=\MT@DoubleAandB%
   \let\MT@@cmd=\MT@@aCSa%
   \MT@SupSkip=\MT@Askip%
   \MT@SubSkip=\MT@Askip%
   \MT@Tensor}
\newcommand*{\MT@Tensor}{%
   \@ifstar{\let\MT@bold=\@firstofone\MT@@Tensor}
           {\let\MT@bold=\MT@SymbFnt\MT@@Tensor}}
\newcommand*{\MT@@Tensor}[2][\@firstofone]{%
   \let\MT@accent=#1\relax%
   \MT@GetScripts{#2}}
\newcommand*\MT@GetScripts[1]{%
   \@ifnextchar'%
      {\MT@GetPrimes{#1}{\prime}}%
      {\MT@UnprimedScripts{#1}}}
\newcommand*\MT@GetPrimes[3]{%
   \@ifnextchar'%
      {\MT@GetPrimes{#1}{#2\prime}}%
      {\@ifnextchar^%
          {\MT@GetPrimedSuper{#1}{#2}}%
          {\@ifnextchar_%
              {\MT@GetPrimedSub{#1}{#2}}%
              {\MT@SetScripts{#1}{#2}{\@empty}}%
          }%
      }%
   }
\def\MT@GetPrimedSuper#1#2^#3{%
   \@ifnextchar_{\MT@GetPrimedSub{#1}{#2#3}}%
                {\MT@SetScripts{#1}{#2#3}{\@empty}}}
\def\MT@GetPrimedSub#1#2_#3{%
   \MT@SetScripts{#1}{#2}{#3}}
\newcommand*\MT@UnprimedScripts[1]{%
   \@ifnextchar^%
      {\MT@GetSuper{#1}}%
         {\@ifnextchar_%
             {\MT@GetSub{#1}}%
             {\MT@SetScripts{#1}{\@empty}{\@empty}}%
         }%
   }
\def\MT@GetSuper#1^#2{%
   \@ifnextchar_{\MT@GetSuperSub{#1}{#2}}%
                {\MT@SetScripts{#1}{#2}{\@empty}}}
\def\MT@GetSub#1_#2{%
   \@ifnextchar^{\MT@GetSubSuper{#1}{#2}}%
                {\MT@SetScripts{#1}{\@empty}{#2}}}
\def\MT@GetSuperSub#1#2_#3{%
   \MT@SetScripts{#1}{#2}{#3}}
\def\MT@GetSubSuper#1#2^#3{%
   \MT@SetScripts{#1}{#3}{#2}}
\newcommand*{\MT@SetSup}{}
\newcommand*{\MT@SetSub}{}
\newcommand*{\MT@SetSubS}{}
\newcommand*\MT@SetScripts[3]{%
  \let\MT@SetSup\relax%
  \let\MT@SetSub\relax%
  \let\MT@SetSubS\relax%
  \ifx\@empty#2\@empty\else
     \def\MT@SetSup{^{\mskip\MT@SupSkip\relax#2}}%
  \fi
  \ifx\@empty#3\@empty\else
     \def\MT@SetSub{_{\mskip\MT@SubSkip\relax#3}}%
     \def\MT@SetSubS{^{}_{\mskip\MT@SubSkip\relax#3}}%
  \fi
  \MT@cmd{#1}}
\newcommand*{\MT@Symb}[1]{\MT@SymbStrt\MT@bold#1}
\newcommand*{\MT@SymbC}[1]{%
   \MT@SymbStrt\widetilde{%
   \MT@bold#1}}
\newsavebox{\MT@Abox}   % for overline/arrow
\newsavebox{\MT@Sbox}   % for symbol
\newsavebox{\MT@Tbox}   % for tempories
\newsavebox{\MT@APbox}  % for overline/arrow phantom
\newsavebox{\MT@SPbox}  % for symbol phantom
\newlength{\MT@SPwdth}  % symbol width
\newlength{\MT@BPwdth}  % Bar width
\newlength{\MT@Wwdth}   % leading whitespace width
\newcommand*{\MT@OverAandB}{%
   \mathpalette\MT@@OverAandB}
\newcommand*{\MT@@OverAandB}[2]{%
      \sbox{\MT@Tbox}{$\m@th#1\MT@Symb{#2}$}%
      \setbox\MT@SPbox\null%
      \ht\MT@SPbox\ht\MT@Tbox%
      \dp\MT@SPbox\dp\MT@Tbox%
      \wd\MT@SPbox\wd\MT@Tbox%
      \sbox{\MT@APbox}{$\m@th\MT@@cmd{#1}{\copy\MT@SPbox}$}%
      \setlength{\MT@Wwdth}{\the\wd\MT@APbox}%
      \addtolength{\MT@Wwdth}{-\the\wd\MT@SPbox}%
      \sbox{\MT@Sbox}{$\m@th#1\hskip 0.5\MT@Wwdth\relax\MT@Symb{#2}\MT@SetSubS$}%
      \sbox{\MT@Tbox}{$\m@th#1\MT@accent{\xusebox{\MT@APbox}}$}%
      \ht\MT@Tbox\ht\MT@APbox%
      \dp\MT@Tbox\dp\MT@APbox%
      \sbox{\MT@Abox}{$\m@th#1\xusebox{\MT@Tbox}\MT@SetSup$}%
      \ifdim\wd\MT@Abox<\wd\MT@Sbox%
          \leavevmode\rlap{\usebox\MT@Abox}{\usebox\MT@Sbox}%
      \else%
          \leavevmode\rlap{\usebox\MT@Sbox}{\usebox\MT@Abox}%
      \fi}
\newcommand*{\MT@UnderAandB}{%
   \mathpalette\MT@@UnderAandB}
\newcommand*{\MT@@UnderAandB}[2]{%
      \sbox{\MT@Tbox}{$\m@th#1\MT@accent{\MT@Symb{#2}}$}%
      \setbox\MT@SPbox\null%
      \wd\MT@SPbox\wd\MT@Tbox%
      \sbox{\MT@Tbox}{$\m@th#1\MT@Symb{#2}$}%
      \ht\MT@SPbox\ht\MT@Tbox%
      \dp\MT@SPbox\dp\MT@Tbox%
      \sbox{\MT@APbox}{$\m@th\MT@@cmd{#1}{\copy\MT@SPbox}$}%
      \setlength{\MT@Wwdth}{\the\wd\MT@APbox}%
      \addtolength{\MT@Wwdth}{-\the\wd\MT@SPbox}%
      \sbox{\MT@Sbox}{$\m@th#1%
         \hskip 0.5\MT@Wwdth\relax\MT@accent{\MT@Symb{#2}}\MT@SetSup$}%
      \sbox{\MT@Abox}{$\m@th#1\xusebox{\MT@APbox}\MT@SetSub$}%
      \ifdim\wd\MT@Abox<\wd\MT@Sbox%
         \leavevmode\rlap{\usebox\MT@Abox}{\usebox\MT@Sbox}%
      \else%
         \leavevmode\rlap{\usebox\MT@Sbox}{\usebox\MT@Abox}%
      \fi}
\newcommand*{\MT@@bSb}[2]{\MT@Overline{#1}{\MT@Underline{#1}{\MT@Symb{#2}}}}
\newcommand*{\MT@@aSb}[2]{\MT@Overarrow{#1}{\MT@Underline{#1}{\MT@Symb{#2}}}}
\newcommand*{\MT@@bSa}[2]{\MT@Overline{#1}{\MT@Underarrow{#1}{\MT@Symb{#2}}}}
\newcommand*{\MT@@aSa}[2]{\MT@Overarrow{#1}{\MT@Underarrow{#1}{\MT@Symb{#2}}}}
\newcommand*{\MT@@bCSb}[2]{\MT@Overline{#1}{\MT@Underline{#1}{\MT@SymbC{#2}}}}
\newcommand*{\MT@@aCSa}[2]{\MT@Overarrow{#1}{\MT@Underarrow{#1}{\MT@SymbC{#2}}}}
\newcommand*{\MT@DoubleAandB}{%
  \mathpalette\MT@@DoubleAandB}
\newcommand*{\MT@@DoubleAandB}[2]{%
      \sbox{\MT@Abox}{$\m@th#1\MT@@cmd{#1}{#2}$}%
      \sbox{\MT@Tbox}{$\m@th#1\MT@accent{\xusebox{\MT@Abox}}$}%
      \ht\MT@Tbox\ht\MT@Abox%
      \dp\MT@Tbox\dp\MT@Abox%
      \xusebox{\MT@Tbox}\MT@SetSup\MT@SetSub}
\endinput
%%
%% End of file `mattens.sty'.
