Home > Back-end >  RMarkdown Latex issue with Formula
RMarkdown Latex issue with Formula

Time:01-03

I'm trying to write the below equation in RMarkdown.

$$
y=
\begin{cases}
y_1\quad\text {if }y*<\zeta_1\\
y_2 \quad\text {if }\zeta_1\leq y* <\zeta_2\\
\dots\\
y_{k-1}\quad\text{if }\zeta_{k-2}\leq y*<\zeta_{k-1}\\
y_k\quad\text{if } y* \leq \zeta_k-1
\end{cases}
$$

but when I knit to pdf, I get an error message "l.1052 \begin{cases}

Try to find the following text in N0869724_Coursework.Rmd:
\begin{cases} "

I've tried using \begin{equation} and end{equation}, but can't seem to make it knit, and google hasn't helped me fix this one.

Any help or advice would be appreciated!

CodePudding user response:

Works fine for me. Here a minimal working .Rmd. Note, that this LaTeX code is put into the text section and not into a code chunk. Check your YAML line by line which you may comment out with #.

---
  output: pdf_document
---
  
$$
y=
\begin{cases}
y_1\quad\text {if }y*<\zeta_1\\
y_2 \quad\text {if }\zeta_1\leq y* <\zeta_2\\
\dots\\
y_{k-1}\quad\text{if }\zeta_{k-2}\leq y*<\zeta_{k-1}\\
y_k\quad\text{if } y* \leq \zeta_k-1
\end{cases}
$$

enter image description here

  • Related