%% %% This is file `phy-ab.sty', %% the `ab' 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.sty} [2023/04/02 `ab' (autobraces) module of `physics2.sty'] % \phy@requiremodule{common} % The `tightbraces' bool option, true or false. \phy@define@key{ab}{tightbraces}[true]{\def\@phy@abtight{#1}} % Execute the default values to keys in this module. \phy@setkeys{ab}{tightbraces=true} \phy@processkeyopt{ab} % \phy@abopen and \phy@abclose, % internal definition for all commands in this module. \ifx\@phy@abtight\phy@true \let\phy@abopen\delopen \let\phy@abclose\delclose \else \let\phy@abopen\left \let\phy@abclose\right \fi % The internal version of \ab. #1: `ab' or `mb'; #2: open symbol; (#3: arg-spec; #4: definition) \def\phy@AB@gen#1#2{\expandafter\DeclareDocumentCommand\csname phy@#1@\string#2\endcsname} % #1 (r): inner content. \phy@AB@gen{ab}({r()}{\phy@abopen(#1\phy@abclose)} \phy@AB@gen{ab}[{r[]}{\phy@abopen[#1\phy@abclose]} \phy@AB@gen{ab}\{{r\{\}}{\phy@abopen\{#1\phy@abclose\}} \phy@AB@gen{ab}|{r||}{\phy@abopen|#1\phy@abclose|} \phy@AB@gen{ab}\|{r\|\|}{\phy@abopen\|#1\phy@abclose\|} \phy@AB@gen{ab}<{r<>}{\phy@abopen<#1\phy@abclose>} \phy@AB@gen{ab}\lbrace{r\lbrace\rbrace}{\phy@abopen\lbrace#1\phy@abclose\rbrace} \phy@AB@gen{ab}\vert{r\vert\vert}{\phy@abopen\vert#1\phy@abclose\vert} \phy@AB@gen{ab}\Vert{r\Vert\Vert}{\phy@abopen\Vert#1\phy@abclose\Vert} \phy@AB@gen{ab}\langle{r\langle\rangle}{\phy@abopen\langle#1\phy@abclose\rangle} % #1 (m): \biggg; #2 (r): inner content. % \endgroup's in the end of definition are corresponding to \begingroup in \phy@d@l@genxm. \phy@AB@gen{mb}({mr()}{\mathopen#1(#2\mathclose#1)\endgroup} \phy@AB@gen{mb}[{mr[]}{\mathopen#1[#2\mathclose#1]\endgroup} \phy@AB@gen{mb}\{{mr\{\}}{\mathopen#1\lbrace#2\mathclose#1\rbrace\endgroup} \phy@AB@gen{mb}|{mr||}{\mathopen#1\vert#2\mathclose#1\vert\endgroup} \phy@AB@gen{mb}\|{mr\|\|}{\mathopen#1\Vert#2\mathclose#1\Vert\endgroup} \phy@AB@gen{mb}<{mr<>}{\mathopen#1\langle#2\mathclose#1\rangle\endgroup} \phy@AB@gen{mb}\lbrace{mr\lbrace\rbrace}{\mathopen#1\lbrace#2\mathclose#1\rbrace\endgroup} \phy@AB@gen{mb}\vert{mr\vert\vert}{\mathopen#1\vert#2\mathclose#1\vert\endgroup} \phy@AB@gen{mb}\Vert{mr\Vert\Vert}{\mathopen#1\Vert#2\mathclose#1\Vert\endgroup} \phy@AB@gen{mb}\langle{mr\langle\rangle}{\mathopen#1\langle#2\mathclose#1\rangle\endgroup} % \phy@del, the automatic braces. #1: opensymbol; #2: close symbol; #3 \def\phy@del#1#2#3{\phy@abopen#1#3\phy@abclose#2} \expandafter\def\csname phy@del\string*\endcsname#1#2#3{\mathopen#1#3\mathclose#2} \expandafter\def\csname phy@del\string\big\endcsname#1#2#3{\bigl#1#3\bigr#2} \expandafter\def\csname phy@del\string\Big\endcsname#1#2#3{\Bigl#1#3\Bigr#2} \expandafter\def\csname phy@del\string\bigg\endcsname#1#2#3{\biggl#1#3\biggr#2} \expandafter\def\csname phy@del\string\Bigg\endcsname#1#2#3{\Biggl#1#3\Biggr#2} \expandafter\def\csname phy@del\string\biggg\endcsname#1#2#3{\bigggl#1#3\bigggr#2} \expandafter\def\csname phy@del\string\Biggg\endcsname#1#2#3{\Bigggl#1#3\Bigggr#2} % \phy@d@lx (phy_del_x): the internal defination of \ab. % #1: `mb', according to \phy@AB@gen; #2: `ab'; #3: star or big or left delimiter. \def\phy@d@lx#1#2#3{% \ifcsname phy@del\string#3\endcsname% \def\reserved@a{#1}% #3 is star or \biggg, then get the next argument. \else% \def\reserved@a{#2}% #3 is delimiter, the braces are automatic. \fi% \csname phy@d@lx\reserved@a\endcsname#3} % The first two arguments of \phy@d@lx need to be generated by the following two commands. \def\phy@d@l@genxm#1{% generate arguments like `mb' \expandafter\def\csname phy@d@lx#1\endcsname##1##2{% \begingroup% \endgroup in \phy@AB@gen{mb} \ifx##1*\let\phy@tempa=\relax\else\let\phy@tempa=##1\fi \csname phy@#1@\string##2\endcsname\phy@tempa##2}} \def\phy@d@l@genxa#1{% generate arguments like `ab' \expandafter\def\csname phy@d@lx#1\endcsname##1{% \csname phy@#1@\string##1\endcsname##1}} % Generate the `mb' and `ab' arguments. \phy@d@l@genxm{mb} \phy@d@l@genxa{ab} % \ab(), after \ab can be a star or \biggg. \DeclareRobustCommand\ab{\phy@d@lx{mb}{ab}} % \phy@d@l@geny: define commands like \pab. #1: cs; #2: open symbol; #3: close symbol. \def\phy@d@l@geny#1#2#3{% \DeclareDocumentCommand#1{som}{% ##1: star; ##2: bigg (csname); ##3: subformula. \IfBooleanTF{##1}% {#2##3#3}% {\IfValueTF{##2}% {\csname##2l\endcsname#2##3\csname##2r\endcsname#3}% {\phy@abopen#2##3\phy@abclose#3}% }% }% } \phy@d@l@geny\pab() \phy@d@l@geny\bab[] \phy@d@l@geny\Bab\lbrace\rbrace \phy@d@l@geny\vab\vert\vert \phy@d@l@geny\aab\langle\rangle \phy@d@l@geny\Vab\Vert\Vert \endinput %% End of file `phy-ab.sty'.