Skip to content

Allow any (common) delimiter pair for code grouping in math #4717

@Enivex

Description

@Enivex

Here's a somewhat arbitrary example of an equation I just had to write using typst:

(I've added linebreaks for clarity)

$
  kappa(lambda) := inf_(u in H_0^1(Omega), u equiv.not 0)
  (display(integral_Omega (abs(nabla u)^2 - g(lambda abs(nabla H)) u^2) dif x))
  /
  (display(integral_Omega u^2 dif x)) 
$

It's not terribly important what it looks like, but here you go anyway:
image

Even in an editor with bracket colorization, I find the code very hard to read, because they're all parentheses. For all its flaws, LaTeX actually does better here, because it uses braces for grouping code. This means that the delimiters for grouping code is different from the one (primarily) used in math.

I propose that we allow both ( ), [ ] and { } for grouping purposes for attachments and fractions. Then the above example could for instance read

$
  kappa(lambda) := inf_{u in H_0^1(Omega), u equiv.not 0}
  {display(integral_Omega (abs(nabla u)^2 - g(lambda abs(nabla H)) u^2) dif x)}
  /
  [display(integral_Omega u^2 dif x)] 
$

To me, this is already a lot more readable, because it removes one layer of parentheses. I can also have my own convention of for instance using {} for numerators and [] for denominators.

We could even consider the more radical move of allowing {} and [] for function calls, which would further improve readability in deeply nested scenarios (they can be much worse than the example I chose here).

Metadata

Metadata

Assignees

No one assigned

    Labels

    change requestA proposal for changes to an existing featuremathRelated to math category, with its syntax, layout, etc.syntaxAbout syntax, parsing, etc.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions