e_table_print: Print a data.frame table for latex and scale to fit page

View source: R/e_table_print.R

e_table_printR Documentation

Print a data.frame table for latex and scale to fit page

Description

If using in Rmd file and a latex documnet, then requires two header includes:

Usage

e_table_print(
  dat,
  sw_scale = FALSE,
  sw_kable_format = c("simple", "kbl", "html", "latex", "doc")[2],
  sw_latex_options = c("basic", "striped", "hold_position", "HOLD_position",
    "scale_down", "repeat_header")[c(2, 3)],
  ...
)

Arguments

dat

data.frame or tibble to print

sw_scale

if "latex" T/F to scale to fit page, if "html" then a point size to pass to kableExtra::kable_styling argument font_size

sw_kable_format

"simple", "html", "latex", or "doc"

sw_latex_options

passed to kableExtra::kable_styling(latex_options = sw_latex_options), updated if sw_scale=TRUE to include "scale_down"

...

other arguments passed to knitr::kable()

Details

EXAMPLE OF .Rmd YAML header for pdf via LaTeX

---
title: "Title"
date: "Today"
output:
  pdf_document:
    df_print: kable
    latex_engine: lualatex
    toc: true
    number_sections: true
    toc_depth: 2
    keep_tex: true
header-includes:
- \usepackage{booktabs}
- \usepackage{colortbl}
always_allow_html: yes
fig_caption: TRUE
---

Value

invisible(NULL)

Examples

dat_mtcars_e |> head() |> e_table_print()
## Not run: 
# html rescaled size
dat_mtcars_e |>
  head() |>
  e_table_print(sw_scale = 6)
# outputs into LaTeX document, scaling is automatic to fit page width
# works best before a \clearpage
# use chunk option: results = 'asis', see other options at https://yihui.org/knitr/options/
dat_mtcars_e |>
  head() |>
  e_table_print(sw_scale = TRUE, sw_kable_format = "latex")

## End(Not run)

erikerhardt/erikmisc documentation built on April 17, 2025, 10:48 a.m.