嘗試將 R 筆記本轉換為(下載為)pdf; LateX 轉換失敗,這部分錯誤似乎相關:
! LaTeX Error: \mathbf allowed only in math mode.
See the LaTeX manual or LaTeX Companion for explanation.
Type H <return> for immediate help.
...
l.284 Show that \$ (\mathbf A
\mathbf B)\^{}T = \mathbf B\^{}T
?
! Emergency stop.
有問題的 Markdown 單元格如下所示:
## Question 1
Show that
$ (\mathbf A \mathbf B)^T = \mathbf B^T \mathbf A^T$ for matrices $\mathbf A \in \mathbb R^{m \times n}$ and $\mathbf B \in \mathbb R^{n \times l}$ by writing componentwise.
看起來好像在 Markdown 單元和 LateX 輸入之間,符號$
被轉義了,而 LateX 現在無法識別它。事實上,其他符號(例如插入符號)看起來也^
被轉義了。
我使用的是 Windows 8、Chrome 版本 58.0.3029.81、Jupyter 版本 4.2.0、Jupyter Notebook 版本 4.2.3。
我該如何修正這個問題?
答案1
經過一番檢查,我注意到問題出在$
標誌後面的空格上 - 這是:
$ (\mathbf A \mathbf B)^T = \mathbf B^T \mathbf A^T$
需要像這樣:
$(\mathbf A \mathbf B)^T = \mathbf B^T \mathbf A^T$
等等。看來MathJax沒有問題,但nbconvert
需要這種格式。