library(tufte)
library(dplyr)
library(huxtable)
# invalidate cache when the tufte version changes
knitr::opts_chunk$set(tidy = FALSE, cache.extra = packageVersion('tufte'), echo = FALSE)
options(htmltools.dir.version = FALSE)
if( ! ((x <- guess_knitr_output_format()) %in% c('html', 'latex'))) stop("guessed output is ", x)

Output format is r guess_knitr_output_format(). My table is \@ref(tab:foo1). The other table is \@ref(tab:foo2). The third is \@ref(tab:foo3).

hux(a = 1:5, b = 1:5) %>% 
  set_caption("My labelled table") %>% 
  set_label("tab:foo1")


hux(a = 1:5, b = 1:5) %>% 
  set_caption("My unlabelled table")

hux(a = 1:5, b = 1:5) %>% 
  set_caption("My labelled table, prefix should be autoadded!") %>% 
  set_label("foo2")

hux(a = "A table with no caption, but a label") %>% 
  set_label("tab:foo3")

x <- hux(a = "A table with no caption or label")
x

huxtable:::make_caption(x, huxtable:::make_label(x))
x <- hux(1:3)
caption(x) <- "a caption"
x


hughjonesd/huxtable documentation built on Feb. 17, 2024, 12:20 a.m.