Rmarkdown – How to Add LaTeX to Rmarkdown to Be Within Text Rather Than Centered When Knitted

equationsrmarkdown

I am writing text in RMarkdown that includes equations that I type in LaTeX. However, rather than including them on the same line within the text, it breaks the line and centres the equation. How can I write LaTeX equations on the same line within text in RMarkdown?

Here is an example of how I wrote my text in Rmd:

The slope of the least squares line is 1.4083\[\approx\]1.4. It is meaningful over the range \[x \in [113.082, 1262.274]\] where the regression line exists along the x-axis.

And here's an image of the result after knitting the Rmd file.

And here's an image of the result after knitting the Rmd file.

Best Answer

You are using the "display math mode". For the "inline math mode" use \( ... \) or $ ... $.

---
output:
  pdf_document: default
---

The slope of the least squares line is
\(1.4083\approx1.4\).
It is meaningful over the range
\(x \in [113.082, 1262.274]\)
where the regression line exists along the x-axis.

mwe

Related Question