### Environment ====================================================================================
options("width" = 110)
project_name <- gsub("(.*)_.*", "\\1", basename(params[["project_directory"]]))


### Load packages ==================================================================================
library(here)

suppressPackageStartupMessages({
  library(knitr)
  library(ragg)
  library(ggplot2)
  library(ggtext)
  library(patchwork)
  library(data.table)
  library(mctemplates)
})


### knitr settings =================================================================================
opts_chunk$set(
  eval = TRUE,
  include = TRUE,
  echo = TRUE,
  warning = FALSE,
  message = FALSE,
  # dpi = 120,
  tidy = FALSE,
  crop = TRUE,
  autodep = TRUE,
  # results = "asis",
  fig.align = "center",
  width = getOption("width"),
  comment = "#>", 
  dev = "ragg_png"
)


### Define theme ===================================================================================
options(
  ggplot2.discrete.colour = function(...) scale_colour_viridis_d(..., begin = 0.15, end = 0.85),
  ggplot2.discrete.fill = function(...) scale_fill_viridis_d(..., begin = 0.15, end = 0.85),
  ggplot2.continuous.colour = function(...) scale_colour_viridis_c(..., begin = 0.15, end = 0.85),
  ggplot2.continuous.fill = function(...) scale_fill_viridis_c(..., begin = 0.15, end = 0.85)
)
theme_set(
  theme_black(base_family = "Times") +
  theme(
    plot.title.position = "plot",
    plot.caption.position = "plot",
    plot.title = element_markdown(),
    plot.subtitle = element_markdown(face = "italic", size = rel(0.8)),
    plot.caption = element_markdown(face = "italic", size = rel(0.65)),
    axis.title.x = element_markdown(),
    axis.text.x = element_markdown(),
    axis.title.y = element_markdown(),
    axis.text.y = element_markdown(),
    panel.grid = element_blank()
  )
)


### Source functions ===============================================================================

Title | Subtitle {.flexbox .vcenter}

Title 1 | Title 2

{.flexbox .vcenter}



mcanouil/mctemplates documentation built on Feb. 25, 2021, 5:17 p.m.