R/uc_presentation.R

Defines functions bcat_xaringan bcat_beamer

Documented in bcat_beamer bcat_xaringan

#' UC Beamer presentation
#'
#' An R Markdown output format for Beamer presentations (PDF).
#'
#' @param in_header relative path to a tex formatting document included in the preamble.
#' If \code{NULL} (default), function will use the preamble.tex file included with the package.
#' @param ... other options passed to \code{rmarkdown::beamer_presentation}
#'
#' @return An \code{rmarkdown::output_format} object for rendering Beamer
#'   presentations.
#'
#' @author Saannidhya Rawat
#' @export
#'
bcat_beamer <- function(in_header = NULL,
                        ...){

  if (is.null(in_header)) {
    in_header <- system.file("rmarkdown", "templates", "bcat_beamer" ,"assets",
                             "preamble.tex", package = "Rbearcat")
  }

  rmarkdown::beamer_presentation(includes = rmarkdown::includes(in_header = in_header),
                                 highlight = "tango",
                                 latex_engine = "xelatex",
                                 theme = "default",
                                 ...)

}

#' UC Xaringan presentation
#'
#' An R Markdown output format for remark.js slides (HTML).
#'
#' @param css A vector of CSS file paths.
#' If \code{NULL} (default), function will use the css files included with the package.
#' @param after_body relative path to HTML document to include after body of each slide.
#' If \code{NULL} (default), function will use the insert-logo.html file included with the package.
#' @param ... arguments passed to \code{xaringan::moon_reader}
#'
#' @return An \code{rmarkdown::output_format} object for rendering Xaringan
#'   presentations.
#'
#' @author Saannidhya Rawat
#' @export
#'
bcat_xaringan <- function(css = NULL,
                          after_body = NULL,
                          ...){

  if(is.null(css)){

    css_theme <- system.file("rmarkdown", "templates", "bcat_xaringan" ,"assets",
                             "theme.css", package = "Rbearcat")

    css_fonts <- system.file("rmarkdown", "templates", "bcat_xaringan" ,"assets",
                             "fonts.css", package = "Rbearcat")

    css <- c("default", css_theme, css_fonts)

  }

  if(is.null(after_body)){
    after_body <- system.file("rmarkdown", "templates", "bcat_xaringan" ,"assets",
                              "insert-logo.html", package = "Rbearcat")
  }

  xaringan::moon_reader(css = css,
                        seal = FALSE,
                        yolo = FALSE,
                        lib_dir = "libs",
                        includes = rmarkdown::includes(after_body = after_body),
                        ...)

}

Try the Rbearcat package in your browser

Any scripts or data that you put into this service are public.

Rbearcat documentation built on March 21, 2026, 5:07 p.m.