2

I am hoping to render something similar to a ket (from the braket package), but where each line is 'doubled'. For example, something similar to this:

enter image description here

I would like it to...

  • stretch vertically to contain the contents, like \ket{x} does
  • have subscripts placed below it in the same location that \ket{x}_n prescribes.

Here are some insufficient attempts (both using commands from the braket package):

  • \ket{\ket{x}}. It looks like this:

    enter image description here

    Blegh!

  • \| x \rangle!\rangle. It looks like the first image in this post, but it doesn't scale vertically, and it doesn't place subscripts in the right location.

    E.g. \| \frac{x}{y} \rangle\!\rangle looks like

    enter image description here

    and \| x \rangle!\rangle_y looks like

    enter image description here

  • \ket{\!\ket{x}\hspace{-2.7pt}}. This renders okay, but the spacing between the lines varies with the height of the contents.

    enter image description here

How can I achieve something visually similar to \|x\rangle!\rangle but which correctly stretches vertically to contain its contents, and which places subscripts at the same vertical position as \ket{x}? This will be used exclusively in math environments.

  • Only your 5th (of 7) links are really relevant to my question - the others have solutions which happen to overlap, but are focused on symmetric brackets. Shamefully, the 'duplicate' link used to close this question is straight up wrong - that question is not a duplicate, since it asks about a single ket and doesn't relate in any way to a double ket nor the problems it introduces. The state of this site! – Anti Earth Dec 14 '21 at 04:41
  • @AntiEarth -- Some additional corrections would be appreciated in your code: In two places, the \! appears as only !; and in two images, only one \rangle appears. I hesitate to make these changes since you are more familiar with what you want to see. – barbara beeton Dec 17 '21 at 14:39
  • @AntiEarth -- If this is "recognized" notation, it would be a good addition to the braket package. The author's address shown in the documentation is still valid, even if the package is old. If you write to him, you can say I suggested it, and point to this question. – barbara beeton Dec 17 '21 at 15:07
  • @barbarabeeton those are not mistakes in my question; I am demonstrating the behaviour of the candidate solution against a single ket. I think the text makes this clear – Anti Earth Dec 21 '21 at 01:56
  • @AntiEarth -- I fail to see how the code \| x \rangle!\rangle_y would produce the output shown. With no backslash preceding the exclamation mark, the ! should appear in the output. That is what I am trying to point out. (I'm ignoring that only one \rangle appears.) I don't question that the output isn't what you want. – barbara beeton Dec 21 '21 at 05:12

2 Answers2

5

In amssymb and most other packages, ‖ is \Vert, which also has the aliases \lVert for \mathopen{Vert} and \rVert for \mathclose{Vert}.

Many packages define the ⟫ math symbol as \rAngle, and a few as \rrangle. There is similarly a \lAngle. This works with unicode-math, or see the Comprehensive LaTeX Symbols list for legacy 8-bit packages. You do not want to use the French-style quotation marks, as those will not properly scale in math mode.

The macros for paired, sized delimiters in mathtools are very handy for this.

\documentclass{article}
\usepackage{mathtools}
\usepackage{newcomputermodern} % Or stix2, etc.

\DeclarePairedDelimiter{\Bra}{\lAngle}{\rVert} \DeclarePairedDelimiter{\Ket}{\lVert}{\rAngle}

\begin{document} [ \Bra*{\frac{x^2}{2}} ; \Ket{y} ; \Ket[\big]{x_i^n} ] \end{document}

New Computer Modern sample

The newcomputermodern package needs LuaLaTeX or XeLaTeX, but you can substitute your font package of choice.

If you need a three-argument double bra-ket which scales its inner delimiters, there is a code sample in section 3.6 of the mathtools manual.

Davislor
  • 44,045
3

I got some inspiration from this nice answer and came up with this approach:

\documentclass{article}

\newsavebox{\mstrut} \newcommand{\bbra}[1]{% \sbox{\mstrut}{(#1)}% \mathinner{\left\langle\kern-0.5\ht\mstrut\left\langle{#1}\right|\mkern-2mu\right|}% } \newcommand{\kett}[1]{% \sbox{\mstrut}{(#1)}% \mathinner{\left|\mkern-2mu\left|{#1}\right\rangle\kern-0.5\ht\mstrut\right\rangle}% }

\begin{document}

$\bbra{x}_n$

$\kett{x}_n$

$\bbra{\frac{x}{y}}_n$

$\kett{\frac{x}{y}}_n$

\end{document}

enter image description here