astrale-sharp / typstfmt

Apache License 2.0
253 stars 25 forks source link

typstfmt remove all indent of math block #113

Closed taooceros closed 1 year ago

taooceros commented 1 year ago
$
    EE_(i_k sim "Unif"({1,...,d}))[f(xx_(k+1)) - f(xx_k)] 
        &<= sum_(i=1)^d 1/d (delta nabla_i f(x_k) + L_i/2 delta^2) \
        &= 1/d sum_(i=1)^d (-alpha_i_k nabla_i f(x_k)^2 + alpha^2_i_k L_i/2 nabla_i f(x_k)^2) \
        &= 1/d sum_(i=1)^d (-alpha_i_k + alpha^2_i_k L_i/2) nabla_i f(x_k)^2 \
$

->

$
  EE_(i_k sim "Unif"({1,...,d}))[f(xx_(k+1)) - f(xx_k)] 
  &<= sum_(i=1)^d 1/d (delta nabla_i f(x_k) + L_i/2 delta^2) \
  &= 1/d sum_(i=1)^d (-alpha_i_k nabla_i f(x_k)^2 + alpha^2_i_k L_i/2 nabla_i f(x_k)^2) \
  &= 1/d sum_(i=1)^d (-alpha_i_k + alpha^2_i_k L_i/2) nabla_i f(x_k)^2 \
$
astrale-sharp commented 1 year ago

I see the problem, one indent should be added before each & in math mode, that would be a good first issue and time is incredibly lacking for me right now ! So if there's any takers

taooceros commented 1 year ago

I really wish to help but this is a really tough semester for me sorry...

astrale-sharp commented 1 year ago

Time is a precious resource ;)

taooceros commented 1 year ago

@astrale-sharp Do you mind sharing with me about where the math code is being formatted in the code? I really wish to have this feature.

astrale-sharp commented 1 year ago

Sure, Equation in itself doesn't get formatted specially at the moment but you could add Equation => {...} here

You should get a look at no_format(...) in the same file to get an idea of what to do, you'd probably have to match again MathAlignPoint for node.kind()

Feel free to ask me for help!

taooceros commented 1 year ago

I see, thanks!