Using texPreview in Rmarkdown HTML Documents

Jonathan Sidi

2019-05-05

library(texPreview)
library(magrittr)

tex_opts$set(
  returnType = knitr::opts_knit$get('rmarkdown.pandoc.to'),
  resizebox = FALSE  
)

The following examples use kable to generate LaTeX table outputs and raw LaTeX to pipe into tex_preview to render the in the document.

Kable Input


knitr::kable(head(iris,5),format = 'latex')%>%
tex_preview()

TeX Input

tab='
\\begin{tabular}{llr}
\\hline
\\multicolumn{2}{c}{Item} \\\\
\\cline{1-2}
Animal    & Description & Price (\\$) \\\\
\\hline
Gnat      & per gram    & 13.65      \\\\
          & each        & 0.01       \\\\
Gnu       & stuffed     & 92.50      \\\\
Emu       & stuffed     & 33.33      \\\\
Armadillo & frozen      & 8.99       \\\\
\\hline
\\end{tabular}'

tab%>%
  tex_preview()