## ----eval=FALSE----------------------------------------------------------
# library(devtools)
# install_github("mat2tex", "markheckmann")
## ------------------------------------------------------------------------
library(mat2tex)
## ----echo=FALSE----------------------------------------------------------
# reset default values. build_vignettes() seems to use current environment
mat2tex:::mat2tex_options_init()
## ------------------------------------------------------------------------
set.seed(1)
A <- matrix(runif(4), 2)
## ----echo=TRUE, results='asis'-------------------------------------------
"$$" %_% xm(A) %_% "$$"
## ----echo=TRUE, results='asis'-------------------------------------------
xx(A)
## ------------------------------------------------------------------------
mat2tex_options(mathenvir=3)
## ----echo=TRUE, results='asis'-------------------------------------------
xx(A)
## ----echo=TRUE, results='asis'-------------------------------------------
xx(A, label="mylabel")
## ------------------------------------------------------------------------
mat2tex_options(mtype="bmatrix", digits=3)
## ----results='asis'------------------------------------------------------
d <- svd(A)
xx("A = UDV^T =", d$u, diag(d$d), xmt(d$v))
## ----results='asis'------------------------------------------------------
splt <- xx("AA^T & = ", A, t(A), "\\\\",
"& =", A %*% t(A), e="split")
xx(splt, e="equation", label="eq1")
## ----results='asis'------------------------------------------------------
xx("AA^T = ", A, t(A), "\\\\",
" =", A %*% t(A), e=9, label="eq2")
## ----results='asis'------------------------------------------------------
xx("AA^T &= ", A, t(A), "\\\\",
"&=", A %*% t(A), e=5, label="eq3")
## ----results='asis'------------------------------------------------------
xx("AA^T = ", A, t(A), "\\\\",
"=", A %*% t(A), e=7, label="eq3b")
## ----results='asis'------------------------------------------------------
xx(xm(A, mtype="matrix"))
## ----results='asis'------------------------------------------------------
xx(xm(A, mtype="pmatrix"))
## ----results='asis'------------------------------------------------------
xx(xm(A, mtype="bmatrix"))
## ----results='asis'------------------------------------------------------
rownames(A) <- letters[1:2]
colnames(A) <- LETTERS[1:2]
xx(xm(A, mtype="bordermatrix"))
## ----eval=FALSE----------------------------------------------------------
# "$$ 1 + 1 =" %_0% "2 $$"
# "$$ 1 + 1 =" %_% "2 $$" # default operator
# "$$ 1 + 1 =" %_1% "2 $$"
# "$$ 1 + 1 =" %_2% "2 $$"
# "$$ 1 + 1 =" %_3% "2 $$"
# "$$ 1 + 1 =" %_4% "2 $$"
# "$$ 1 + 1 =" %_5% "2 $$"
## ----echo=FALSE, results='asis'------------------------------------------
"$$ 1 + 1 =" %_0% "2 $$"
"$$ 1 + 1 =" %_% "2 $$"
"$$ 1 + 1 =" %_1% "2 $$"
"$$ 1 + 1 =" %_2% "2 $$"
"$$ 1 + 1 =" %_3% "2 $$"
"$$ 1 + 1 =" %_4% "2 $$"
"$$ 1 + 1 =" %_5% "2 $$"
## ----results='asis'------------------------------------------------------
"$$ 1 + 1= " %_% s(2) %_% "2 $$"
## ----results='hide'------------------------------------------------------
xx("1 + 1= ", s(2), "2")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.