Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mel needs beautify #16

Closed
zrt2002 opened this issue Nov 21, 2023 · 3 comments
Closed

mel needs beautify #16

zrt2002 opened this issue Nov 21, 2023 · 3 comments

Comments

@zrt2002
Copy link

zrt2002 commented Nov 21, 2023

This code snippet
$ mel(phi_n^0, sqrt((2 hbar) / (m omega))(a^dagger + a), phi_n^0) $
gives
image
in which the vertical bar is too bold and slightly higher than my braket. Besides, the space between alphabet and bar is too tight.

@Leedehai
Copy link
Owner

Leedehai commented Nov 21, 2023

Thanks. Admittedly this has been a longstanding pain issue and I do not have an answer.

Boldness and tightness: sorry, this is rooted in Typst's layout strategy and could not be solved cleanly at the package level. Especially, I think the boldness is caused by some issue deep inside the compiler's stretch_glyph() function: stretching by height shouldn't affect the width. I just created typst/typst#2737.

Height of vertical bar: the package uses a hack to calculate the height, and it is not reliable as you saw from the example. Maybe I could use quadratic interpolation to calculate an adjustment factor based on the element height [1], but that's unreliable, too. There's an issue created at Typst (typst/typst#240), and I very much look forward to a native solution to get rid of the hack.

I urge you to raise the Typst contributor's awareness so they could prioritize :)

[1] In the meantime, I'll find some time and do it in this package.

Leedehai added a commit that referenced this issue Nov 22, 2023
…ution for braket etc.

Not satisfactory, until Typst resolves typst/typst#240

This interim solution can handle
$ mel(u,M,v) mel(u,vec(U,V),v), mel(vec(U,V),M,v) $
but not something like
$ mel(u,vec(U,V,W),v) mel(vec(U,V,W),M,v) $

Motivated by #16
@Leedehai
Copy link
Owner

Update: I have a draft to make the Typst compiler handle this natively: https://github.com/Leedehai/typst/pull/1/files

@Leedehai
Copy link
Owner

Leedehai commented Dec 4, 2023

Upgraded physica to v0.9.0. It requires Typst compiler 0.10.0 (released a few hours ago; update with typst update), which has my PRs typst/typst#2760 and typst/typst#2764 to fix this issue.

Screenshot 2023-12-04 at 18 46 56

After typst/packages#277 is merged as well, physica v0.9.0 will be auto-downloadable by the compiler and the typst.app web app.

@Leedehai Leedehai closed this as completed Dec 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants