一种不同的,也许更明确和详细的方法,扩展了之前给出的答案。这将出现在\backmatter
一本书中。该值nColOut
是包含使用的包列表的打印表的列数。
\cleardoublepage
\printindex
\cleardoublepage
\chapter*{Packages}
<<packages, cache = FALSE, echo = FALSE, warning = FALSE, results = "asis">>=
nColOut = 7
packsAll <- unique(c(.packages(), loadedNamespaces(), readLines('cache/__packages')))
packsReduced <- setdiff(packsAll,
c("knitr", "stats", "graphics", "grDevices", "utils", "datasets", "methods", "base"))
howManyPacks <- packsReduced %>%
length()
numLines <-
tibble(numPacks = howManyPacks + 0:(nColOut - 1),
n = numPacks %% nColOut)
howManyToAdd <- numLines %>%
filter(n == 0) %>%
mutate(diff = numPacks - howManyPacks) %>%
pull(diff)
packsReduced %>%
sort() %>%
as_tibble() %>%
add_row(value = rep('', howManyToAdd)) %>%
mutate(id = rep(1:(length(value) / nColOut), nColOut),
col = rep(letters[1 : nColOut], each = length(value) / nColOut)) %>%
pivot_wider(names_from = col, values_from = value) %>%
select(-id) %>%
kable("latex", booktabs = TRUE, longtable = TRUE) %>%
kable_styling(latex_options = "repeat_header") %>%
row_spec(0, align = "c")
@