Skip to content

Feat(auto-align): Add support for math equation auto-alignment + tests#27

Draft
Eagle4398 wants to merge 5 commits into
arne314:mainfrom
Eagle4398:typstarTYPST
Draft

Feat(auto-align): Add support for math equation auto-alignment + tests#27
Eagle4398 wants to merge 5 commits into
arne314:mainfrom
Eagle4398:typstarTYPST

Conversation

@Eagle4398

@Eagle4398 Eagle4398 commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

Add support for rapid fast auto-alignment of equations when typing.

  • supports any math equations
  • works within groups or "commands" e.g. a _ (a = b %ali%) --> a _ (a = & b \ & %cursor%)
  • differentiates between equation alignment (selects last equation sign) and logical operator alignment (selects first operator) depending on the symbol chosen for the following line e.g.
a = b = c = d ali --> a = b = c = & d  \n =  & cursor
a <==> b <==> c <===> d --> a <==> & b <==> c <===> d \ <==> ^

The tests characterize behavior:

    ['inline-align-naive'] = ali_wrapper('$ x = a\\C $', "$ x = & a \\\n = &  $"),
    ['multiline-align-naive'] = ali_wrapper('$\\\n x = a\\C \\\n$', "$\\\n x = & a \\\n  = &  \\\n$"),
    ['subscript-align'] = ali_wrapper('$\\\n a = b + sum_( k = 0\\C)\\\n$', "$\\\n a = b + sum_( k = & 0 \\\n  = & )\\\n$"),
    ['subscript-align-2'] = ali_wrapper('$\\\n a = b + sum_( k = 0\\C)\\\n$', "$\\\n a = b + sum_( k = & 0 \\\n    & )\\\n$", " "),
    ['and-test'] = ali_wrapper('$ x = a\\C $', "$ & x = a \\\n and  &  $", "and"),
    ['or-test'] = ali_wrapper('$ x = a\\C $', "$ & x = a \\\n or  &  $", "or"),
    ['iff-test'] = ali_wrapper('$ x = a\\C $', "$ & x = a \\\n <==> &  $", "<==>"),
    ['==>-test'] = ali_wrapper('$ x = a\\C $', "$ & x = a \\\n ==> &  $", "==>"),

    ['multiple-operators'] = ali_wrapper('$ A <==> B <==> C <==> D\\C $', "$ A <==> & B <==> C <==> D \\\n ==> &  $", "==>"),
    ['multiple-operators2'] = ali_wrapper('$ A = B <==> C = D\\C $', "$ A = B <==> & C = D \\\n ==> &  $", "==>"),
    ['multiple-operators3'] = ali_wrapper('$ A = B <==> C = D\\C $', "$ A = B <==> C = & D \\\n = &  $"),

    ['ignore_eq_in_fun'] = ali_wrapper('$ norm(a = b)\\C $', "$ & norm(a = b) \\\n = &  $"),
    ['ignore_eq_in_grp'] = ali_wrapper('$ a_(a = b)\\C $', "$ & a_(a = b) \\\n = &  $"),

TODO

  • Typstyle adherence (get character count till ampersand in preceding line and insert artifical whitespaces at beginning of line)

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

Successfully merging this pull request may close these issues.

1 participant