orsharir / github-mathjax

Chrome extension for rendering LaTeX equations in GitHub with MathJax
Other
153 stars 49 forks source link

Unable to render formula #31

Open sstorey-nephila opened 5 years ago

sstorey-nephila commented 5 years ago

This latex is correct

$$
\underbrace{E[Y_i|D_i=1]- E[Y_i|D_i=0]}_\text{Observed difference in average health} = 
\underbrace{E[Y_{1i}|D_i=1]- E[Y_{0i}|D_i=1]}_\text{Average treatment effect on the treated} + 
\underbrace{E[Y_{0i}|D_i=1]- E[Y_{0i}|D_i=0]}_\text{Selection Bias}
$$

Yet to make it work here in github, I must escape _\ to \_\

$$
\underbrace{E[Y_i|D_i=1]- E[Y_i|D_i=0]}\_\text{Observed difference in average health} = 
\underbrace{E[Y_{1i}|D_i=1]- E[Y_{0i}|D_i=1]}\_\text{Average treatment effect on the treated} +
\underbrace{E[Y_{0i}|D_i=1]- E[Y_{0i}|D_i=0]}\_\text{Selection Bias}
$$

After escaping the underscores it does work $$ \underbrace{E[Y_i|D_i=1]- E[Y_i|Di=0]}_\text{Observed difference in average health} = \underbrace{E[Y{1i}|Di=1]- E[Y{0i}|Di=1]}_\text{Average treatment effect on the treated} + \underbrace{E[Y{0i}|_i=1]- E[_{0i}|_i=0]}_\text{Selection Bias} $$

Any idea if this can be resolved as it appears to be similar in root cause to the issue when trying to render this

$$
\begin{aligned}
Y_i &= \left \{
\begin{array}{ll}
Y_{1i} & \text{if } D_i = 1 \\  
Y_{0i} & \text{if } D_i = 0 \\   
\end{array} 
\right. \\
&= Y_{0i} + (Y_{1i} - Y_{0i})D_{i*}
\end{aligned}
$$

Resulting in this error $$ \begin{aligned} Y_i &= \left { \begin{array}{ll} Y_{1i} & \text{if } D_i = 1 \
Y_{0i} & \text{if } D_i = 0 \
\end{array} \right. \ &= Y_{0i} + (Y_{1i} - Y_{0i})D_{i*} \end{aligned} $$

Change the latex like this

$$
\begin{align}
Y_i &= \left \\{
\begin{array}{ll}
Y_{1i} & \text{if } D_i = 1 \\\\
Y_{0i} & \text{if } D_i = 0 \\\\
\end{array} 
\right. \\\\
&= Y_{0i} + (Y_{1i} - Y_{0i})D_{i*}
\end{align}
$$

Amending the original \{to \\{ and the \\ to \\\\ resolves the issue

$$ \begin{align} Yi &= \left \{ \begin{array}{ll} Y{1i} & \text{if } Di = 1 \\ Y{0i} & \text{if } Di = 0 \\ \end{array} \right. \\ &= Y{0i} + (Y{1i} - Y{0i})D_{i*} \end{align} $$

Mathjax correctly renders the latex and I can extract it for use elsewhere.

With thanks

muzimuzhi commented 5 years ago

Duplicate of #16 . And, I am afraid that this cannot be resolved.

zzqxaut commented 1 year ago

why the latex on typora is different from the latex on github?