Using texPreview to Convert TeX lines to Kable Objects

knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)
library(texPreview)

tex_opts$set( 
  returnType = 'html',
  opts.html   = list(width = '50%', height = '50%')
)

read the lines in the tex file

tex_file <- system.file('examples/toy/toy.tex',package = 'texPreview')
readLines(tex_file)

convert lines into knitr_kable

kbl <- tex_file |>
  texPreview::as.kable()

preview the table

kbl |>
  texPreview::tex_preview()

use kableExtra to manipulate the table and preview

kbl |>  
  kableExtra::collapse_rows(columns = 1:2, 
                            latex_hline = "major", 
                            valign = "middle") |>
  texPreview::tex_preview()


Try the texPreview package in your browser

Any scripts or data that you put into this service are public.

texPreview documentation built on March 31, 2022, 9:05 a.m.