---
title: "Bookdown test"
output:
  bookdown::pdf_book: default
  bookdown::html_book: default
---

```{r setup, include=FALSE}
library(dplyr)
library(huxtable)

if( ! ((x <- guess_knitr_output_format()) %in% c('html', 'latex'))) {
  stop("guessed output is ", x)
}
if (! huxtable:::use_bookdown_style_captions()) {
  stop("huxtable:::use_bookdown_style_captions() returned FALSE")
} 
```

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

```{r}


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 labelled table, prefix should be autoadded!") %>% 
  set_label("foo2")

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

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

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

```
