diff --git a/R/compile_report.R b/R/compile_report.R index c6309eb..0d62065 100644 --- a/R/compile_report.R +++ b/R/compile_report.R @@ -52,11 +52,10 @@ compile_report <- function(rmd_filename = list.files(pattern = "\\.Rmd$")[1], ) officer::read_docx("temp_report.docx") %>% - officer::cursor_reach(keyword = "Introduction") %>% - officer::body_add_toc(pos = "before", level = toc_level) %>% + officer::cursor_begin() %>% officer::body_add_par("Contents", pos = "before", style = "TOC Heading") %>% - officer::cursor_reach(keyword = "Introduction") %>% - officer::body_add_break(pos = "before") %>% + officer::body_add_toc(pos = "after", level = toc_level) %>% + officer::body_add_break(pos = "after") %>% print("temp_report2.docx") # Cover Page diff --git a/R/phs_report_docx.R b/R/phs_report_docx.R index 3ab1350..ed14a16 100644 --- a/R/phs_report_docx.R +++ b/R/phs_report_docx.R @@ -106,11 +106,10 @@ phs_report_docx <- function(toc = FALSE, stitle = cover_subtitle, dt = cover_date, tocd = toc_depth) { officer::read_docx(output_file) %>% - officer::cursor_reach(keyword = "Introduction") %>% - officer::body_add_toc(pos = "before", level = tocd) %>% + officer::cursor_begin() %>% officer::body_add_par("Contents", pos = "before", style = "TOC Heading") %>% - officer::cursor_reach(keyword = "Introduction") %>% - officer::body_add_break(pos = "before") %>% + officer::body_add_toc(pos = "after", level = tocd) %>% + officer::body_add_break(pos = "after") %>% print(output_file) # Cover Page