I want to typeset Hilbert-Schmidt-Products as the Liouville-Equivalent of the Hilbert Space Braket, with doubled delimiters, like this: \Lbraket{\rho|\rho} results in <<rho|rho>>.
I was trying to adapt the definition of \Braket from the Braket package to do this, ending up with the following code:
{\catcode`\|=\active
\xdef\Lbraket{\protect\expandafter\noexpand\csname Lbraket \endcsname}
\expandafter\gdef\csname Lbraket \endcsname#1{\begingroup
\ifx\SavedDoubleVert\relax
\let\SavedDoubleVert\|\let\|\BraDoubleVert
\fi
\mathcode`\|32768\let|\BraVert
\left\langle\kern-0.2em\left\langle{#1}\right\rangle\kern-0.2em\right\rangle\endgroup}
}
\def\BraVert{\@ifnextchar|{\|\@gobble}% turn || into \|
{\egroup\,\mid@vertical\,\bgroup}}
\def\BraDoubleVert{\egroup\,\mid@dblvertical\,\bgroup}
\let\SavedDoubleVert\relax
\begingroup
\edef\@tempa{\meaning\middle}
\edef\@tempb{\string\middle}
\expandafter \endgroup \ifx\@tempa\@tempb
\def\mid@vertical{\middle|}
\def\mid@dblvertical{\middle\SavedDoubleVert}
\else
\def\mid@vertical{\mskip1mu\vrule\mskip1mu}
\def\mid@dblvertical{\mskip1mu\vrule\mskip2.5mu\vrule\mskip1mu}
\fi
This works, but for very large formulas the double delimiters are not sufficiently tight, and the negative kerning should be larger.
On the other hand, I've found some code that allows to define double delimiters
and doesn't seem to suffer from the same problem. The following is from a
newsgroup posting, it defines \lleft and \rright so that e.g.
\lleft\langle results in <<.
\catcode`@=11
\def\lleft#1#2\rright{\begingroup%
\def\ts@r{\nulldelimiterspace=0pt \mathsurround=0pt}%
\let\@hat=#1%
\def\sht@im{#2}%
\def\@t{{\mathchoice{\def\@fen{\displaystyle}\k@fel}%
{\def\@fen{\textstyle}\k@fel}%
{\def\@fen{\scriptstyle}\k@fel}%
{\def\@fen{\scriptscriptstyle}\k@fel}}}%
\def\g@rin{\ts@r\left\@hat\vphantom{\sht@im}\right.}%
\def\k@fel{\setbox0=\hbox{$\@fen\g@rin$}\hbox{%
$\@fen \kern.3875\wd0 \copy0 \kern-.3875\wd0%
\llap{\copy0}\kern.3875\wd0$}}%
\def\pt@h{\mathopen\@t}\pt@h\sht@im%
\rright}%
\def\rright#1{\let\@hat=#1%
\def\st@m{\mathclose\@t}%
\st@m\endgroup}
\catcode`@=12
My question is if there's a way to combine to two code snippets to get a correctly resizing Braket with doubled delimiters. Simply doing the following does not work:
{\catcode`\|=\active
\xdef\LBraket{\protect\expandafter\noexpand\csname LBraket \endcsname}
\expandafter\gdef\csname LBraket \endcsname#1{\begingroup
\ifx\SavedDoubleVert\relax
\let\SavedDoubleVert\|\let\|\BraDoubleVert
\fi
\mathcode`\|32768\let|\BraVert
\lleft\langle{#1}\rright\rangle\endgroup}
}
This results in an error message:
! Extra \middle.
\mid@vertical ->\middle |
My knowledge of lowlevel TeX is not anywhere near sufficient to understand how
the implementation of \lleft and \rright works, but maybe someone sees
whether the two snippets can be combined.
\LBraket{\rho| \hat{\hat{A}} | \rho}, the way\Braketdoes. Would there be a way to incorporate that as well? – Michael Goerz Oct 27 '11 at 20:26\lleftmacro works... what's the trick there? – Michael Goerz Oct 28 '11 at 11:39\lleftand\rrightmagic. :) – egreg Oct 28 '11 at 12:39\LBlleft{\{[}#1{]\}}\LBrright. I mean to set two different delimiters. – Marco Daniel Oct 29 '11 at 08:40