简体   繁体   English

Latex 在 Jupyter Notebook 上无法正确呈现

[英]Latex not rendering correctly on Jupyter Notebook

I am having some trouble with Latex on my Jupyter Notebook.我的 Jupyter Notebook 上的 Latex 遇到了一些问题。

Whenever I try to use Latex expressiosn of the form \begin{}.. \end{} the code is not correctly rendered.每当我尝试使用 \begin{}.. \end{} 形式的 Latex 表达式时,代码都不会正确呈现。

When I use inline expressions, like the $ whatever inside $ this, DOES work.当我使用内联表达式时,比如 $ this 中的 $whatever ,确实有效。

I have tried with the magic %%latex on code cells, as well as in markdown cells.我已经尝试在代码单元以及 markdown 单元中使用魔法 %%latex。

Here an example of what happens>这是发生的事情的一个例子>

在此处输入图像描述

I read that many people have problems with this, but not concrete solution.我读到很多人对此有疑问,但没有具体的解决方案。 Any ideas??有任何想法吗?? Thanks a lot in advance.提前非常感谢。

EDIT ADD CODE编辑添加代码

On a code cell with the %%latex magic在具有 %%latex 魔法的代码单元上

%%latex
\begin{tabular}{ | c | c   c   c | } \hline
        $k$ &   $x_1^k$  &   $x_2^k$  &    $x_3^k$   \\
         \hline
         0 & -0.30000000 & 0.60000000 &  0.70000000  \\
         1 &  0.47102965 & 0.04883157 & -0.53345964  \\
         2 &  0.49988691 & 0.00228830 & -0.52246185  \\
         3 &  0.49999976 & 0.00005380 & -0.52365600  \\
         4 &  0.50000000 & 0.00000307 & -0.52359743  \\
         5 &  0.50000000 & 0.00000007 & -0.52359885  \\
         6 &  0.50000000 & 0.00000000 & -0.52359877  \\
         7 &  0.50000000 & 0.00000000 & -0.52359878  \\
         \hline
\end{tabular}

On a markdown cell without the magic在没有魔法的 markdown 电池上

\begin{itemize}
\item Hello
\end{itemize}

But the following code renders as a matrix correctly , so it's like tabular or itemize are broken?但是下面的代码正确地呈现为矩阵,所以它就像表格或项目被破坏了?

$$
\begin{pmatrix}
Var[X_1] & Cov[X_1,X_2] \\
Cov[X_1,X_2] & Var[X_2].
\end{pmatrix}
$$

Check this answer :检查这个答案

Jupyter builds on MathJax and cite "MathJax doesn't implement tabular". Jupyter 基于 MathJax 并引用“MathJax 不实现表格”。 The link also shows the recommended array environment as tabular replacement. 该链接还将推荐的阵列环境显示为表格替换。

I suggest to use Markdown Cells .我建议使用Markdown Cells

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM