Skip to content

_ and ^ eat newline in math #1435

Open
Open

Description

@Enivex

Description

$
    a = b_ \
    c = d
$

will render as
image

The same is the case if _ is replaced with ^

This is not ideal, because it makes the output jump around whenever you add a sub- or superscript at the end of an existing line in an equation.

Reproduction URL

No response

Operating system

No response

Typst version

  • I am using the latest version of Typst

Activity

  1. added
    bug
    math
    on Jun 7, 2023
  2. frozolotl commented on Jun 7, 2023

    @frozolotl
    Contributor

    This works because linebreaks are considered to be expressions.
    Meaning, b_\ is parsed as a = b_(Linebreak) (pseudo-code?).

    It might be reasonable to not permit unparenthesized linebreaks as attachments.
    So:

    = Allowed
    $a_(\ )$
    $a_(b \ c)$
    $a^(\ )$
    $a^(b \ c)$
    
    = Disallowed (produces compile error)
    $a_\ $
    $a^\ $
  3. user202729 commented on Jun 9, 2023

    @user202729
    Contributor

    Seems like a rather "contrived" disallowance. Maybe better to forbid all cases of "empty" super/subscript entirely? (although I can't really think of another case where user accidentally make an empty super/subscript...) a_& perhaps?

  4. added
    syntax
    on Nov 14, 2023
  5. added a commit that references this issue on Sep 12, 2024
    44de5c9
  6. NoamDev commented on Jan 27, 2025

    @NoamDev

    This annoys me as well.

    I'll add that my current solution is to temporarily add double line breaks so that at most the lower line jumps up a bit instead of the two lines merging.

  7. Enivex commented on May 7, 2026

    @Enivex
    CollaboratorAuthor

    This should have been completed by #7742

  8. reopened this on May 7, 2026
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

    bugmathsyntax

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions