I'm creating a document with rmarkdown
, ultimately for pdf output.
I'd like to make a table that has multiple sections with subheadings (title, abstract, introduction etc.) such as the table below
I've made the following so far, but I'd like to have the vertical lines present apart from the heading rows("Title", "Abstract" etc):
{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"))
Here's a huxtable-based solution. (My package.)
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()