2018-09-19 03:22:22 +02:00
|
|
|
##' Templates for RMarkdown-based Beamer PDF presentations supporting
|
|
|
|
##' the \sQuote{Metropolis} style by Matthias Vogelgesang and others,
|
2018-10-08 08:03:18 +02:00
|
|
|
##' the \sQuote{IQSS} style by Ista Zahn and Gary King,
|
|
|
|
##' and the \sQuote{Monash} style by Rob J Hyndman.
|
2018-09-15 16:05:26 +02:00
|
|
|
##'
|
2018-09-19 03:22:22 +02:00
|
|
|
##' Note that not all options and customizations available at the LaTeX
|
2018-09-20 13:11:43 +02:00
|
|
|
##' level are implemented or supported yet. A number of styling options
|
|
|
|
##' could be exposed by setting YAML meta-data in the header for either
|
|
|
|
##' style. This needs more testing and documentation.
|
|
|
|
##'
|
2018-09-19 03:22:22 +02:00
|
|
|
##' @title Binb is not Beamer - PDF Presentation Themes
|
2018-09-20 13:11:43 +02:00
|
|
|
##'
|
2018-09-15 16:05:26 +02:00
|
|
|
##' @param toc A logical variable defaulting to \code{FALSE}.
|
2018-09-19 03:22:22 +02:00
|
|
|
##' @param slide_level A numeric variable defaulting to two for
|
2018-10-08 08:03:18 +02:00
|
|
|
##' \sQuote{Metropolis} and \sQuote{Monash}, and three for \sQuote{IQSS}.
|
2018-09-15 16:05:26 +02:00
|
|
|
##' @param incremental A logical variable defaulting to \code{FALSE}.
|
|
|
|
##' @param fig_width A numeric variable defaulting to ten.
|
|
|
|
##' @param fig_height A numeric variable defaulting to seven.
|
|
|
|
##' @param fig_crop A logical variable defaulting to \code{TRUE}.
|
|
|
|
##' @param fig_caption A logical variable defaulting to \code{TRUE}.
|
|
|
|
##' @param dev A character variable defaulting to \dQuote{pdf}.
|
|
|
|
##' @param df_print A character variable defaulting to \dQuote{default}.
|
|
|
|
##' @param fonttheme A character variable defaulting to \dQuote{default}.
|
2018-11-21 22:30:57 +01:00
|
|
|
##' @param colortheme For the \sQuote{Monash} theme only. A character variable defaulting to \dQuote{monashwhite}.
|
2018-09-15 16:05:26 +02:00
|
|
|
##' @param highlight A character variable defaulting to \dQuote{tango}.
|
|
|
|
##' @param keep_tex A logical variable defaulting to \code{FALSE}.
|
|
|
|
##' @param latex_engine A character variable defaulting to \dQuote{xelatex}.
|
|
|
|
##' @param citation_package An optional character variable with possible value
|
2018-09-16 15:28:08 +02:00
|
|
|
##' \dQuote{none}, \dQuote{natbib} (the default), or \dQuote{biblatex}.
|
2018-09-15 16:05:26 +02:00
|
|
|
##' @param includes An optional character variable defaulting to \code{NULL}.
|
|
|
|
##' @param md_extensions An optional character variable defaulting to \code{NULL}.
|
|
|
|
##' @param pandoc_args An optional character variable defaulting to \code{NULL}.
|
2018-09-20 13:11:43 +02:00
|
|
|
##'
|
|
|
|
##' @section IQSS Details: We currently set \code{slide_level} to three to use
|
|
|
|
##' the same appearance as the LaTeX demo. This means section and sub-section headers
|
|
|
|
##' use one and two hash marks, new slides use three, and \dQuote{box} environments
|
|
|
|
##' start with four. More commonly, Beamer theme use two and work without subsections.
|
|
|
|
##'
|
|
|
|
##' @seealso Three other packages also offer RMarkdown interfaces to LaTeX
|
|
|
|
##' (or HTML) content: \code{\link[tint]{tint}} for Tufte-style pdf and html,
|
|
|
|
##' \code{\link[pinp]{pinp}} for two-column pdf vignettes, and
|
|
|
|
##' \code{\link[linl]{linl}} for LaTeX letters.
|
|
|
|
##'
|
|
|
|
##' @return RMarkdown content processed is returned for use by the
|
|
|
|
##' \code{\link[rmarkdown]{render}} function but the function is invoked
|
|
|
|
##' for it side effect of creating the pdf file.
|
|
|
|
##'
|
2018-09-15 16:05:26 +02:00
|
|
|
##' @author Dirk Eddelbuettel
|
2018-09-20 13:11:43 +02:00
|
|
|
##'
|
2018-09-19 03:22:22 +02:00
|
|
|
##' @examples
|
|
|
|
##' \dontrun{
|
|
|
|
##' library(rmarkdown)
|
|
|
|
##' draft("myslides.Rmd", template="metropolis", package="binb", edit=FALSE)
|
|
|
|
##' setwd("myslides") ## template creates a new subdir
|
|
|
|
##' render("myslides.Rmd")
|
|
|
|
##' }
|
2018-09-15 16:05:26 +02:00
|
|
|
metropolis <- function(toc = FALSE,
|
|
|
|
slide_level = 2,
|
|
|
|
incremental = FALSE,
|
|
|
|
fig_width = 10,
|
|
|
|
fig_height = 7,
|
|
|
|
fig_crop = TRUE,
|
|
|
|
fig_caption = TRUE,
|
|
|
|
dev = 'pdf',
|
|
|
|
df_print = "default",
|
|
|
|
fonttheme = "default",
|
|
|
|
highlight = "tango",
|
|
|
|
keep_tex = FALSE,
|
|
|
|
latex_engine = "xelatex",
|
|
|
|
citation_package = c("none", "natbib", "biblatex"),
|
|
|
|
includes = NULL,
|
|
|
|
md_extensions = NULL,
|
|
|
|
pandoc_args = NULL) {
|
|
|
|
|
|
|
|
template <- system.file("rmarkdown", "templates", "metropolis",
|
|
|
|
"resources", "template.tex",
|
|
|
|
package="binb")
|
|
|
|
|
|
|
|
rmarkdown::beamer_presentation(template = template,
|
|
|
|
toc = toc,
|
|
|
|
slide_level = slide_level,
|
|
|
|
incremental = incremental,
|
|
|
|
fig_width = fig_width,
|
|
|
|
fig_height = fig_height,
|
|
|
|
fig_crop = fig_crop,
|
|
|
|
fig_caption = fig_caption,
|
|
|
|
dev = dev,
|
|
|
|
df_print = df_print,
|
|
|
|
theme = "metropolis",
|
|
|
|
fonttheme = fonttheme,
|
|
|
|
highlight = highlight,
|
|
|
|
keep_tex = keep_tex,
|
|
|
|
latex_engine = latex_engine,
|
|
|
|
citation_package = citation_package,
|
|
|
|
includes = includes,
|
|
|
|
md_extensions = md_extensions,
|
|
|
|
pandoc_args = pandoc_args)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2018-09-16 15:28:08 +02:00
|
|
|
##' @rdname metropolis
|
|
|
|
iqss <- function(toc = FALSE,
|
|
|
|
slide_level = 3,
|
|
|
|
incremental = FALSE,
|
|
|
|
fig_width = 10,
|
|
|
|
fig_height = 7,
|
|
|
|
fig_crop = TRUE,
|
|
|
|
fig_caption = TRUE,
|
|
|
|
dev = 'pdf',
|
|
|
|
df_print = "default",
|
|
|
|
fonttheme = "default",
|
|
|
|
highlight = "haddock",
|
|
|
|
keep_tex = FALSE,
|
|
|
|
latex_engine = "xelatex",
|
|
|
|
citation_package = c("none", "natbib", "biblatex"),
|
|
|
|
includes = NULL,
|
|
|
|
md_extensions = NULL,
|
|
|
|
pandoc_args = NULL) {
|
|
|
|
|
|
|
|
for (f in c("beamercolorthemeiqss.sty", "beamerfontthemeiqss.sty",
|
|
|
|
"beamerthemeiqss.sty", "header.png", "figs/"))
|
|
|
|
if (!file.exists(f))
|
2018-09-22 17:28:26 +02:00
|
|
|
file.copy(system.file("rmarkdown", "templates", "iqss", "skeleton",
|
|
|
|
f, package="binb"),
|
2018-09-16 15:28:08 +02:00
|
|
|
".", recursive=TRUE)
|
|
|
|
|
|
|
|
template <- system.file("rmarkdown", "templates", "iqss",
|
|
|
|
"resources", "template.tex",
|
|
|
|
package="binb")
|
|
|
|
|
2018-09-22 17:28:26 +02:00
|
|
|
rmarkdown::beamer_presentation(template = template,
|
|
|
|
toc = toc,
|
|
|
|
slide_level = slide_level,
|
|
|
|
incremental = incremental,
|
|
|
|
fig_width = fig_width,
|
|
|
|
fig_height = fig_height,
|
|
|
|
fig_crop = fig_crop,
|
|
|
|
fig_caption = fig_caption,
|
|
|
|
dev = dev,
|
|
|
|
df_print = df_print,
|
|
|
|
theme = "iqss",
|
|
|
|
fonttheme = fonttheme,
|
|
|
|
highlight = highlight,
|
|
|
|
keep_tex = keep_tex,
|
|
|
|
latex_engine = latex_engine,
|
|
|
|
citation_package = citation_package,
|
|
|
|
includes = includes,
|
|
|
|
md_extensions = md_extensions,
|
|
|
|
pandoc_args = pandoc_args)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-10-08 08:03:18 +02:00
|
|
|
##' @rdname metropolis
|
|
|
|
monash <- function(toc = FALSE,
|
|
|
|
slide_level = 2,
|
|
|
|
incremental = FALSE,
|
|
|
|
fig_width = 8,
|
|
|
|
fig_height = 5,
|
|
|
|
fig_crop = TRUE,
|
|
|
|
fig_caption = TRUE,
|
|
|
|
dev = 'pdf',
|
|
|
|
df_print = "default",
|
|
|
|
fonttheme = "default",
|
2018-11-21 11:14:39 +01:00
|
|
|
colortheme = "monashwhite",
|
2018-10-08 08:03:18 +02:00
|
|
|
highlight = "tango",
|
|
|
|
keep_tex = FALSE,
|
|
|
|
latex_engine = "pdflatex",
|
|
|
|
citation_package = c("none", "natbib", "biblatex"),
|
|
|
|
includes = NULL,
|
|
|
|
md_extensions = NULL,
|
2018-11-21 22:30:57 +01:00
|
|
|
pandoc_args = NULL) {
|
2018-10-08 08:03:18 +02:00
|
|
|
|
2018-11-21 11:14:39 +01:00
|
|
|
fcolortheme <- paste0("beamercolortheme",colortheme,".sty")
|
|
|
|
for (f in c("beamerfontthememonash.sty",fcolortheme,
|
2018-10-08 08:03:18 +02:00
|
|
|
"beamerthememonash.sty", "titlepage.png", "figs/"))
|
|
|
|
if (!file.exists(f))
|
|
|
|
file.copy(system.file("rmarkdown", "templates", "monash", "skeleton",
|
|
|
|
f, package="binb"),
|
|
|
|
".", recursive=TRUE)
|
|
|
|
|
|
|
|
template <- system.file("rmarkdown", "templates", "monash",
|
|
|
|
"resources", "template.tex",
|
|
|
|
package="binb")
|
|
|
|
|
|
|
|
rmarkdown::beamer_presentation(template = template,
|
|
|
|
toc = toc,
|
|
|
|
slide_level = slide_level,
|
|
|
|
incremental = incremental,
|
|
|
|
fig_width = fig_width,
|
|
|
|
fig_height = fig_height,
|
|
|
|
fig_crop = fig_crop,
|
|
|
|
fig_caption = fig_caption,
|
|
|
|
dev = dev,
|
|
|
|
df_print = df_print,
|
|
|
|
theme = "monash",
|
2018-11-21 11:14:39 +01:00
|
|
|
colortheme = colortheme,
|
2018-10-08 08:03:18 +02:00
|
|
|
fonttheme = fonttheme,
|
|
|
|
highlight = highlight,
|
|
|
|
keep_tex = keep_tex,
|
|
|
|
latex_engine = latex_engine,
|
|
|
|
citation_package = citation_package,
|
|
|
|
includes = includes,
|
|
|
|
md_extensions = md_extensions,
|
|
|
|
pandoc_args = pandoc_args)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2018-09-22 17:28:26 +02:00
|
|
|
##' @rdname metropolis
|
|
|
|
presento <- function(toc = FALSE,
|
|
|
|
slide_level = 2,
|
|
|
|
incremental = FALSE,
|
|
|
|
fig_width = 10,
|
|
|
|
fig_height = 7,
|
|
|
|
fig_crop = TRUE,
|
|
|
|
fig_caption = TRUE,
|
|
|
|
dev = 'pdf',
|
|
|
|
df_print = "default",
|
|
|
|
fonttheme = "default",
|
|
|
|
highlight = "haddock",
|
|
|
|
keep_tex = FALSE,
|
|
|
|
latex_engine = "xelatex",
|
|
|
|
citation_package = c("none", "natbib", "biblatex"),
|
|
|
|
includes = NULL,
|
|
|
|
md_extensions = NULL,
|
|
|
|
pandoc_args = NULL) {
|
|
|
|
|
|
|
|
for (f in c("presento.sty", "images/"))
|
|
|
|
if (!file.exists(f))
|
|
|
|
file.copy(system.file("rmarkdown", "templates",
|
|
|
|
"presento", "skeleton", f, package="binb"),
|
|
|
|
".", recursive=TRUE)
|
|
|
|
|
|
|
|
template <- system.file("rmarkdown", "templates", "presento",
|
|
|
|
"resources", "template.tex",
|
|
|
|
package="binb")
|
|
|
|
|
2018-09-16 15:28:08 +02:00
|
|
|
rmarkdown::beamer_presentation(template = template,
|
|
|
|
toc = toc,
|
|
|
|
slide_level = slide_level,
|
|
|
|
incremental = incremental,
|
|
|
|
fig_width = fig_width,
|
|
|
|
fig_height = fig_height,
|
|
|
|
fig_crop = fig_crop,
|
|
|
|
fig_caption = fig_caption,
|
|
|
|
dev = dev,
|
|
|
|
df_print = df_print,
|
|
|
|
theme = "iqss",
|
|
|
|
fonttheme = fonttheme,
|
|
|
|
highlight = highlight,
|
|
|
|
keep_tex = keep_tex,
|
|
|
|
latex_engine = latex_engine,
|
|
|
|
citation_package = citation_package,
|
|
|
|
includes = includes,
|
|
|
|
md_extensions = md_extensions,
|
|
|
|
pandoc_args = pandoc_args)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-09-15 16:05:26 +02:00
|
|
|
# Call rmarkdown::pdf_documet and mark the return value as inheriting pdf_document
|
|
|
|
inherit_pdf_document <- function(...) {
|
|
|
|
fmt <- rmarkdown::pdf_document(...)
|
|
|
|
fmt$inherits <- "pdf_document"
|
|
|
|
fmt
|
|
|
|
}
|
|
|
|
|
|
|
|
knitr_fun <- function(name) utils::getFromNamespace(name, 'knitr')
|
|
|
|
|
|
|
|
output_asis <- knitr_fun('output_asis')
|