我试图在Jupyter笔记本中以漂亮的方式显示矢量方程。我想要实现这样的事情:
使用IPython.display模块,我能够以一种漂亮的方式打印矩阵。问题是显示“(2 *矩阵) - (1 *另一个子矩阵)......”内联。
这可能吗?
from IPython.display import display, Math, Latex
display(Math(r'2 \cdot \begin{bmatrix} 1 \\ -2 \\ \end{bmatrix} -1 \cdot \begin{bmatrix} 2 \\ -3 \\ \end{bmatrix} +1 \cdot \begin{bmatrix} -3 \\ 1 \\ \end{bmatrix} -1 \cdot \begin{bmatrix} 1 \\ -1 \\ \end{bmatrix}= \begin{bmatrix} -4 \\ 1 \\ \end{bmatrix}'))
更粗。你可以使用\ bullet而不是\ cdot
Jupyter笔记本支持乳胶:
$e^{i\pi} + 1 = 0$
可以在Jupyter笔记本代码单元格中使用%%latex
魔术函数。这将在Latex中呈现整个单元格输出:
%%latex
\begin{align} 2 \cdot \begin{bmatrix} 1 \\ -2 \\ \end{bmatrix} -1 \cdot \begin{bmatrix} 2 \\ -3 \\ \end{bmatrix} +1 \cdot \begin{bmatrix} -3 \\ 1 \\ \end{bmatrix} -1 \cdot \begin{bmatrix} 1 \\ -1 \\ \end{bmatrix}= \begin{bmatrix} -4 \\ 1 \\ \end{bmatrix} \end{align}
here描述了在Jupyter中渲染LaTeX的所有不同方法。