3

I am using the \usepackage{physics} package and want to write something using bra-ket notation but with a double bar in the middle (physicist's notation in Quantum Chemistry). It can be written as \braket{0||0} using the \usepackage{braket} package, however it is much more useful for me to use the {physics} package for the majority of my work. I cannot use the {braket} package as the command \braket is already a command in the {physics} package, and I don't want to tamper previous pages I've written using the physics package. So I guess I have 2 questions.

1) Can you write the equation in the picture using the physics package? Equation to br written

2) Is it possible to import both packages but call on the \braket command from different packages when I choose? For example, I may want to use the command from the physics package for my first equation, but the braket package for my second equation.

2
  • I don't have time to work up a proper answer, but here is an idea: Use the mathtools package. Look for \braket in the documentation, and learn how to build your own. You can call it whatever you wish. Jan 9, 2018 at 8:59
  • You can use $\mel{ij}{}{jk}$.
    – Sandy G
    Jan 9, 2018 at 17:16

2 Answers 2

1

The physics package can do this using matrix element commands \matrixel, or \mel for short. The code

\documentclass{article}
\usepackage{physics}
\begin{document}

$\mel{ij}{}{kl}$

\end{document}

Will produce the desired output. If desired, an additional second argument can be inserted. (It is empty in the example.)

enter image description here

There are two other forms of the \mel command: \mel* and mel**. The no-star version adjusts the delimiter heights based on the first and third arguments, but not the second. The one-star version does no resizing at all. The two-star version resizes delimiters based on all three arguments. For example, the code

$\mel{\rule{2pt}{2ex}}{\rule{2pt}{3ex}}{kl}\quad%
\mel*{\rule{2pt}{2ex}}{\rule{2pt}{3ex}}{kl}\quad%
\mel**{\rule{2pt}{2ex}}{\rule{2pt}{3ex}}{kl}$

produces the output:

enter image description here

Note that there appears to be a spacing inconsistency between the no-star and one-star versions, compared to the two-star version. The difference appears to be exactly a thinspace. Consider the following code and its output:

H$\mel{ij}{}{kl}$H

H$\mel*{ij}{}{kl}$H

H$\mel**{ij}{}{kl}$H 

enter image description here

The spacing on the left and right is equalized by inserting a negative thin space (\!) before \mel or \mel*.

0
1

I propose a solution based on mathtools, xparse and etoolbox. The syntax is \mybraket{1st argt | 2nd argt |3rd arrgt}. The separator for arguments is |, but it may be changed to, say, a comma or a semi-colon.

This command can take an optional size argument (\big, \Big,&c.). Alternatively, the starred version\mybracket* adds an implicit \left \right pair before the delimiters.

\documentclass{article}
\usepackage{mathtools}
\usepackage{physics}
\usepackage{xparse, etoolbox}

\DeclarePairedDelimiterX\mybraket[1]{\langle}{\rangle}{\braketargs{#1}}%
\NewDocumentCommand{\braketargs}{ >{\SplitArgument{2}{|}}m }
{\braketargsaux#1}
\NewDocumentCommand{\braketargsaux}{ m m m}%
{\IfNoValueTF{#3}{\IfNoValueTF{#2}{#1}{#1\,\delimsize\vert\,\mathopen{}#2}}%
{\ifblank{#2}{#1\,\delimsize\vert\mkern-1mu\delimsize\vert\,\mathopen{}#3}%
{#1\,\delimsize\vert\,\mathopen{}#2\,\delimsize\vert\,\mathopen{}#3}}}%

\begin{document}


\[ \mybraket*{ij}\quad\mybraket[\big]{ij||jk} \quad\mybraket[\big]{ij|\ell|jk}\]%

\end{document} 

enter image description here

1
  • I vote also to you +1. Thanks for the help on site Mathematics.
    – Sebastiano
    Jan 9, 2018 at 18:05

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .