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
312 stars 8 forks source link

Match size of brakets #29

Open mpmdean opened 3 months ago

mpmdean commented 3 months ago

Thanks for the nice package.

If I write

$ braket(f, D^dagger , n) braket(n, D, i) $ The left and right brakets don't match

Screenshot 2024-05-15 at 12 48 00 PM

I failed to work out how to add a hidden superscript, which seems like the natural way to address this?

Leedehai commented 3 months ago

Hi, I'm glad that you find the package useful!

This issue is actually part of Typst itself: a symbol's attachment (superscript, subscript) can affect the symbol frame's overall height, and the bracket's height is too sensitive on the content's height - though we certainly want the bracket to be taller if the contained symbol is very tall, e.g. an integration symbol. Maybe you could consider filing an issue on https://github.com/typst/typst.

YDX-2147483647 commented 3 months ago

Besides, the height of lr is settable. Maybe we can add a size argument to braket?

https://github.com/Leedehai/typst-physics/blob/e36043094294557da4493a1ed62c54fa2ab75d4a/physica.typ#L471-L476

//  This is NOT a full solution.
#set math.lr(size: 500%)

$ lr(angle.l D angle.r) $

Left/Right Functions – Typst Documentation

Leedehai commented 3 months ago

Maybe we can add a size argument to braket?

Hi - that's a great idea. Feel free to open a PR:) However, I noticed Typst's lr() doesn't handle mid() well with the size parameter. I think that'd be a blocking issue:

#set math.lr(size: 500%)

$ lr(angle.l A mid(|) B angle.r), lr(angle.l A B angle.r) $
sjfhsjfh commented 3 months ago

https://github.com/typst/typst/issues/3186