typst / typst/typst

Make toggling of display math mode more explicit

Open
#6,830 8 comments 6 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

change request syntax
Dominant language
Rust
Stars
56.1k
Forks
1.7k
Avg merge
3d 10h
Merged PRs (30d)
22

Description

Description

I don't like that toggling on/off display math is made through padding spaces. This approach produces starkly different results depending on whether an invisible character is there or not.

Maybe I am missing some context for this design choice, but the fact is that this feels a little bit weak/flimsy and unreliable.

Use Case

Could we have an attribute to the math environment?

So, instead of writing $ sin(x) $ (with padding spaces) for display math we would have to include an attribute $sin(x)$! instead? (or something similar)

This is more explicit and deliberate.

Suppose that I have some equation that I want to typeset inline, if we follow this approach the spaces/line breaks are ignored, and therefore I could do

$
x + dot(y)
=
y - 3
$

for an inline math expression and thus have some isolated lines of code available as canvas to work on my expression. (I would not need to omit one of the surrounding line breaks to force the math to be typeset inline)

And for the display math I can simply do

$x + y$!      // <- with the display attribute "!"

or indeed

$
x + dot(y)
=
y - 3
$!        // <- display attribute

If the "!" character is already taken, here are some other suggestions:

$x$!
$x$!!
$x$<d>

// Or at the start instead
!$x$
!!$x$
<d>$x$ 

Thank you!

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The issue does not name files, tests, or an entry point. Begin by locating the math parsing and whitespace-handling logic, then review the existing padding-space behavior and related tests before deciding whether an explicit display-mode syntax is feasible; done means the chosen syntax is specified and its inline and display cases are covered.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.