%%
%% This is file `delimset.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% delimset.dtx  (with options: `package')
%% 
%% Copyright (C) 2016-2018 Niklas Beisert
%% 
%% 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.
%% 
\NeedsTeXFormat{LaTeX2e}[1996/12/01]
\ProvidesPackage{delimset}[2018/12/30 v1.1 convenient size control for delimiter sets]

\RequirePackage{amsmath}
\RequirePackage{keyval}

\newif\ifdlm@std\dlm@stdtrue
\newif\ifdlm@ext\dlm@extfalse
\newif\ifdlm@script\dlm@scripttrue

\def\dlm@group{dlm@}
\define@key{\dlm@group}{stddef}[true]{\csname dlm@std#1\endcsname}
\define@key{\dlm@group}{extdef}[true]{\csname dlm@ext#1\endcsname}
\define@key{\dlm@group}{scriptstyle}[true]{\csname dlm@script#1\endcsname}

\DeclareOption*{\expandafter\setkeys\expandafter\dlm@group%
  \expandafter{\CurrentOption}}
\ProcessOptions

\ifdlm@script
\def\bBigg@choice#1#2#3#4{%
  {\@mathmeasure\z@{\nulldelimiterspace\z@}%
     {\big@size#2\big@size#1\left#4\vcenter to#3\big@size{}\right.}%
   \box\z@}}
\def\bBigg@#1#2{{\mathchoice%
  {\bBigg@choice{\displaystyle}{1}{#1}{#2}}%
  {\bBigg@choice{\textstyle}{1}{#1}{#2}}%
  {\bBigg@choice{\scriptstyle}{0.7}{#1}{#2}}%
  {\bBigg@choice{\scriptscriptstyle}{0.5}{#1}{#2}}}}
\fi

\newcommand{\bigp}{\mathpunct\big}
\newcommand{\Bigp}{\mathpunct\Big}
\newcommand{\biggp}{\mathpunct\bigg}
\newcommand{\Biggp}{\mathpunct\Bigg}
\newcommand{\bigb}{\mathbin\big}
\newcommand{\Bigb}{\mathbin\Big}
\newcommand{\biggb}{\mathbin\bigg}
\newcommand{\Biggb}{\mathbin\Bigg}

\newcommand{\dlm@class}[1]{\csname dlm@class@#1\endcsname}
\newcommand{\dlm@class@}{}
\newcommand{\dlm@class@l}{\mathopen}
\newcommand{\dlm@class@r}{\mathclose}
\newcommand{\dlm@class@o}{\mathopen}
\newcommand{\dlm@class@c}{\mathclose}
\newcommand{\dlm@class@m}{\mathrel}
\newcommand{\dlm@class@p}{\mathpunct}
\newcommand{\dlm@class@b}{\mathbin}
\newcommand{\dlm@norm}[1]{\dlm@class{#1}\bBigg@{0.0}}
\newcommand{\dlm@big}[1]{\dlm@class{#1}\big}
\newcommand{\dlm@Big}[1]{\dlm@class{#1}\Big}
\newcommand{\dlm@bigg}[1]{\dlm@class{#1}\bigg}
\newcommand{\dlm@Bigg}[1]{\dlm@class{#1}\Bigg}
\newcommand{\dlm@var}[1]{\csname dlm@var@#1\endcsname}
\newcommand{\dlm@var@}[1]{\middle#1}
\newcommand{\dlm@var@l}[1]{\mathopen{}\mathclose\bgroup\left#1}
\newcommand{\dlm@var@r}[1]{\right#1\egroup}
\newcommand{\dlm@var@o}[1]{\mathopen{}\middle#1\mathopen{}}
\newcommand{\dlm@var@c}[1]{\mathclose{}\middle#1\mathclose{}}
\newcommand{\dlm@var@m}[1]{\mathrel{}\middle#1\mathrel{}}
\newcommand{\dlm@var@p}[1]{\middle#1\mathpunct{}}
\newcommand{\dlm@var@b}[1]{\mathbin{}{}\mkern-\medmuskip%
  \middle#1\mkern-\medmuskip{}\mathbin{}}

\newcommand{\dlm@parsesize}[1]{\@ifnextchar\bgroup%
  {\dlm@parsesize@{#1}{0}}{\dlm@parsesize@{#1}}}
\newcommand{\dlm@parsesize@}[2]{\let\dlm@arg\dlm@norm%
  \if0#2\let\dlm@arg\dlm@norm\fi%
  \if1#2\let\dlm@arg\dlm@big\fi%
  \if+#2\let\dlm@arg\dlm@big\fi%
  \if!#2\let\dlm@arg\dlm@big\fi%
  \if2#2\let\dlm@arg\dlm@Big\fi%
  \if3#2\let\dlm@arg\dlm@bigg\fi%
  \if4#2\let\dlm@arg\dlm@Bigg\fi%
  \if*#2\let\dlm@arg\dlm@var\fi%
  #1}

\newcommand{\selectdelim}[2][]{\if.#1#2\else\dlm@arg{#1}#2\fi}

\newcommand{\DeclareMathDelimiterSet}[1]{\expandafter\dlm@declare%
  \csname dlm@dcl@\expandafter\@gobble\string#1\endcsname{#1}}
\def\dlm@declare#1#2{\newcommand{#2}{\dlm@parsesize{#1}}\newcommand{#1}}

\newcommand{\delim}[2]
  {\dlm@parsesize{\dlm@dcl@delim{#1}{#2}}}
\newcommand{\dlm@dcl@delim}[3]
  {\selectdelim[l]#1{#3}\selectdelim[r]#2}

\newcommand{\delimpair}[3]
  {\dlm@parsesize{\dlm@dcl@delimpair{#1}{#2}{#3}}}
\newcommand{\dlm@dcl@delimpair}[5]
  {\selectdelim[l]#1{#4}\selectdelim#2{#5}\selectdelim[r]#3}

\newcommand{\delimtriple}[4]
  {\dlm@parsesize{\dlm@dcl@delimtriple{#1}{#2}{#3}{#4}}}
\newcommand{\dlm@dcl@delimtriple}[7]
  {\selectdelim[l]#1{#5}\selectdelim#2{#6}\selectdelim#3{#7}\selectdelim[r]#4}

\ifdlm@std
\providecommand{\brk}[1][r]{\begingroup\def\dlm@use{\delim()}%
  \if r#1 \def\dlm@use{\delim()}\fi%
  \if s#1 \def\dlm@use{\delim[]}\fi%
  \if c#1 \def\dlm@use{\delim\{\}}\fi%
  \if a#1 \def\dlm@use{\delim<>}\fi%
  \expandafter\endgroup\dlm@use}
\providecommand{\eval}[1][v]{\begingroup\def\dlm@use{\delim.\rvert}%
  \if v#1 \def\dlm@use{\delim.\rvert}\fi%
  \if s#1 \def\dlm@use{\delim[]}\fi%
  \expandafter\endgroup\dlm@use}
\providecommand{\abs}{\delim\lvert\rvert}
\providecommand{\norm}{\delim\lVert\rVert}
\fi

\ifdlm@ext
\providecommand{\pair}{\delimpair({[.],})}
\providecommand{\set}{\delim\{\}}
\providecommand{\setcond}{\delimpair\{|\}}
\providecommand{\intv}[1][c]{\begingroup\def\dlm@use{\delimpair[{[.],}]}%
  \if c#1 \def\dlm@use{\delimpair[{[.],}]}\fi%
  \if l#1 \def\dlm@use{\delimpair]{[.],}]}\fi%
  \if r#1 \def\dlm@use{\delimpair[{[.],}[}\fi%
  \if o#1 \def\dlm@use{\delimpair]{[.],}[}\fi%
  \expandafter\endgroup\dlm@use}
\providecommand{\avg}{\delim<>}
\providecommand{\corr}{\delim<>}
\providecommand{\comm}{\delimpair[{[.],}]}
\providecommand{\acomm}{\delimpair\{{[.],}\}}
\providecommand{\bra}{\delim<|}
\providecommand{\ket}{\delim|>}
\providecommand{\braket}{\delimpair<|>}
\fi

\endinput
%%
%% End of file `delimset.sty'.
