This function overcomes/works around a recent issue with
kable(..., longtable = TRUE) and kable_styling(..., full_width = TRUE)
which fail when knitting to PDF (see https://stackoverflow.com/questions/71651334/longtable-t-messes-up-with-scaled-down-table-in-r-markdown-pdf/72511243#72511243).
It uses pander::pander.table to automatically deal with long/wide tables when knitting to PDF
and knitr::kable when knitting to HTML.
Note that the chunk option results must be set to "asis".
Arguments
- tab
table object compatible with
pander::panderANDknitr::kable- caption
a caption. Make sure special LaTeX characters are escaped.
bookdowntext references can be useful when formatting text and using special characters (https://bookdown.org/yihui/bookdown/markdown-extensions-by-bookdown.html#text-references).- landscape
if TRUE panderOptions are changed so that the page can be put in landscape position. Note that this requires adding
\\newpageand\begin{landscape}before the chunk and\end{landscape}after the chunk.- panderArgs
named list of additional arguments passed to
pander. Do NOT pass the caption and input table arguments.- kableArgs
named list of additional arguments passed to
kable. Do NOT pass the caption and input table arguments.- kable_stylingArgs
named list of additional arguments passed to
kable_styling. Do NOT pass the input table argument.- column_specArgs
named list of additional arguments passed to
column_spec. Do NOT pass the input table argument.