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

Derivative delimiter matching #26

Open th1j5 opened 5 months ago

th1j5 commented 5 months ago

When writing out a formula, I would want to achieve something like (3). Only (1),(2) and (4) are easily feasible in typst (with physica), without the manual size adjustment in (3) and (5), which is still not exactly the same as automatic typesetting would have it (compare the size of the parentheses in (5)).

I know little about typesetting (and typst), but I thought it might be an improvement upon things when one doesn't have to manually 'guess' the size for these parentheses, but let it be done automatically by the dv function? image

// No aligment, see e.g. https://github.com/typst/typst/pull/1849
$ &dv(          (f(x) plus.minus g(x)) ,x, s:#none)  &= ... $
$ &dv(          (f(x) plus.minus g(x)) ,x, s:slash)  &= ... $
$ &dv(,x)   lr( (f(x) plus.minus g(x)) ,size: #200%) &= ... $
$ &(dv(,x))     (f(x) plus.minus g(x))               &= ... $
$ &(dv(,x)) lr( (f(x) plus.minus g(x)) ,size: #200%) &= ... $
  1. What is your opinion on this? Should this be supported by physica, or is my way (lr(... ,size: #200%)) the 'best' way (I'd like to think not...)?
  2. If this could be supported by physica, how would one do this?
    • I would suggest to have another option in the s: argument of dv (and similar commands). This option would ask that the function is pretty large and thus needs this particular typesetting. How would we call this option? large_function, ...
    • The implementation could look something like the following pseudo-code? size = maximum(height of the content box, height of the d/dx box) where size is the height of the parentheses.