diff --git a/R/add-appendix-subsection-refs.R b/R/add-appendix-subsection-refs.R index 1bf5489..be94aa1 100644 --- a/R/add-appendix-subsection-refs.R +++ b/R/add-appendix-subsection-refs.R @@ -179,13 +179,12 @@ add_appendix_subsection_refs <- function(x){ # Add referencing so the appendix can be referenced in the document # with a link - - counter_lines <- "\refstepcounter{chapter}" - if(app_ind == 1){ - counter_lines <- c("\renewcommand{\thechapter}{A}", - counter_lines) - } + counter_lines <- c(paste0("\\renewcommand{\\thechapter}{", + toupper(LETTERS[app_ind]), + "}"), + "\\refstepcounter{chapter}") app <- c(counter_lines, app) + app }) diff --git a/R/fix-envs.R b/R/fix-envs.R index ee53c38..fc75e5f 100644 --- a/R/fix-envs.R +++ b/R/fix-envs.R @@ -136,7 +136,6 @@ fix_envs <- function(x, ) } } - x <- inject_refstepcounters(x) if (pandoc_curr_ver_is_before()) { # Need to remove hypertarget for references to appendices to work: diff --git a/R/utils.R b/R/utils.R index 6ff9b2b..b4d6c09 100644 --- a/R/utils.R +++ b/R/utils.R @@ -296,20 +296,6 @@ fr <- function(){ getOption("french", default = FALSE) } -inject_refstepcounters <- function(x) { - chpts <- grep("^\\\\starredchapter\\{", x) - for (i in chpts) { - # in very rare setups hypertarget doesn't appear(?): - .i <- if (grepl("hypertarget", x[i - 1])) i else i + 1 - x <- c( - x[seq(1, .i - 3)], - paste0(x[.i - 2], "\n\n\\clearpage\n\n\\refstepcounter{chapter}"), - x[seq(.i - 1, length(x))] - ) - } - x -} - # nocov start #' Add a Res Doc titlepage to a docx file #'