With R Markdown, you can embed LaTeX and MathML equations directly into your document. Equations are displayed using the MathJax JavaScript library. Note that this library is loaded from the MathJax website so readers of your document must be online to see the rendered equations.
To embed a LaTeX equation inline, wrap it insdie dollar signs with a latex denotation such as:
$latex equation $
For example, the following sentence:
The Arithmetic mean is equal to \( \frac{1}{n} \sum_{i=i}^{n} x_{i} \), or the summation of n numbers divided by n.
Is produced by:
To display an equation and place it on it's own line (centered), use two dollar signs such as:
$$latex equation $$
For example, to display the Taylor Series nicely:
\[ f(a) + \frac{f'(a)}{1!} (x-a) + \frac{f''(a)}{2!} (x-a)^{2} + \frac{f'''(a)}{3!} (x-a)^{3} + \ldots \]
Enter the following:
Embedded equations can also span multiple lines. Note however, you must avoid unwanted line breaks around your equation, otherwise a new paragraph will be introduced.
For example, the previous equation can be entered across multiple lines:
The Arithmetic mean is equal to \( \frac{1}{n} \sum_{i=i}^{n} x_{i} \), or the summation of n numbers divided by n.
Is produced by:
To insert MathML equations, wrap your equation inside a tag such as:
<math ...>
</math>
For example to display the Quadratic Formula:
Enter the following:
Return to Using Markdown with RStudio