MathCoder
MathCoder

Reputation: 442

Last column of table in Jupyter Notebook Markdown cell badly formatted

I created this table in jupyter notebook markdown cell, but the last column is badly formatted and I can not figure out what the problem is.

| $H_0$ | $H_1$ | Test statistic TS | Significance level $\alpha$ test | $p$-value |
| :-: | :-: | :-: | :-: | :-: |
| $\beta_1 = 0$ | $\beta_1\neq 0$ | $\frac{\hat\beta_1}{s/\sqrt{\sum_i(x_i-\bar x)^2}}$ | Reject if $|TS|> t_{\alpha/2, n-2}$ | $2P(t(n-2) \geq |TS|)$ |

Rendered output

Upvotes: 0

Views: 250

Answers (1)

Wayne
Wayne

Reputation: 9865

I suspect you aren't using JupyterLab because presently it works generally, as-is there. (I qualify it with 'generally' because your example is very complex, unlike the minimal reproducible example in the place I found the solution. I note the Reject if portion of the fourth column may not be perfect with your original code in JupyterLab, see below. I may have missed more)

Presumably then you aren't using JupyterLab and aren't looking to change, and so the solution is (and probably even best in JupyterLab, too):

As covered here in reply to this post, (which was also posted at the Jupyter Community Discourse Forum here), it seems to differ whether you use one or two dollar signs when embedding the latex in a table. You used only one dollar sign throughout yours, and the referenced solution said you need two.

I copied your included text and in a text-editor did find-replace to change every single dollar sign in your markdown table to double dollar sign to get:

| $$H_0$$ | $$H_1$$ | Test statistic TS | Significance level $$\alpha$$ test | $$p$$-value |
| :-: | :-: | :-: | :-: | :-: |
| $$\beta_1 = 0$$ | $$\beta_1\neq 0$$ | $$\frac{\hat\beta_1}{s/\sqrt{\sum_i(x_i-\bar x)^2}}$$ | Reject if $$|TS|> t_{\alpha/2, n-2}$$ | $$2P(t(n-2) \geq |TS|)$$ |

I see, in the current traditional Jupyter notebook interface, the following where the top is your markdown text rendered and the bottom is where I did find-replace to change every single dollar sign to double:

enter image description here

This approach works in JupyterLab, too, and so is probably best for use everywhere. Indeed, the Reject if portion of the fourth column works better in Jupyterlab (I think), too, with this updated approach.

Upvotes: 1

Related Questions