Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get line breaks in equation when knitting to pdf?

I'm trying to knit a document that has an equation in it and I would like the equation to respect linebreaks. This works fine when I knit to HTML but does not when I knit to pdf.

$$ 
x_1 - ? +\\
x_2 - ? +\\
x_3 - ? +\\
$$

I've also tried \newline and even \hfill \break. I also tried the different latex engines listed on the RMarkdown cheat sheet at RStudio.

like image 511
Elin Avatar asked Mar 16 '17 13:03

Elin


People also ask

How do you add a line break in RMD?

To break a line in R Markdown and have it appear in your output, use two trailing spaces and then hit return .

How do you knit in a PDF?

To transform your markdown file into an HTML, PDF, or Word document, click the “Knit” icon that appears above your file in the scripts editor. A drop down menu will let you select the type of output that you want. When you click the button, rmarkdown will duplicate your text in the new file format.

How do I create a paragraph in Rmarkdown?

TEXT IN R MARKDOWN You may start with the most basic word processing—simply typing your text below the YAML header section. If you want to start a new paragraph, you can simply hit Enter twice on your key- board, and begin writing again.


1 Answers

Use Latex code:

\begin{aligned}
x_1 - ? + \\
x_2 - ? + \\
x_3 - ? + 
\end{aligned}

If you do not want a numbered equation, use

\begin{aligned}
x_1 - ? + \nonumber \\
x_2 - ? + \nonumber \\
x_3 - ? + \nonumber
\end{aligned}

This works in HTML and PDF.

like image 115
J_F Avatar answered Oct 14 '22 14:10

J_F