From 74dcb7195f3e2434d7bb31835eb35ba707898d2e Mon Sep 17 00:00:00 2001 From: Sam Schiano <125507018+Schiano-NOAA@users.noreply.github.com> Date: Fri, 2 Oct 2026 15:49:24 -0400 Subject: [PATCH] fix issue not rendering report without bib files --- R/create_template.R | 6 +++--- R/utils_tex.R | 4 +++- inst/resources/formatting_files/in-header.tex | 2 -- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/R/create_template.R b/R/create_template.R index d940172ae..e10567787 100644 --- a/R/create_template.R +++ b/R/create_template.R @@ -603,7 +603,7 @@ create_template <- function( # customize titlepage tex if (!file.exists(file_dir, "support_files", "_titlepage.tex") | !is.null(species)) create_titlepage_tex(office = office, subdir = supdir, species = species) # customize in-header tex - if (!file.exists(file_dir, "support_files", "in-header.tex") | !is.null(species)) create_inheader_tex(species = species, year = year, subdir = supdir) + if (!file.exists(file_dir, "support_files", "in-header.tex") | !is.null(species)) create_inheader_tex(species = species, year = year, subdir = supdir, bib_file = bib_file) } } else { #### Copy template files to report folder ---- @@ -621,7 +621,7 @@ create_template <- function( # customize titlepage tex create_titlepage_tex(office = office, subdir = supdir, species = species) # customize in-header tex - create_inheader_tex(species = species, year = year, subdir = supdir) + create_inheader_tex(species = species, year = year, subdir = supdir, bib_file = bib_file) # Copy species image from package file.copy(spp_image, supdir, overwrite = FALSE) |> suppressWarnings() # Copy us doc logo @@ -677,7 +677,7 @@ create_template <- function( # customize titlepage tex create_titlepage_tex(office = office, subdir = supdir, species = species) # customize in-header tex - create_inheader_tex(species = species, year = year, subdir = supdir) + create_inheader_tex(species = species, year = year, subdir = supdir, bib_file = bib_file) # Copy species image from package file.copy(spp_image, supdir, overwrite = FALSE) |> suppressWarnings() # Copy us doc logo diff --git a/R/utils_tex.R b/R/utils_tex.R index c6d98b276..48f176a1c 100644 --- a/R/utils_tex.R +++ b/R/utils_tex.R @@ -64,7 +64,7 @@ create_titlepage_tex <- function(office = "", #' @return Create an in-header latex document that dynamically changes based on #' the species and year along with other factors. #' @export -create_inheader_tex <- function(species = NULL, year = NULL, subdir) { +create_inheader_tex <- function(species = NULL, year = NULL, subdir, bib_file = TRUE) { if (is.null(year)) { year <- format(as.POSIXct(Sys.Date(), format = "%YYYY-%mm-%dd"), "%Y") } @@ -73,6 +73,7 @@ create_inheader_tex <- function(species = NULL, year = NULL, subdir) { ) if (is.null(species)) { to_add <- paste( + {if (isTRUE(bib_file)) "% Link journals package\n\\usepackage{journals-bibnames}\n\n"}, "\\usepackage[headsepline=0.005pt:,footsepline=0.005pt:,plainfootsepline,automark]{scrlayer-scrpage}", "\n", "\\clearpairofpagestyles", "\n", "\\ohead[]{\\headmark} \\cofoot[\\pagemark]{\\pagemark}", "\n", @@ -85,6 +86,7 @@ create_inheader_tex <- function(species = NULL, year = NULL, subdir) { lines <- append(lines, to_add) } else { to_add <- paste( + {if (isTRUE(bib_file)) "% Link journals package\n\\usepackage{journals-bibnames}\n\n"}, "\\usepackage[headsepline=0.005pt:,footsepline=0.005pt:,plainfootsepline,automark]{scrlayer-scrpage}", "\n", "\\clearpairofpagestyles", "\n", "\\ohead[]{\\headmark} \\cofoot[\\pagemark]{\\pagemark}", "\n", diff --git a/inst/resources/formatting_files/in-header.tex b/inst/resources/formatting_files/in-header.tex index d68c2a2ee..3e1d063b8 100644 --- a/inst/resources/formatting_files/in-header.tex +++ b/inst/resources/formatting_files/in-header.tex @@ -41,5 +41,3 @@ % \addtokomafont{subsection}{\subsectionfont} % \addtokomafont{subsubsection}{\subsubsectionfont} -% Link journals package -\usepackage{journals-bibnames}