Why does \\\\ not break lines in this R markdown example?

丶灬走出姿态 提交于 2019-12-06 06:27:57

In my R version it crashed when I tried to include amsmath. Somehow it seems to be already loaded.

As I already mentioned in the comment omitting \[ ... \] worked for the code below.

---
title: "Document title"
author: "Author's name"
output: pdf_document
---
\begin{align}
 X_t  &= \mu_t + \sigma_t Z_t\\
\mu_t &= \mu + \sum_{k=1}^{p_1} \phi_k  (X_{t-k}-\mu) +
         \sum_{k=1}^{q_1} \theta_k (X_{t-k}-\mu_{t-k})\sigma_t^2\\
      &= \alpha_0 + \sum_{k=1}^{p_2} \alpha_k (X_{t-k}-\mu_{t-k})^2 +
         \sum_{k=1}^{q_2} \beta_k \sigma_{t-k}^2.
\end{align}

The following worked:

---
title: Foo
author: Marius Hofert
vignette: >
  %\VignetteEngine{knitr::rmarkdown}
  %\VignetteIndexEntry{Foo}
---
\[
\begin{align}
    X_t &= \mu_t + \sigma_t Z_t\\\\
  \mu_t &= \mu + \sum_{k=1}^{p_1} \phi_k  (X_{t-k}-\mu) +
            \sum_{k=1}^{q_1} \theta_k (X_{t-k}-\mu_{t-k})\sigma_t^2\\\\
        &= \alpha_0 + \sum_{k=1}^{p_2} \alpha_k (X_{t-k}-\mu_{t-k})^2 +
            \sum_{k=1}^{q_2} \beta_k \sigma_{t-k}^2.
            \end{align}
\]

What I found out (much) later is that I was missing the R package rmarkdown. With that, one indeed doesn't need to escape backslashes and only needs to provide \begin{align}..\end{align} (without \[...\])

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!