Skip to content

Commit

Permalink
Fix refstepcounter issue
Browse files Browse the repository at this point in the history
  • Loading branch information
cgrandin committed Jun 14, 2024
1 parent 527e668 commit 337b33c
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 21 deletions.
11 changes: 5 additions & 6 deletions R/add-appendix-subsection-refs.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
})

Expand Down
1 change: 0 additions & 1 deletion R/fix-envs.R
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
14 changes: 0 additions & 14 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
#'
Expand Down

0 comments on commit 337b33c

Please sign in to comment.