Skip to content

Tools for converting mathematically R code to equivalent latex mathematical equations

License

Notifications You must be signed in to change notification settings

yiluheihei/rlatexmath

Repository files navigation

R build status License: GPL v3 Codecov test coverage Lifecycle: experimental

NOTE: Markdown does not support well for mathematical equations. And some equations not displayed properly in this page, such as $\frac{x}{y}$, $\sqrt[y]{x}$ and $\prod_{i = 1}^{n} x_i$, . See the html vignette for all the correct displayed equations.

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.

Usage

Special symbols

library(rlatexmath)
translate_latexmath(pi)

π

# quoted object
translate_latexmath_(quote(pi))

π

Known functions

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 ± y
x %/% y x ÷ y
x %*% y x × y
x %.% y x ⋅ y
x[i] xi
x^i xi
Grouping
(x + y) (x+y)
{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]) x1, ⋯, x2
list(x[1], ldots, x[2]) x1, …, x2
Radicals
sqrt(x) $\sqrt[]{x}$
sqrt(x, y) $\sqrt[y]{x}$
Relation
x == y x = y
x != y x ≠ y
x < y x < y
x > y x > y
x >= y x ≥ y
x <= y x ≤ y
x %==% y x ≡ y
x %~~% y x ≈ y
x %=~% y x ≅ y
x %prop% y x ∝ y
Set</>
x %supset% y x ⊃ y
x %supseteq% y x ⊇ y
x %subset% y x ⊂ y
x %notsubset% y x ⊄ y
x %subseteq% y x ⊆ y
x %in% y x ∈ y
x %notin% y x ∉ y
Arrow
x %<->% y x ↔ y
x %<-% y x ← y
x %up% y x ↑ y
x %->% y x → y
x %down% y x ↓ y
x %<=>% y x ⇔ y
x %<=% y x ⇐ y
x %dblup% y x ⇑ y
x %=>% y x ⇒ y
x %dbldown% y x ⇓ y
Accent
tilde(x)
hat(x)
widetilde(x)
widehat(x)
bar(x)
Operators
sum(x[i]) xisum(x[i], i==1, n)
prod(x[i]) xi
prod(x[i], i==1, n) $\prod_{i = 1}^{n} x_i$
integral(f(x)*{dx}, a, b) abf(x)d**x
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) limx → ∞f(x)
min(f(x), x >= 0) minx ≥ 0f(x)
max(f(x), x >= 0) maxx ≥ 0f(x)
Typeface
plain(x) x
bold(x) x
italic(x) x
bolditalic(x) x
Delimiters
group(“(”, list(a,b), “]”) (a, b]
bgroup(“[", frac(a,b), "]”) $\left [ \frac{a}{b} \right ]$
abs(x) |x|

related projects

Acknowledgements

About

Tools for converting mathematically R code to equivalent latex mathematical equations

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages