LaTeX (pronounced “Lah-Tech” or “Lay-Tech”) is a typesetting system designed especially for scientific documents and mathematical formulas. Unlike word processors such as Word, LaTeX uses markup commands to control layout and formatting.
In our courses, LaTeX is primarily used within R Markdown and Quarto documents to render mathematical formulas professionally. A standalone LaTeX installation is typically not required, as Quarto can use the lightweight TinyTeX distribution.
LaTeX Formula Syntax
LaTeX formulas are written between dollar signs in R Markdown and Quarto:
- Inline formula:
$formula$– rendered within the text - Display formula:
$$formula$$– rendered centered on its own line
Examples
| LaTeX Code | Result |
|---|---|
$\bar{x} = \frac{1}{n}\sum_{i=1}^{n} x_i$ |
\(\bar{x} = \frac{1}{n}\sum_{i=1}^{n} x_i\) |
$\sigma^2 = \frac{1}{n}\sum_{i=1}^{n}(x_i - \bar{x})^2$ |
\(\sigma^2 = \frac{1}{n}\sum_{i=1}^{n}(x_i - \bar{x})^2\) |
$y = \beta_0 + \beta_1 x + \epsilon$ |
\(y = \beta_0 + \beta_1 x + \epsilon\) |
$P(A \mid B) = \frac{P(B \mid A) \cdot P(A)}{P(B)}$ |
\(P(A \mid B) = \frac{P(B \mid A) \cdot P(A)}{P(B)}\) |
Common Commands
| Command | Description | Example |
|---|---|---|
\frac{a}{b} |
Fraction | \(\frac{a}{b}\) |
\sum_{i=1}^{n} |
Summation | \(\sum_{i=1}^{n}\) |
\bar{x} |
Mean bar | \(\bar{x}\) |
\sqrt{x} |
Square root | \(\sqrt{x}\) |
x^{2} |
Superscript | \(x^{2}\) |
x_{i} |
Subscript | \(x_{i}\) |
\alpha, \beta, \gamma |
Greek letters | \(\alpha, \beta, \gamma\) |
Installation
TinyTeX (recommended for Quarto)
If you use Quarto, the lightweight TinyTeX distribution is sufficient. Install it via the terminal:
quarto install tinytexTinyTeX automatically downloads missing LaTeX packages as needed.
Full TeX Distribution
For standalone LaTeX use or advanced requirements, you can install a full distribution:
- TeX Live (Windows, Linux): tug.org/texlive
- MacTeX (macOS): tug.org/mactex
- MiKTeX (Windows): miktex.org
Further Resources
- The LaTeX Project – Official website
- Overleaf – Learn LaTeX – Comprehensive LaTeX documentation and tutorials
- TinyTeX – Lightweight TeX distribution for R and Quarto
- LaTeX Mathematics (Wikibooks) – Reference for mathematical commands
- Detexify – Find symbols by drawing