Skip to content

[Bug] Display-math \tag number overlaps equation in WYSIWYG mode #1376

Description

@lkk0027

Before Submitting

  • I searched existing issues and did not find a duplicate.
  • I reproduced this on the latest release. The runtime reproduction is on 0.9.61; static inspection shows the relevant CSS and rendering code are unchanged in 0.9.65/current main.
  • This report includes environment, exact reproduction steps, expected and actual behavior, and a minimal repro.

Bug Summary

In WYSIWYG mode, the equation number produced by KaTeX \tag{...} overlaps the rightmost part of a short display equation instead of being positioned at the right edge of the display block.

Operating System

macOS 26.6.2 (Build 25G83)

VMark Version

0.9.61 (runtime reproduction). The relevant math rendering and CSS rules appear unchanged in 0.9.65/current main.

Install Method

Homebrew

Steps to Reproduce

  1. Open a Markdown document in WYSIWYG mode.

  2. Add this display-math block:

    $$
    [H][\Delta P_T]=[\Delta V] \tag{9}
    $$
  3. Leave math editing mode so the rendered preview is shown.

Expected Behavior

The equation is centered and (9) is placed at the right edge of the display-math area without overlapping the equation.

Actual Behavior

(9) is positioned at the right edge of the equation's shrink-wrapped content box and overlaps the final term, visually resembling [\Delta V(9)].

Logs, Screenshots, or Repro

Minimal repro is included above. No error is logged; this is a deterministic layout issue.

Additional Context

KaTeX supports \tag in display mode, and VMark correctly calls renderToString with displayMode: true.

The likely cause is the block-preview layout:

.math-block-preview {
  display: flex;
  align-items: center;
  justify-content: center;
  overflow-x: auto;
}

.math-block-preview .katex-display {
  margin: 0;
}

As a centered flex item, .katex-display shrink-wraps to the equation content instead of occupying the available row width. KaTeX positions the tag relative to that display box, so the tag lands on the equation's right edge.

The relevant rules are identical in v0.9.61 and current main. A fix should make short display equations use the available row width so tags have a real right margin, while preserving horizontal scrolling for intrinsically wide equations (for example, large matrices) and keeping the equation plus tag together as one scrollable unit.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions