%% 
%% This is file `phy-ab.braket.sty',
%% the `ab.braket' module of `physics2' package.
%% 
%% ******************************************************
%% * This work may be distributed and/or modified under *
%% * the conditions of the LaTeX Project Public License *
%% *                                                    *
%% *     http://www.latex-project.org/lppl.txt          *
%% *                                                    *
%% * either version 1.3c of this license or any later   *
%% * version.                                           *
%% ******************************************************
%% 
%% This work has the LPPL maintenance status `maintained'.
%% 
%% The Current Maintainer of this work is Zhang Tingxuan.
%% 
\ProvidesFile{phy-ab.braket.sty}
  [2023/01/25 `ab.braket' module of `physics2.sty']
% This module requires \phy@abopen and \phy@abclose from `ab'.
\phy@requiremodule{ab}
\ifdefined\phy@bra@@
  \PackageWarning{physics2}{You cannot load `ab.braket' and `braket'
    modules together.\MessageBreak Only `ab.braket' module works now.}
\fi
% \bra<foo|
\phy@AB@gen{br.m}<{mr<|}{\mathopen#1\langle#2\mathclose#1\vert}
\phy@AB@gen{br.a}<{r<|}{\phy@abopen\langle#1\phy@abclose\vert}
\phy@d@l@genxm{br.m}
\phy@d@l@genxa{br.a}
\DeclareRobustCommand\bra{\phy@d@lx{br.m}{br.a}}
% \ket|foo>
\phy@AB@gen{kt.m}|{mr|>}{\mathopen#1\vert#2\mathclose#1\rangle}
\phy@AB@gen{kt.a}|{r|>}{\phy@abopen\vert#1\phy@abclose\rangle}
\phy@d@l@genxm{kt.m}
\phy@d@l@genxa{kt.a}
\DeclareRobustCommand\ket{\phy@d@lx{kt.m}{kt.a}}
% \braket<foo|bar>
\begingroup
\catcode`\|=\active
\gdef\phy@@mb@bk#1#2{\begingroup%
  \mathcode`\|="8000\def|{\egroup#1\vert\bgroup}%
  \def\<{\mathrel{<}}\def\>{\mathrel{>}}%
  \mathopen#1\langle\bgroup#2\egroup\mathclose#1\rangle\endgroup}
\gdef\phy@@ab@bk#1{\begingroup%
  \mathcode`\|="8000\def|{\egroup\phy@abb@bkv\bgroup}%
  \def\<{\mathrel{<}}\def\>{\mathrel{>}}%
  \phy@abopen\langle\bgroup#1\egroup\phy@abclose\rangle\endgroup}
\endgroup
\def\phy@abb@bkv{\middle\vert}
\phy@AB@gen{bk.m}<{mr<>}{\phy@@mb@bk#1{#2}}
\phy@AB@gen{bk.a}<{r<>}{\phy@@ab@bk{#1}}
\phy@d@l@genxm{bk.m}
\phy@d@l@genxa{bk.a}
\DeclareRobustCommand\braket{\phy@d@lx{bk.m}{bk.a}}
% \ketbra|foo>bar<baz|
\begingroup
\catcode`\<=\active
\catcode`\>=\active
\gdef\phy@@mb@kb#1#2{\begingroup%
  \mathcode`\<="8000 \mathcode`\>="8000%
  \def<{#1\langle}\def>{#1\rangle}%
  \def\<{\phy@abb@l}\def\>{\phy@abb@r}%
  \mathopen#1\vert#2\mathclose#1\vert\endgroup}
\endgroup
\gdef\phy@@ab@kb#1>#2<#3\phy@@end{\begingroup%
  \def\<{\phy@abb@l}\def\>{\phy@abb@r}%
  \phy@abopen\vert\mathopen{\phy@mathvphantom{#3}}#1\phy@abclose\rangle#2%
  \phy@abopen\langle#3\mathclose{\phy@mathvphantom{#1}}\phy@abclose\vert%
\endgroup}
\AtBeginDocument{\ifcsname symbf\endcsname%
  \def\phy@abb@l{\Umathchar 3 \symoperators "003C }%
  \def\phy@abb@r{\Umathchar 3 \symoperators "003E }%
\fi}
\def\phy@abb@l{\mathchar"313C }
\def\phy@abb@r{\mathchar"313E }
\phy@AB@gen{kb.m}|{mr||}{\phy@@mb@kb#1{#2}}
\phy@AB@gen{kb.a}|{r||}{\phy@@ab@kb#1\phy@@end}
\phy@d@l@genxm{kb.m}
\phy@d@l@genxa{kb.a}
\DeclareRobustCommand\ketbra{\phy@d@lx{kb.m}{kb.a}}
\endinput
%% End of file `phy-ab.braket.sty'.
