是否有一个包可以创建一个带有 headers mid-table 的单独部分的 rmarkdown table? (首选 pdf 输出)

Is there a package to create an rmarkdown table with separate sections with headers mid-table? (preferred pdf output)

我正在使用 rmarkdown 创建文档,最终用于 pdf 输出。

我想制作一个 table,其中包含多个带有子标题(标题、摘要、介绍等)的部分,例如下面的 table

到目前为止我已经做了以下内容,但我希望在标题行(“标题”、“摘要”等)之外显示垂直线:


{r prch}

pc = structure(list(`Section/topic` = c("\textbf{Title}", "Title", 
"\textbf{Abstract}", "Structured summary"), `Item No` = c("", 
"1", "", "2"), `Checklist item` = c("", "Identify the report as a systematic review, meta-analysis, or both", 
"", "Provide a structured summary including, as applicable, background, objectives, data sources, study eligibility criteria, participants, interventions, "
), `Reported on page No` = c("", "", "", "")), row.names = c(NA, 
-4L), class = c("tbl_df", "tbl", "data.frame"))

pc%>%
  kbl(longtable = T, escape = F,  booktabs = T)%>%
  column_spec(1, width = "8em")%>%
  column_spec(3, width = "20em")%>%
  column_spec(4, width = "6em")%>%
  kable_styling(latex_options = c("repeat"))

这是一个基于 huxtable 的解决方案。 (我的包裹。)


library(huxtable)

ht <- tribble_hux(
  ~ "Section/topic", ~ "Item no", ~ "Checklist item", ~ "Reported on Page No",
  "Title"          , ""         , ""                , "",
  "Title"          , "1"        , "Identify..."     , "", 
  "Abstract"       , ""         , ""                , "",
  "Structured summary", "2"     , "Provide..."      , ""
  # et cetera...
) 


# using the pipe from 4.1.0...

ht |> 
  set_header_rows(c(2, 4), TRUE)                |>
  merge_across(c(2, 4), everywhere)             |>
  style_header_rows(bold = TRUE)                |>
  set_all_borders(brdr(0.4, "solid", "grey70")) |>
  set_background_color("grey97")                |>
  set_background_color(1, 1:3, "grey90")        |>
  set_col_width(c(0.2, 0.05, 0.55, 0.2))        |>
  set_font("cmss")                              |>
  quick_pdf()