markup
markup copied to clipboard
Markdown math rendering fails on multiple subscripts with curly brackets
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}$.
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}$
Same issue, thanks for the workaround tho!
In some cases also without curly brackets don't work.
Example: 19 =_2 010011
The workaround works fine.
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$"
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…
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)
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 $$
For non-inline math, as an alternative, we can use
```math
to replace $$
.
I have more experiments at https://github.com/ImpleLee/c4w/issues/1 .
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?
See e.g. ${\boldsymbol{x}1, ..., \boldsymbol{x}{i-1}, \boldsymbol{x}_{i+1}, ..., \boldsymbol{x}_n}$, which fails to render.
@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 🤞