2
\documentclass{article}
\usepackage{physics}
\begin{document}
    \fboxsep=0pt
    This is some \fbox{$\ev*{\hat{O}_P}$} and then some.
\end{document}

enter image description here

There seems to be extra spacing added before the left angle bracket as opposed to the space after the right angle bracket when using \ev*. Is there anything I can do to fix it if I want to continue using this command from the physics package?

By fix, I mean I want the spacing of the right angle bracket on both sides.

Edit: I realized it does not happen with the non-starred version of the command, \ev{\hat{O}_P} gives the correct spacing on both sides. And that the problem seems to carry over to other starred commands like \ket*{x} and \bra*{x} where additional space is added to the left of the output.

3
  • Do you also get lots of warnings? If you do This is some \fbox{$\langle\hat{O}_P\rangle$} and then some., the spacing will be equal.
    – user121799
    Oct 1, 2018 at 5:10
  • @marmot No, do you? I know, but it's a hassle to write that, I'ld prefer to continue using hte ev command. I'm hoping for some patch I could implement to the command.
    – ksgj1
    Oct 1, 2018 at 5:23
  • Yes, I do. Meanwhile you got an answer, which suggests not to use the package. You may just load the braket package and try \fbox{$\braket{\hat{O}_P}$}.
    – user121799
    Oct 1, 2018 at 9:06

1 Answer 1

10

I looked at the definition of \ev in the physics package. In your case it essentially reduces to

\vphantom{\hat{O}_P}\left\langle\smash{\hat{O}_P}\right\rangle

The \vphantom{\hat{O}_P} will insert a box of zero width and of type mathord, but when followed by a mathopen atom (which \left makes automatically), spacing is inserted.

The definition of \ev makes absolutely no sense. The implementers are trying to reverse the effect of the automatic scaling of \left and \right by using \smash to hide the height of the content, but then the construct will have no height and depth, so they reinserted using \vphantom.

The package code is also full of spurious spaces. Considering the quality of the implementation, the best way to fix this issue is by not using the physics package.

2

You must log in to answer this question.

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