---
format: 
  pdf:
    keep-tex: true
    latex-auto-install: false
params:
  display_name: ""
  pkg_path: ""
  transform: NULL

---

```{r echo = FALSE}

if(dir.exists(params$pkg_path)){
  devtools::load_all(params$pkg_path, export_all = FALSE, quiet = TRUE)
}else{
  suppressPackageStartupMessages(library(docorator))
}

```
  
```{r echo = FALSE}
dd <- readRDS(paste0(params$display_name, "_docorator_obj.Rds"))
geom <- docorator:::geom_process(dd$header,
                     dd$footer,
                     dd$fontsize,
                     dd$geometry)
```

---
geometry: "`r paste0(geom)`"
fontsize: "`r paste0(dd$fontsize, 'pt')`"
include-in-header:  
  - text: | 
      \renewcommand*\familydefault{\ttdefault}
      \usepackage{fancyhdr, lastpage}
      \usepackage{booktabs, longtable, colortbl, array, multirow, anyfontsize}
      \usepackage[labelformat=empty]{caption} 
      \usepackage{float}
      \floatplacement{table}{H}
      \IfFileExists{header.tex}{\input{header.tex}}{}
---
 
<!--- Define Headers and Footers --->
```{=tex}
\fancypagestyle{plain}{
  \renewcommand{\headrulewidth}{0pt}
  \fancyhf{}%
  `r docorator:::hf_process(dd$header)`
  `r docorator:::hf_process(dd$footer)`
}
\pagestyle{plain} 
```
 
\centering
 
```{r echo = FALSE, results = "asis"}
if (inherits(dd$display, c("gt_tbl","gt_group"))){
  prep_obj_tex(dd, params$transform)
} else {
  create_chunks_all(dd, params$transform)
}
```
