inst/manuscript/_common.R

suppressPackageStartupMessages(
    withr::with_dir(
        usethis::proj_get(), pkgload::load_all(helpers = TRUE, export_all = TRUE)
    )
)

# global options ----------------------------------------------------------
options(tidyverse.quiet = TRUE)

# bookdown ----------------------------------------------------------------
options(tinytex.verbose = TRUE)
options(bookdown.post.latex = function(lines){
    rep_pos = grep('\\definecolor{shadecolor}{RGB}{248,248,248}',lines, fixed = TRUE)
    lines[rep_pos] = '\\definecolor{shadecolor}{RGB}{230,230,230}'
    lines
})

# knitr -------------------------------------------------------------------
knitr::opts_chunk$set(
    out.width = '100%',
    echo = FALSE,
    results = "markup",
    message = FALSE,
    warning = FALSE,
    cache = TRUE,
    comment = "#>",
    fig.retina = 0.8, # figures are either vectors or 300 dpi diagrams
    dpi = 300,
    out.width = "70%",
    fig.align = 'center',
    fig.width = 6,
    fig.asp = 0.618,  # 1 / phi
    fig.show = "hold",
    eval.after = 'fig.cap' # so captions can use link to demos
)

# index.R metadata --------------------------------------------------------
index <- new.env() 
DESCRIPTION <- desc::description$new(usethis::proj_get())
index$title       <- function() DESCRIPTION$get_field('Title')
index$subtitle    <- function() DESCRIPTION$get_field('Subtitle')
index$description <- function() DESCRIPTION$get_field('Description')
index$author      <- function() paste(unlist(DESCRIPTION$get_author())[c('given', 'family')], collapse = ' ')
index$date        <- base::Sys.Date
index$url         <- function() DESCRIPTION$get_urls()
index$cover_image <- function() NULL # "images/cover.png" 
index$favicon     <- function() "favicon.ico"
index$github_repo <- function() "Kiwi-Random-House/R-Projects"
Kiwi-Random-House/R-Projects documentation built on Dec. 31, 2020, 2:10 p.m.