typst / typst/typst

Avoid layout collisions with equation numbering

Open
#7,221 2 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Description

When an equation is sufficiently long, its bounding box can collide with the equation number. There are two scenarios where this happens:

  1. The equation exceeds the column width. This feature does not address this case.
  2. The equation fits within the column, but due to center alignment, it extends far enough right to collide with the equation number.

I proposes implementing collision detection and dynamic positioning improve the typography for scenario 2 occurs. Specifically:

Proposed Behavior

  1. Detect when the bounding boxes of the centered equation and right-aligned equation number collide.
  2. If a collision is detected and sufficient space remains in the column, progressively offset the equation leftward until either:
    1. The equation and number no longer collide and achieve satisfactory typographic spacing, or
    2. The equation reaches the edge of the column.

Note: In the second outcome, the equation would span the full column width and may still collide with the numbering. This is expected behavior, the feature aims to utilize available space, but cannot resolve collisions when the equation genuinely requires the entire column.

Use Case

Near Collision
Image

Here, the equation is uncomfortably close to the numbering when strictly centered in the column. It would look significantly better with a slightly offset to the left.

Collision
Image

Now the equation is actually colliding with the equation number. But there's plenty of room in the column for them not to collide at all.

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 an implementation file, test, or entry point, so first locate the equation layout and numbering logic in the Rust codebase. Done means detecting collisions, shifting a centered equation left when space permits, and preserving the documented behavior when the equation reaches the column edge.

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
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.