Multiline equations not rendering

On the preview of an equation such as

$$
FPR = \frac{FP}{N} = \dfrac{FP}{FP+TN} 
TPR = \frac{TP}{P} = \dfrac{FP}{FP+FN} 
$$

Which renders as this:

FPR = \frac{FP}{N} = \dfrac{FP}{FP+TN} TPR = \frac{TP}{P} = \dfrac{FP}{FP+FN}

On the preview I see the content in two lines, and I would like to keep that.

However, when I knit the document to pdf there is actually in one line (like on this website)
I saw some latex post, and the help itself, that mention adding \begin{equation} and add a \\ to separate lines.

$$
\begin{equation}
FPR = \frac{FP}{N} = \dfrac{FP}{FP+TN}  \\
TPR = \frac{TP}{P} = \dfrac{FP}{FP+FN} 
\end{equation}
$$

However, this results on an incorrect math environment.
I tried also setting the array and align environments.
How can I have multiline environment with equations on bookdown? What could be wrong with the knitting proces


My versions bookdown: 0.24, knitr:1.37, pandoc 2.5 and R 3.6 (I also tried with R 4.1.2 and an unkown pandoc version) all this on Ubuntu 20.04. engine pdflatex, on include:before_body I only have "\usepackage{pdfpages} % To include other pdf"

I think you need to write some LaTeX this way

---
output: 
  pdf_document: default
  html_document: default
  bookdown::pdf_document2: default
---

# Foo

$$
\begin{aligned}
FPR = \frac{FP}{N} = \dfrac{FP}{FP+TN}\\
TPR = \frac{TP}{P} = \dfrac{FP}{FP+FN} 
\end{aligned}
$$

Or 

\begin{align}
\begin{aligned}
FPR = \frac{FP}{N} = \dfrac{FP}{FP+TN}\\
TPR = \frac{TP}{P} = \dfrac{FP}{FP+FN}
\end{aligned}
\end{align}

I found this by googling about aligning equation. It seems amsmath is needed (which is available by default), and that \\ does not work in \begin{equation}.

Anyway, this seems to work for me.

Resources:

Hope it helps

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.