<-
tab_latex |>
gtcars ::select(mfr, model, msrp) |>
dplyr::slice(1:5) |>
dplyrgt() |>
tab_header(
title = md("Data listing from **gtcars**"),
subtitle = md("`gtcars` is an R dataset")
|>
) as_latex()
The as_latex()
function
Use a subset of the gtcars
dataset to create a gt table. Add a header with tab_header()
and then export the table as LaTeX code using the as_latex()
function.
What’s returned is a knit_asis
object, which makes it easy to include in R Markdown documents that are knit to PDF. We can use as.character()
to get just the LaTeX code as a single-element vector.