Skip to content

Markdown math rendering fails on multiple subscripts with curly brackets #1575

Closed

Description

@stroitzsch

Multiple subscripts in combination with curly brackets in LaTeX-based math expressions don't render as expected.

Single underscore with curly brackets works fine: \mathbf{x}_{i,j} = \mathbf{y} renders as $\mathbf{x}_{i,j} = \mathbf{y}$.

Multiple underscores without curly brackets work fine: x_i = y_i renders as $x_i = y_i$.

Multiple underscores with curly brackets fail: \mathbf{x}_{i,j} = \mathbf{y}_{i,j} renders as $\mathbf{x}{i,j} = \mathbf{y}{i,j}$.

Activity

  1. stroitzsch commented on Jul 18, 2022

    @stroitzsch
    Author

    In the meantime, a workaround is to use trailing spaces after underscore symbols: \mathbf{x}_ {i,j} = \mathbf{y}_ {i,j} renders as $\mathbf{x}_ {i,j} = \mathbf{y}_ {i,j}$

  2. zhongzachary commented on Aug 4, 2022

    @zhongzachary

    Same issue, thanks for the workaround tho!

  3. giopalma commented on Aug 20, 2022

    @giopalma

    In some cases also without curly brackets don't work.
    Example: 19 =_2 010011
    The workaround works fine.

  4. tautomer commented on Oct 27, 2022

    @tautomer

    If the two subscripts are in two expressions but in the same line, render is broken as well.

    Range of $\mathbf{d}_{ij}$ and $\mathbf{d}_{ij} \cdot \Delta E$
    

    will be rendered as "Range of $\mathbf{d}{ij}$ and $\mathbf{d}{ij} \cdot \Delta E$", but the workaround also work for this case "Range of $\mathbf{d}_ {ij}$ and $\mathbf{d}_ {ij} \cdot \Delta E$"

  5. tobiasBora commented on Nov 21, 2022

    @tobiasBora

    To give more strange examples (but thanks a lot for the workaround), if I put a single expression it works, if I copy/paste it it fails:

    $V^{a}_{x}$
    

    Gives $V^{a}_{x}$

    But

    $V^{a}_{x} V^{a}_{x}$
    

    Gives $V^{a}{x} V^{a}{x}$

    My bet is that github confuses it with emphasis (like in _emphasis_), explaining why adding a space solves the issue…

  6. tobiasBora commented on Nov 21, 2022

    @tobiasBora

    Also something similar happens with stars (I guess again because it thinks it's bold, so the same work around also works):

    $V^{*}$
    

    Gives
    $V^{*}$ (ok)

    $V^{*} V^{*}$
    

    Gives $V^{} V^{}$ (bad!)

    $V^{ * } V^{ * }$
    

    Gives
    $V^{ * } V^{ * }$ (ok)

  7. ImpleLee commented on Dec 1, 2022

    @ImpleLee

    I suspect this happens because a_b is detected as one word, so emphasis doesn't come in, but in a}_b, there is a word boundary between } and _, so it can be detected as emphasis.

    So a _b c_d is working but a _b c_ d is not.

    $$ a _b c_d $$

    $$ a _b c_ d $$

  8. ImpleLee commented on Dec 1, 2022

    @ImpleLee

    For non-inline math, as an alternative, we can use

    ```math
    

    to replace $$.

    I have more experiments at ImpleLee/c4w#1 .

  9. prasanth-ntu commented on Mar 10, 2023

    @prasanth-ntu

    Inline math expression: $\sum_{i=1}^{m}$ $\sum_{i=1}^{m}$ Summation superscript rendering is bad!
    Another e.g., $\frac{1}{2m}\sum_{i=1}^{m}{(\hat{y} _{i} - y _{i})}^{2}$ $\frac{1}{2m}\sum_{i=1}^{m}{(\hat{y} _{i} - y _{i})}^{2}$

    Block math expression: Summation superscript is okay!
    $$\sum_{i=1}^{m}$$ $$\sum_{i=1}^{m}$$
    Another e.g.,
    $$\frac{1}{2m}\sum_{i=1}^{m}{(\hat{y} _{i} - y _{i})}^{2}$$

    Any workarounds?

  10. added a commit that references this issue on Apr 15, 2023
  11. added a commit that references this issue on May 16, 2023
  12. mbaudin47 commented on Jun 2, 2023

    @mbaudin47

    See e.g. ${\boldsymbol{x}1, ..., \boldsymbol{x}{i-1}, \boldsymbol{x}_{i+1}, ..., \boldsymbol{x}_n}$, which fails to render.

  13. kirk86 commented on Jun 13, 2023

    @kirk86

    @prasanth-ntu I was looking for the same and found a workaround on a github gist of some repo. One of the solutions described there was the following ${\sum}_{k=0}^{K}$ = ${\sum}_{k=0}^{K}$. Although, these issues require #github's attention and hopefully should be fixed at some point 🤞

  14. added a commit that references this issue on Jun 16, 2023
  15. added a commit that references this issue on Oct 31, 2023
  16. 27 remaining items

  17. github-actions commented on Aug 16, 2024

    @github-actions

    Stale issue message

  18. added a commit that references this issue on Sep 3, 2025
  19. cdfh commented on Jun 3, 2026

    @cdfh

    This bug is still unfixed. The best workaround is to use the syntax described here:

    jgm/pandoc#9121

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions