When outputting PDF, flextable uses latex's "longtable". longtable allows for separate headers for the first page and the second and subsequent pages. I want to add text like "(continued)" at the top of the header for the second and subsequent pages.
For this purpose,
I created the following function. Simply add text to the bottom of the latex source "\endfirsthead". It would be nice to be able to set any text, adjust font family, size, text alignment, etc. It might be nice if the footer could also be displayed on a page-by-page basis.
MyFunc <- function(x){
tableNcol <- ncol_keys(x)
if(!is.null(knitr::opts_knit$get("rmarkdown.pandoc.to"))){
if(knitr::opts_knit$get("rmarkdown.pandoc.to") %in% c("beamer", "latex")) {
flextable_to_rmd(x, print = FALSE) %>%
str_replace_all(
fixed("\\endfirsthead"),
fixed(str_glue("\\endfirsthead\n\n\\multicolumn{tableNcol}{{r}}{{(continued)}}\\\\", tableNcol=tableNcol))
) %>%
cat()
}
}else{
return(x)
}
}
If you use the following in a chunk, it will be rendered as is inline, and when knit, the latex source will be rewritten.
airquality %>%
slice(1:60) %>%
flextable() %>%
theme_booktabs() %>%
autofit() %>%
MyFunc()
When outputting PDF, flextable uses latex's "longtable". longtable allows for separate headers for the first page and the second and subsequent pages. I want to add text like "(continued)" at the top of the header for the second and subsequent pages.
For this purpose,
I created the following function. Simply add text to the bottom of the latex source "\endfirsthead". It would be nice to be able to set any text, adjust font family, size, text alignment, etc. It might be nice if the footer could also be displayed on a page-by-page basis.
If you use the following in a chunk, it will be rendered as is inline, and when knit, the latex source will be rewritten.