Added monash theme

This commit is contained in:
Rob J Hyndman 2018-10-08 17:03:18 +11:00
parent 65948308ce
commit 91ca8fd519
10 changed files with 676 additions and 5 deletions

View File

@ -1,3 +1,3 @@
export("metropolis", "iqss", "presento")
export("metropolis", "iqss", "presento", "monash")
import("knitr")
import("rmarkdown")

View File

@ -1,6 +1,7 @@
##' Templates for RMarkdown-based Beamer PDF presentations supporting
##' the \sQuote{Metropolis} style by Matthias Vogelgesang and others,
##' and the \sQuote{IQSS} style by Ista Zahn and Gary King.
##' the \sQuote{IQSS} style by Ista Zahn and Gary King,
##' and the \sQuote{Monash} style by Rob J Hyndman.
##'
##' Note that not all options and customizations available at the LaTeX
##' level are implemented or supported yet. A number of styling options
@ -11,7 +12,7 @@
##'
##' @param toc A logical variable defaulting to \code{FALSE}.
##' @param slide_level A numeric variable defaulting to two for
##' \sQuote{Metrpolis} and three for \sQuote{IQSS}.
##' \sQuote{Metropolis} and \sQuote{Monash}, and three for \sQuote{IQSS}.
##' @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.
@ -149,6 +150,58 @@ iqss <- function(toc = FALSE,
}
##' @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",
highlight = "tango",
keep_tex = FALSE,
latex_engine = "pdflatex",
citation_package = c("none", "natbib", "biblatex"),
includes = NULL,
md_extensions = NULL,
pandoc_args = NULL) {
for (f in c("beamercolorthememonash.sty", "beamerfontthememonash.sty",
"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",
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)
}
##' @rdname metropolis
presento <- function(toc = FALSE,
slide_level = 2,

View File

@ -0,0 +1,370 @@
\PassOptionsToPackage{unicode=true}{hyperref} % options for packages loaded elsewhere
\PassOptionsToPackage{hyphens}{url}
\documentclass[$if(fontsize)$$fontsize$,$endif$$if(lang)$$babel-lang$,$endif$$if(handout)$handout,$endif$$if(colorlinks)$dvipsnames,$endif$$if(beamer)$ignorenonframetext,$endif$$for(classoption)$$classoption$$sep$,$endfor$]{$documentclass$}
\setbeamertemplate{caption}[numbered]
\setbeamertemplate{caption label separator}{: }
\setbeamercolor{caption name}{fg=normal text.fg}
\beamertemplatenavigationsymbols$if(navigation)$$navigation$$else$empty$endif$
$if(fontfamily)$
\usepackage[$for(fontfamilyoptions)$$fontfamilyoptions$$sep$,$endfor$]{$fontfamily$}
$else$
\usepackage{lmodern}
$endif$
\usepackage{amssymb,amsmath}
\usepackage{ifxetex,ifluatex}
\usepackage{fixltx2e} % provides \textsubscript
\ifnum 0\ifxetex 1\fi\ifluatex 1\fi=0 % if pdftex
\usepackage[$if(fontenc)$$fontenc$$else$T1$endif$]{fontenc}
\usepackage[utf8]{inputenc}
$if(euro)$
\usepackage{eurosym}
$endif$
\else % if luatex or xelatex
\ifxetex
\usepackage{mathspec}
\else
\usepackage{fontspec}
\fi
\defaultfontfeatures{Ligatures=TeX,Scale=MatchLowercase}
$for(fontfamilies)$
\newfontfamily{$fontfamilies.name$}[$fontfamilies.options$]{$fontfamilies.font$}
$endfor$
$if(euro)$
\newcommand{\euro}{}
$endif$
$if(mainfont)$
\setmainfont[$for(mainfontoptions)$$mainfontoptions$$sep$,$endfor$]{$mainfont$}
$endif$
$if(sansfont)$
\setsansfont[$for(sansfontoptions)$$sansfontoptions$$sep$,$endfor$]{$sansfont$}
$endif$
$if(monofont)$
\setmonofont[Mapping=tex-ansi$if(monofontoptions)$,$for(monofontoptions)$$monofontoptions$$sep$,$endfor$$endif$]{$monofont$}
$endif$
$if(mathfont)$
\setmathfont(Digits,Latin,Greek)[$for(mathfontoptions)$$mathfontoptions$$sep$,$endfor$]{$mathfont$}
$endif$
$if(CJKmainfont)$
\usepackage{xeCJK}
\setCJKmainfont[$for(CJKoptions)$$CJKoptions$$sep$,$endfor$]{$CJKmainfont$}
$endif$
\fi
$if(theme)$
\usetheme[$for(themeoptions)$$themeoptions$$sep$,$endfor$]{$theme$}
$endif$
$if(colortheme)$
\usecolortheme{$colortheme$}
$endif$
$if(fonttheme)$
\usefonttheme{$fonttheme$}
$endif$
$if(titlefontsize)$
\setbeamerfont{title}{series=\bfseries,parent=structure,size=\fontsize{$titlefontsize$}{32}}
$endif$
$if(mainfont)$
\usefonttheme{serif} % use mainfont rather than sansfont for slide text
$endif$
$if(innertheme)$
\useinnertheme{$innertheme$}
$endif$
$if(outertheme)$
\useoutertheme{$outertheme$}
$endif$
% use upquote if available, for straight quotes in verbatim environments
\IfFileExists{upquote.sty}{\usepackage{upquote}}{}
% use microtype if available
\IfFileExists{microtype.sty}{%
\usepackage{microtype}
\UseMicrotypeSet[protrusion]{basicmath} % disable protrusion for tt fonts
}{}
$if(lang)$
\ifnum 0\ifxetex 1\fi\ifluatex 1\fi=0 % if pdftex
\usepackage[shorthands=off,$for(babel-otherlangs)$$babel-otherlangs$,$endfor$main=$babel-lang$]{babel}
$if(babel-newcommands)$
$babel-newcommands$
$endif$
\else
\usepackage{polyglossia}
\setmainlanguage[$polyglossia-lang.options$]{$polyglossia-lang.name$}
$for(polyglossia-otherlangs)$
\setotherlanguage[$polyglossia-otherlangs.options$]{$polyglossia-otherlangs.name$}
$endfor$
\fi
$endif$
\newif\ifbibliography
$if(natbib)$
\usepackage[round]{natbib}
\bibliographystyle{$if(biblio-style)$$biblio-style$$else$plainnat$endif$}
$endif$
$if(biblatex)$
\usepackage[$if(biblio-style)$style=$biblio-style$,$endif$$for(biblatexoptions)$$biblatexoptions$$sep$,$endfor$]{biblatex}
$for(bibliography)$
\addbibresource{$bibliography$}
$endfor$
$endif$
$if(verbatim-in-note)$
\usepackage{fancyvrb}
$endif$
\hypersetup{
$if(title-meta)$
pdftitle={$title-meta$},
$endif$
$if(author-meta)$
pdfauthor={$author-meta$},
$endif$
$if(keywords)$
pdfkeywords={$for(keywords)$$keywords$$sep$, $endfor$},
$endif$
$if(colorlinks)$
colorlinks=true,
linkcolor=$if(linkcolor)$$linkcolor$$else$Maroon$endif$,
citecolor=$if(citecolor)$$citecolor$$else$Blue$endif$,
urlcolor=$if(urlcolor)$$urlcolor$$else$Blue$endif$,
$else$
pdfborder={0 0 0},
$endif$
breaklinks=true}
%\urlstyle{same} % Use monospace font for urls
$if(verbatim-in-note)$
\VerbatimFootnotes % allows verbatim text in footnotes
$endif$
$if(listings)$
\usepackage{listings}
$endif$
$if(lhs)$
\lstnewenvironment{code}{\lstset{language=Haskell,basicstyle=\small\ttfamily}}{}
$endif$
$if(highlighting-macros)$
$highlighting-macros$
$endif$
$if(tables)$
\usepackage{longtable,booktabs}
\usepackage{caption}
% These lines are needed to make table captions work with longtable:
\makeatletter
\def\fnum@table{\tablename~\thetable}
\makeatother
$endif$
$if(graphics)$
\usepackage{graphicx,grffile}
\makeatletter
\def\maxwidth{\ifdim\Gin@nat@width>\linewidth\linewidth\else\Gin@nat@width\fi}
\def\maxheight{\ifdim\Gin@nat@height>\textheight0.8\textheight\else\Gin@nat@height\fi}
\makeatother
% Scale images if necessary, so that they will not overflow the page
% margins by default, and it is still possible to overwrite the defaults
% using explicit options in \includegraphics[width, height, ...]{}
\setkeys{Gin}{width=\maxwidth,height=\maxheight,keepaspectratio}
$endif$
% Prevent slide breaks in the middle of a paragraph:
\widowpenalties 1 10000
\raggedbottom
$if(section-titles)$
\AtBeginPart{
\let\insertpartnumber\relax
\let\partname\relax
\frame{\partpage}
}
\AtBeginSection{
\ifbibliography
\else
\let\insertsectionnumber\relax
\let\sectionname\relax
\frame{\sectionpage}
\fi
}
\AtBeginSubsection{
\let\insertsubsectionnumber\relax
\let\subsectionname\relax
\frame{\subsectionpage}
}
$endif$
$if(links-as-notes)$
% Make links footnotes instead of hotlinks:
\renewcommand{\href}[2]{#2\footnote{\url{#1}}}
$endif$
$if(strikeout)$
\usepackage[normalem]{ulem}
% avoid problems with \sout in headers with hyperref:
\pdfstringdefDisableCommands{\renewcommand{\sout}{}}
$endif$
\setlength{\parindent}{0pt}
\setlength{\parskip}{6pt plus 2pt minus 1pt}
\setlength{\emergencystretch}{3em} % prevent overfull lines
\providecommand{\tightlist}{%
\setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}}
$if(numbersections)$
\setcounter{secnumdepth}{$if(secnumdepth)$$secnumdepth$$else$5$endif$}
$else$
\setcounter{secnumdepth}{0}
$endif$
$if(dir)$
\ifxetex
% load bidi as late as possible as it modifies e.g. graphicx
$if(latex-dir-rtl)$
\usepackage[RTLdocument]{bidi}
$else$
\usepackage{bidi}
$endif$
\fi
\ifnum 0\ifxetex 1\fi\ifluatex 1\fi=0 % if pdftex
\TeXXeTstate=1
\newcommand{\RL}[1]{\beginR #1\endR}
\newcommand{\LR}[1]{\beginL #1\endL}
\newenvironment{RTL}{\beginR}{\endR}
\newenvironment{LTR}{\beginL}{\endL}
\fi
$endif$
$for(header-includes)$
$header-includes$
$endfor$
%% Monash overrides
$if(toc)$
\AtBeginSection[]{
\frame<beamer>{
\frametitle{Outline}
\tableofcontents[currentsection,hideallsubsections]
}}
$endif$
% Redefine shaded environment if it exists (to ensure text is black)
\ifcsname Shaded\endcsname
\definecolor{shadecolor}{RGB}{225,225,225}
\renewenvironment{Shaded}{\color{black}\begin{snugshade}\color{black}}{\end{snugshade}}
\fi
%%
$if(title)$
\title[$shorttitle$]{$title$}
$endif$
$if(subtitle)$
\subtitle{$subtitle$}
$endif$
$if(author)$
\author[
$if(short-author)$
$for(short-author)$$short-author$$sep$ \and $endfor$
$else$
$for(author)$$author$$sep$ \and $endfor$
$endif$
]{$for(author)$$author$$sep$ \and $endfor$}
$endif$
$if(institute)$
\institute[
$if(short-institute)$
$for(short-institute)$$short-institute$$sep$ \and $endfor$
$endif$
]{
$if(department)$
$for(department)$$department$$sep$ \and $endfor$ \\
$endif$
$for(institute)$$institute$$sep$ \and $endfor$
$if(email)$
\\ $for(email)$ \href{mailto:$email$}{\nolinkurl{$email$}}$sep$ \and $endfor$
$endif$
}
$endif$
\date[
$if(short-date)$
$short-date$
$else$
$date$
$endif$]{
$if(date)$
$date$
$if(license)$
\\ \vspace{5mm}
$endif$
$endif$
$if(license)$
{\scriptsize $license$}
$endif$
}
\begin{document}
% Hide progress bar and footline on titlepage
$if(title)$
\begin{frame}[plain]
\titlepage
\end{frame}
$endif$
$for(include-before)$
$include-before$
$endfor$
$if(toc)$
\frame<beamer>{
\frametitle{Outline}
\tableofcontents[hideallsubsections]
}
$endif$
$body$
$if(natbib)$
$if(bibliography)$
$if(biblio-title)$
$if(book-class)$
\renewcommand\bibname{$biblio-title$}
$else$
\renewcommand\refname{$biblio-title$}
$endif$
$endif$
\begin{frame}[allowframebreaks]{$biblio-title$}
\bibliographytrue
\bibliography{$for(bibliography)$$bibliography$$sep$,$endfor$}
\end{frame}
$endif$
$endif$
$if(biblatex)$
\begin{frame}[allowframebreaks]{$biblio-title$}
\bibliographytrue
\printbibliography[heading=none]
\end{frame}
$endif$
$for(include-after)$
$include-after$
$endfor$
\end{document}

View File

@ -0,0 +1,28 @@
%% Beamer Color Theme: Monash Blue
%% Created by Rob J Hyndman. 28 March 2017
\definecolor{MonashBlue}{RGB}{0, 99, 167}
\definecolor{Orange}{RGB}{204, 89, 0}
\definecolor{DarkYellow}{RGB}{230, 172, 0}
\definecolor{grey}{RGB}{191,191,191}
\definecolor{DarkGrey}{RGB}{100,100,100}
\definecolor{LightGrey}{RGB}{231,231,231}
\setbeamercolor{normal text}{fg=black!2,bg=MonashBlue}
\usebeamercolor[fg]{normal text}
\setbeamercolor{progress bar}{fg=Orange}
\setbeamercolor{frametitle}{fg=MonashBlue,bg=black!2}
\setbeamercolor{enumerate item}{fg=Orange,bg=LightGrey}
\setbeamercolor{enumerate subitem}{fg=Orange!50!yellow,bg=white}
\setbeamercolor{itemize item}{fg=Orange}
\setbeamercolor{itemize subitem}{fg=Orange!50!yellow}
\setbeamercolor{description item}{fg=DarkYellow}
\setbeamercolor{title}{fg=white,bg=MonashBlue}
\setbeamercolor{section}{fg=MonashBlue}
\setbeamercolor{subsection}{fg=MonashBlue}
\setbeamercolor{itemize}{fg=black}
\setbeamercolor{alerted text}{fg=DarkYellow}
\setbeamercolor{block body alerted}{fg=black,bg=DarkYellow}
\setbeamercolor{block body}{fg=black,bg=black!25!white}
\setbeamercolor{structure}{fg=white}
\setbeamercolor{block title}{fg=white,bg=Orange}
\setbeamercolor{block title alerted}{fg=white,bg=black}

View File

@ -0,0 +1,10 @@
%% Font theme for use with Monash beamer theme
%% Created by Rob J Hyndman. 8 October 2018
\usepackage[lf,t]{carlito}
%\usepackage{bera}
% Lets make descriptions and alerts bold
\setbeamerfont{description item}{series=\bfseries}
\setbeamerfont{alerted text}{series=\bfseries}

View File

@ -0,0 +1,84 @@
%% This is the Monash beamer theme
%% Created for Monash Business School
%% Updated by Rob J Hyndman. 8 October 2018
\RequirePackage{beamerthememetropolis}
\usecolortheme{monash}
\usefonttheme{monash}
\metroset{progressbar=foot}
% Plenty of room
\setbeamersize{text margin left=2em,text margin right=2em}
% Rounded corners on boxes
\useinnertheme{rounded}
% Square bullets and enumerated items
\setbeamertemplate{items}[square]
% larger squares for enumeration
\defbeamertemplate{enumerate item}{mysquare}
{ \raisebox{-0.ex}{\hbox{%
\usebeamerfont*{item projected}%
\usebeamercolor{enumerate item}%
\vrule width4ex height2.7ex depth.7ex%
\hskip-4ex%
\hbox to4ex{%
\hfil%
\color{LightGrey}\raisebox{.2ex}{\insertenumlabel}%
\hfil}%
}}%
}
[action]
{\setbeamerfont{item projected}{size=\scriptsize}}
\setbeamertemplate{enumerate item}[mysquare]
\setbeamertemplate{itemize item}[square]
\setbeamertemplate{items}[mysquare]
\usesubitemizeitemtemplate{%
\tiny\raise1.5pt\hbox{\color{beamerstructure}$\blacktriangleright$}%
}
\usesubsubitemizeitemtemplate{%
\tiny\raise1.5pt\hbox{\color{beamerstructure}$\bigstar$}%
}
\setbeamertemplate{section in toc}[square]
\setbeamerfont{section number projected}{size=\large}
\setbeamercolor{section number projected}{bg=Orange,fg=white}
\setbeamercolor{section in toc shaded}{fg=white}
\setbeamercolor{section in toc}{fg=DarkYellow}
\setbeamertemplate{section in toc shaded}[default][50]
% Figure placement
\RequirePackage[absolute,overlay]{textpos}
\setlength{\TPHorizModule}{1cm}
\setlength{\TPVertModule}{1cm}
\def\placefig#1#2#3#4{\begin{textblock}{.1}(#1,#2)\rlap{\includegraphics[#3]{#4}}\end{textblock}}
% Monash title page
\setbeamertemplate{title page}
{\placefig{-0.01}{-0.01}{width=1.01\paperwidth,height=1.01\paperheight}{MonashTitleSlide}
\begin{textblock}{7.5}(1,2.8)\usebeamerfont{title}
{\color{white}\raggedright\par\inserttitle}
\end{textblock}
\begin{textblock}{7.5}(1,7)
{\color{white}\raggedright{\insertauthor}\\[0.2cm]
\insertdate}
\end{textblock}}
% Reduce vertical space around displayed equations
\preto\frame{%
\setlength{\abovedisplayskip}{1pt}%
\setlength{\belowdisplayskip}{4pt}%
\setlength{\abovedisplayshortskip}{0pt}%
\setlength{\belowdisplayshortskip}{0pt}}
% Redefine shaded environment if it exists (for R plots)
\ifcsname Shaded\endcsname
\definecolor{shadecolor}{RGB}{225,225,225}
\renewenvironment{Shaded}{\color{black}\begin{snugshade}\color{black}}{\end{snugshade}}
\fi
%%
%% End of file `beamerthememonash.sty'.

View File

@ -0,0 +1,113 @@
---
title: Monash Beamer Class Demonstration
author: Rob J Hyndman
date: \today
fontsize: 14pt
titlefontsize: 22pt
classoption: compress
toc: true
output: binb::monash
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE, message=FALSE, warning=FALSE, cache=TRUE, dev.args=list(bg=grey(0.9), pointsize=11))
```
# Intro
## Slide with bullets
- Bullet 1
- Bullet 2
- Bullet 3
Use `\alert` to \alert{highlight} some text
### Some enumeration
1. The first item
1. Stuff
1. Nonsense
# Using R
## Slide with R output
```{r cars, echo = TRUE}
summary(cars)
```
## Slide with graphics
```{r pressure}
plot(pressure)
```
## Slide with mathematics
Quantile score for observation $y$. For $0<p<1$:
\begin{block}{}
\[
S(y_t,q_t(p)) = \left\{
\begin{array}{rl}
p(y_t-q_t(p)) & \text{if $y_t \ge q_t(p)$}\\
(1-p)(q_t(p)-y_t) & \text{if $y_t < q_t(p)$}
\end{array}\right.
\]
\end{block}
Average score over all percentiles gives the best distribution forecast:
\[
QS = \frac{1}{99T}\sum_{p=1}^{99}\sum_{t=1}^T S(q_t(p),y_t)
\]
# RMarkdown Examples
## R Figure
The following code generates the plot on the next slide (taken from
`help(bxp)` and modified slightly):
\small
```{r pressureCode, eval=FALSE, echo=TRUE}
library(stats)
set.seed(753)
bx.p <- boxplot(split(rt(100, 4),
gl(5, 20)), plot=FALSE)
bxp(bx.p, notch = FALSE, boxfill = "orange",
frame = FALSE, outl = TRUE,
main = "Example from help(bxp)")
```
## R Figure
```{r pressureFig, echo=FALSE}
library(stats)
set.seed(753)
bx.p <- boxplot(split(rt(100, 4),
gl(5, 20)), plot=FALSE)
bxp(bx.p, notch = FALSE, boxfill = "orange",
frame = FALSE, outl = TRUE,
main = "Example from help(bxp)")
```
## R Table
A simple `knitr::kable` example:
\small
```{r kableEx, echo=TRUE}
knitr::kable(mtcars[1:4, 1:7],
caption="(Parts of) the mtcars dataset")
```
## Resources
### For more information:
- See the [RMarkdown repository](https://github.com/rstudio/rmarkdown) for more on RMarkdown
- See the [binb repository](https://github.com/eddelbuettel/binb) for more on binb
- See the [binb vignettes](https://github.com/eddelbuettel/binb/vignettes) for more examples.

Binary file not shown.

After

Width:  |  Height:  |  Size: 116 KiB

View File

@ -0,0 +1,3 @@
name: Binb is not Beamer - Monash (pdf)
description: A custom R Markdown Beamer presentation theme.
create_dir: true

View File

@ -3,6 +3,7 @@
\name{metropolis}
\alias{metropolis}
\alias{iqss}
\alias{monash}
\alias{presento}
\title{Binb is not Beamer - PDF Presentation Themes}
\usage{
@ -22,6 +23,14 @@ iqss(toc = FALSE, slide_level = 3, incremental = FALSE,
"biblatex"), includes = NULL, md_extensions = NULL,
pandoc_args = NULL)
monash(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", highlight = "tango", keep_tex = FALSE,
latex_engine = "pdflatex", citation_package = c("none", "natbib",
"biblatex"), includes = NULL, md_extensions = NULL,
pandoc_args = NULL)
presento(toc = FALSE, slide_level = 2, incremental = FALSE,
fig_width = 10, fig_height = 7, fig_crop = TRUE,
fig_caption = TRUE, dev = "pdf", df_print = "default",
@ -34,7 +43,7 @@ presento(toc = FALSE, slide_level = 2, incremental = FALSE,
\item{toc}{A logical variable defaulting to \code{FALSE}.}
\item{slide_level}{A numeric variable defaulting to two for
\sQuote{Metrpolis} and three for \sQuote{IQSS}.}
\sQuote{Metropolis} and \sQuote{Monash}, and three for \sQuote{IQSS}.}
\item{incremental}{A logical variable defaulting to \code{FALSE}.}
@ -75,7 +84,8 @@ for it side effect of creating the pdf file.
\description{
Templates for RMarkdown-based Beamer PDF presentations supporting
the \sQuote{Metropolis} style by Matthias Vogelgesang and others,
and the \sQuote{IQSS} style by Ista Zahn and Gary King.
the \sQuote{IQSS} style by Ista Zahn and Gary King,
and the \sQuote{Monash} style by Rob J Hyndman.
}
\details{
Note that not all options and customizations available at the LaTeX