Skip to main content
 首页 » 编程设计

python之latex jupyter 笔记本不起作用

2025年05月04日24itcoder

我开始在 jupyter notebook 上使用 python,问题是打印不像标准的 LaTeX 我的手机:

%%latex 
\begin{center} 
$(a+b)^{2} = a^{2}+2ab+b^{2}$ 
\end{center} 

笔记本中的结果如下图所示:

请您参考如下方法:

来自 jupyter docs :

The subset of latex which is supported depends on the implementation in the client. In the Jupyter Notebook, this magic only renders the subset of latex defined by MathJax here.

您可以使用 markdown 来显示您的公式:使用单个 $ 表示 latex ,或使用两个 $$ 将其居中。您需要将单元格格式化为 ma​​rkdown 而不是 code

您的单元格成为以下两行之一:

$$(a+b)^{2} = a^{2}+2ab+b^{2}$$ 
$(a+b)^{2} = a^{2}+2ab+b^{2}$ 

您必须运行单元格才能显示 Markdown 。