Intro.Rmd
library(rlatexmath)
Tools for converting R expressions to latex mathematical equations. This project is scratch from the section 21.3 transforms mathematically R code into its LaTeX equivalent.
library(rlatexmath)
translate_latexmath(pi)
\[ \pi \]
# quoted object
translate_latexmath_(quote(pi))
\[ \pi \]
R expression | latex math |
---|---|
Binary operators | |
x + y | \(x + y\) |
x - y | \(x - y\) |
x * y | \(x y\) |
x / y | \(x / y\) |
x %+-% y | \(x \pm y\) |
x %/% y | \(x \div y\) |
x %*% y | \(x \times y\) |
x %.% y | \(x \cdot y\) |
x[i] | \(x_i\) |
x^i | \(x^i\) |
Grouping | |
(x + y) | \(\left(x + y\right)\) |
{x y} | \({x + y}\) |
Juxtaposition | |
paste(x, y, z) | \(xyz\) |
Comma separated lists | |
list(x + y, z) | \(x + y, z\) |
Fractions | |
frac(x, y) | \(\frac{x}{y}\) |
atop(x, y) | \(x \atop y\) |
Ellipsis | |
list(x[1], cdots, x[2]) | \(x_1, \cdots, x_2\) |
list(x[1], ldots, x[2]) | \(x_1, \ldots, x_2\) |
Radicals | |
sqrt(x) | \(\sqrt[]{x}\) |
sqrt(x, y) | \(\sqrt[y]{x}\) |
Relation | |
x == y | \(x = y\) |
x != y | \(x \neq y\) |
x < y | \(x < y\) |
x > y | \(x > y\) |
x >= y | \(x \geq y\) |
x <= y | \(x \leq y\) |
x %==% y | \(x \equiv y\) |
x %~~% y | \(x \approx y\) |
x %=~% y | \(x \cong y\) |
x %prop% y | \(x \propto y\) |
Set</> | |
x %supset% y | \(x \supset y\) |
x %supseteq% y | \(x \supseteq y\) |
x %subset% y | \(x \subset y\) |
x %notsubset% y | \(x \not\subset y\) |
x %subseteq% y | \(x \subseteq y\) |
x %in% y | \(x \in y\) |
x %notin% y | \(x \notin y\) |
Arrow | |
x %<->% y | \(x \leftrightarrow y\) |
x %<-% y | \(x \leftarrow y\) |
x %up% y | \(x \uparrow y\) |
x %->% y | \(x \rightarrow y\) |
x %down% y | \(x \downarrow y\) |
x %<=>% y | \(x \Leftrightarrow y\) |
x %<=% y | \(x \Leftarrow y\) |
x %dblup% y | \(x \Uparrow y\) |
x %=>% y | \(x \Rightarrow y\) |
x %dbldown% y | \(x \Downarrow y\) |
Accent | |
tilde(x) | \(\tilde{x}\) |
hat(x) | \(\hat{x}\) |
widetilde(x) | \(\widetilde{x}\) |
widehat(x) | \(\widehat{x}\) |
bar(x) | \(\bar{x}\) |
Operators | |
sum(x[i]) | \(\sum x_i\)sum(x[i], i==1, n) |
prod(x[i]) | \(\prod x_i\) |
prod(x[i], i==1, n) | \(\prod_{i = 1}^{n} x_i\) |
integral(f(x)*{dx}, a, b) | \(\int_{a}^{b} \mathrm{f}(x) {dx}\) |
union(A[i], i==1, n) | \(\bigcup_{i = 1}^{n} A_i\) |
intersect(A[i], i==1, n) | \(\bigcup_{i = 1}^{n} A_i\) |
lim(f(x), x %->% infty) | \(\lim_{x \rightarrow \infty} \mathrm{f}(x)\) |
min(f(x), x >= 0) | \(\min_{x \geq 0} \mathrm{f}(x)\) |
max(f(x), x >= 0) | \(\max_{x \geq 0} \mathrm{f}(x)\) |
Typeface | |
plain(x) | \(\mathrm{x}\) |
bold(x) | \(\mathbf{x}\) |
italic(x) | \(\mathit{x}\) |
bolditalic(x) | \(\boldsymbol{x}\) |
Delimiters | |
group(“(”, list(a,b), “]”) | \(( a, b ]\) |
bgroup(“[", frac(a,b), "]”) | \(\left [ \frac{a}{b} \right ]\) |
abs(x) | \(\vert x\vert\) |