Leedehai / typst-physics

physica: vectors, fields, differentials, derivatives, Dirac brakets, tensors, and more. See examples in the manual PDF.
https://github.com/Leedehai/typst-physics
MIT License
359 stars 11 forks source link

Improve braket #1

Closed peng1999 closed 1 year ago

peng1999 commented 1 year ago

Current implementation gives inconsistent height of angles and vertical bars in braket. Until typst/typst#641 have merged, I propose to use following workaround to make the formula more pleasant.

#let braket(bra, ket) = style(styles => {
  let height = measure($ bra ket $, styles).height;
  let phantom = box(height: height, width: 0pt, inset: 0pt, stroke: none);
  $ lr(angle.l bra lr(|phantom#h(0pt)) ket angle.r) $
})

Result: image

Leedehai commented 1 year ago

谢啦