typst / webapp-issues

Issue tracker for Typst's web app.
https://typst.app
13 stars 0 forks source link

Multiline equation workflow #261

Open Mc-Zen opened 10 months ago

Mc-Zen commented 10 months ago

Description

I usually find myself formatting multiline equations like this:

$ 
  U_(k l)^dagger &= sum_(j=0)^(d-1) zeta^(-(j-k) l) |j-k〉〈j| \
                 &= zeta^(k l) U_(-k, -l) = U^(-1)
$

with the dollar signs on an individual line and the equation content indented by two spaces. Maybe, the app could help improving the workflow by behaving the same way for $$ as for curly braces.

In detail:

  1. When starting with a single dollar sign, a second one is added after the cursor (already the current behaviour): $|$
  2. When pressing enter, a linebreak and two spaces are inserted, and an additional linebreak after the cursor:
    $
    |
    $

Use Case

I think this would help make the workflow better and support readable formatting of equations.

Mc-Zen commented 1 week ago

I'd like to bump this because it would be really useful and improve the experience when writing out math considerably.

In Tinymist, it has already been realized https://github.com/Myriad-Dreamin/tinymist/issues/548

Basically, the dollar signs $$ just need to behave like the square brackets [] and curly braces {}.

laurmaedje commented 1 week ago

I guess it's time to give up on my personal formatting preference. It is clearly less practical though imo it looks better:

$ sum_(k=0)^n k
    &= 1 + ... + n \
    &= (n(n+1)) / 2 $
Mc-Zen commented 1 week ago
$ sum_(k=0)^n k
    &= 1 + ... + n \
    &= (n(n+1)) / 2 $

I just tried out this formatting with a "real-world" document but the source code is just more readable the other way, by an order of magnitude. The additional whitespace clears up the structure and helps the eye to orientate when there are many equations.

As a remark: this feature request does not worsen the situation for the more compact version since it only kicks in when hitting Enter after typing the $.

laurmaedje commented 1 week ago

As a remark: this feature request does not worsen the situation for the more compact version since it only kicks in when hitting Enter after typing the $.

Indeed, I also realized that. It's more that it implies that newlines are good style. Which I guess they are! As said, I have kinda given up on my original style preference.