knitr::opts_chunk$set(echo = FALSE, warning = FALSE, message = FALSE)
knitr::knit_hooks$set(plot = function(x,options) {
      base = knitr::opts_knit$get('base.url')
      if (is.null(base)) base = ''
      alt = ifelse (is.null(options$alt),"",options$alt)
      cap = ifelse (is.null(options$caption),"",options$caption)
      if (alt != ""){
        sprintf('![%s](%s%s "%s")', cap, base, x, alt)
      } else {
        sprintf('![%s](%s%s)', cap, base, x)
        }
  })

load("00opts.Rdata")

if (is.null(params$model) & file.exists("00mod.Rdata")) {
  stopifnot(file.exists("00mod.Rdata"))
  load("00mod.Rdata")
} else {
  load(dir(params$model, pattern = "00mod.Rdata", full.names = TRUE))
}
# Load plotinfotable if it is available
if (!is.null(params$model)) {
  if (file.exists(file_figurecsv <- file.path(params$model, "plots", "plotinfotable_for_doc.csv"))) {
    figurecsv <- utils::read.csv(file_figurecsv) %>%
      dplyr::mutate(caption = gsub("\\n", "", caption))
    figurecsv[grepl("catch2", figurecsv[["label"]]), "caption"] <- "Landings (mt) by fleet (colors) used to fit the model."
  }
}

# AMAZING piece of code to allow for inline r in asis engine from
# https://stackoverflow.com/questions/32944715/conditionally-display-block-of-markdown-text-using-knitr
knitr::knit_engines$set(asis = function(options) {
  if (options$echo && options$eval) knitr::knit_child(text = options$code)
})
# Define knitr chunk options with names
# Use this within the chunk options as e.g.,
# opts.label = "north"
knitr::opts_template$set(north = list(
  echo = TRUE,
  eval = ifelse(grepl("North", params$area), TRUE, FALSE),
  include = TRUE
))
knitr::opts_template$set(south = list(
  echo = TRUE,
  eval = ifelse(grepl("South", params$area), TRUE, FALSE),
  include = TRUE
))

\newcommand\CapeM{40\textdegree 10\textquotesingle N} \newcommand\PtC{34\textdegree 27\textquotesingle N} \newcommand\CAOR{42\textdegree 00\textquotesingle N}



iantaylor-NOAA/Lingcod_2021 documentation built on Oct. 30, 2024, 6:42 p.m.