to_latex {lazy.symbolic} | R Documentation |
Convert the input string to LaTex and display it on the RStudio viewer
Description
Convert the input string to LaTex and display it on the RStudio viewer
Usage
to_latex(
expr_str,
dollar = TRUE,
mat2sum = FALSE,
simple_mat2sum = FALSE,
print_html = FALSE,
undef_Greek = c("strip", "keep", "initial")
)
Arguments
expr_str |
The input expression as a string |
dollar |
= FALSE to omit the encompassing dollar signs |
mat2sum |
= TRUE if the input expression contains summation |
simple_mat2sum |
= TRUE if the input expression contains summation and the simpler LaTeX is prefered |
print_html |
= TRUE to display the result in RStudio's Viewer pane. |
undef_Greek |
Character string specifying how to handle undefined Greek macros (e.g., \Zeta). Use '"strip"' to print them as plain strings (e.g., '\Zeta' → '"Zeta"'), or '"initial"' to print only their initial character (e.g., '"Z"'). |
Details
This function requires htmltools
package when print_html=TRUE
.
Value
LaTeX expression of expr
Author(s)
Contributed by Dr. Kentaro Fukushima of Osaka University.
Examples
modify_math_operators()
A <- demomat(2,3, root="a")
B <- demomat(3,2, root="b")
AB=A%*%B
printm(AB)
AB_tex <- to_latex( AB )
printm(AB_tex)
sexpr <- mat2sum( "A%*%B+C" )
printm(sexpr)
sexpr_tex <- to_latex( sexpr, mat2sum=TRUE )
## Not run:
library(htmltools)
print_tex_as_html(AB_tex)
AB_tex <- to_latex( t(A)+B, print_html=TRUE )
sexpr_tex <- to_latex( sexpr, mat2sum=TRUE, print_html=TRUE )
sexpr_tex <- to_latex( sexpr, simple_mat2sum=TRUE, print_html=TRUE )
## End(Not run)
[Package lazy.symbolic version 1.0.0.20250701 ]