Skip to content

Instantly share code, notes, and snippets.

@bmmalone
Last active November 19, 2017 19:59
Show Gist options
  • Save bmmalone/ea7a61e99c4c18ae43f7953eb0a386ae to your computer and use it in GitHub Desktop.
Save bmmalone/ea7a61e99c4c18ae43f7953eb0a386ae to your computer and use it in GitHub Desktop.
Latex beamer templates
%%%
% Add spaces when necessary after commands
%%%
\usepackage{xspace}
%%%
% Make sure we can use colors
%%%
\usepackage{xcolor}
%%%
% Make writing commands with optional parameters a little easier
%%%
\usepackage{xparse}
%%%
% Generally useful stuff
%%%
\newcommand\todo[1]{\textcolor{red}{[TODO: #1]}}
\newcommand\unsure[1]{\textcolor{blue}{[UNSURE: #1]}}
\newcommand\update[1]{\textcolor{green}{[UPDATE: #1]}}
\newcommand{\etal}{\textit{et al.}\xspace}
\newcommand{\apriori}{\textit{a priori}\xspace}
\newcommand{\adhoc}{\textit{ad hoc}\xspace}
%%%
% tables and such
%%%
\usepackage{multicol}
\usepackage{framed}
\renewcommand{\(}{\begin{columns}}
\renewcommand{\)}{\end{columns}}
\newcommand{\<}[1]{\begin{column}{#1}}
\renewcommand{\>}{\end{column}}
%%%
% math
%%%
\usepackage{algorithm}
\usepackage{algorithmicx}
\usepackage[noend]{algpseudocode}
\usepackage{amsmath,amssymb,bm}
\usepackage{mathtools}
\usepackage{pifont}% http://ctan.org/pkg/pifont
\newcommand{\cmark}{\ding{51}}%
\newcommand{\xmark}{\ding{55}}%
% standard, simple math notation
\DeclareMathOperator*{\argmax}{arg\,max}
\DeclareMathOperator*{\argmin}{arg\,min}
\DeclareMathSymbol{\naf}{\mathord}{symbols}{"18}
\newcommand\var[1]{\ensuremath{\mathbb{V}[#1]}}
\newcommand\mean[1]{\ensuremath{\mathbb{E}[#1]}}
\newcommand{\IF}{\leftarrow}
\newcommand{\BigO}[1]{\ensuremath{\operatorname{O}\left(#1\right)}\xspace}
%%%
% "defined to be" with "colon equals"
%
% $y \defeq f(x)$
%%%
\newcommand*{\defeq}{%
\mathrel{\vcenter{%
\baselineskip0.5ex \lineskiplimit0pt%
\hbox{\scriptsize.}\hbox{\scriptsize.}%
}}%
=%
}
%%%
% KL-divergence
%
% \kld{p}{q}
%%%
\DeclarePairedDelimiterX{\infdivx}[2]{(}{)}{%
#1\;\delimsize|\delimsize|\;#2%
}
\newcommand{\kld}[2]{\ensuremath{D_{KL}\infdivx{#1}{#2}}\xspace}
%%%
% Expectation of X (optionally, with respect to y)
%
% \expectation{X}
%
% or
%
% \expectation[y]{X}
%%%
\DeclareDocumentCommand \expectation { o m } {%
\ensuremath{\mathbb{E}%
\IfValueTF {#1} {%
_{#1} \left[ #2 \right]%
}{%
\left[ #2 \right]%
}%
}\xspace%
}
%%%
% independence: https://tex.stackexchange.com/questions/79434
%%%
\newcommand\independent{\protect\mathpalette{\protect\independenT}{\perp}}
\def\independenT#1#2{\mathrel{\rlap{$#1#2$}\mkern2mu{#1#2}}}
\makeatletter
\newcommand*{\indep}{%
\mathbin{%
\mathpalette{\@indep}{}%
}%
}
\newcommand*{\nindep}{%
\mathbin{% % The final symbol is a binary math operator
%\mathpalette{\@indep}{\not}% \mathpalette helps for the adaptation
\mathpalette{\@indep}{/}%
% of the symbol to the different math styles.
}%
}
\newcommand*{\@indep}[2]{%
% #1: math style
% #2: empty or \not
\sbox0{$#1\perp\m@th$}% box 0 contains \perp symbol
\sbox2{$#1=$}% box 2 for the height of =
\sbox4{$#1\vcenter{}$}% box 4 for the height of the math axis
\rlap{\copy0}% first \perp
\dimen@=\dimexpr\ht2-\ht4-.2pt\relax
% The equals symbol is centered around the math axis.
% The following equations are used to calculate the
% right shift of the second \perp:
% [1] ht(equals) - ht(math_axis) = line_width + 0.5 gap
% [2] right_shift(second_perp) = line_width + gap
% The line width is approximated by the default line width of 0.4pt
\kern\dimen@
\ifx\\#2\\%
\else
\hbox to \wd2{\hss$#1#2\m@th$\hss}%
\kern-\wd2 %
\fi
\kern\dimen@
\copy0 % second \perp
}
\makeatother
% mono (\|), bold (\!) and fancy (\*) letters
\def\|#1{\ensuremath{\mathtt{#1}}}
\def\!#1{\ensuremath{\mathbf{#1}}}
\def\*#1{\ensuremath{\mathcal{#1}}}
%%%
% Other common shortcuts
%%%
%\newcommand{\etal}{\textit{et al.}\xspace}
\newcommand{\eg}{e.g.\xspace}
\newcommand{\pvalue}{\ensuremath{p\text{-value}}\xspace}
\newcommand{\kldivergence}{KL-divergence\xspace}
\newcommand{\iid}{i.i.d.\xspace}
%%%
% Missind data mechanisms
%%%
\newcommand{\mcar}{MCAR\xspace}
\newcommand{\mar}{MAR\xspace}
\newcommand{\nmar}{NMAR\xspace}
%%%
% Standard model notation
%%%
\newcommand{\glm}{\textsc{glm}\xspace}
\newcommand{\nb}{\textsc{NB}\xspace}
\documentclass[xcolor=x11names,compress,10pt]{beamer}
%% General document %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{graphicx}
\usepackage{xcolor}
% "easily" place text on top of images
\usepackage{tikz}
% for the copyright symbol
\usepackage{textcomp}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Beamer Layout %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\definecolor{mpigreen}{HTML}{75AE6D}
\definecolor{mpigreenlight}{HTML}{9EC699}
\definecolor{mpitext}{HTML}{00876D}
\definecolor{heidelbergblue}{HTML}{3D4370}
\definecolor{heidelberglightblue}{HTML}{464C72}
\definecolor{heidelbergtext}{HTML}{3C4066}
\definecolor{necblue}{HTML}{002b62}
\definecolor{neclightblue}{HTML}{1414a0}
\definecolor{nectext}{HTML}{002b62}
\definecolor{necturquoise}{HTML}{457995}
\useoutertheme[subsection=false,shadow]{miniframes}
\useinnertheme{default}
\usefonttheme{professionalfonts}
\usepackage{palatino}
\setbeamerfont{title like}{shape=\scshape}
\setbeamerfont{frametitle}{shape=\scshape}
%\setbeamercolor*{lower separation line head}{bg=DeepSkyBlue4}
\setbeamercolor{footlinecolor}{fg=white,bg=neclightblue}
\setbeamercolor*{lower separation line head}{bg=necturquoise}
\setbeamertemplate{itemize item}{\color{necblue}$\blacksquare$}
\setbeamercolor*{frametitle}{fg=nectext}
\setbeamercolor*{normal text}{fg=black,bg=white}
\setbeamercolor*{alerted text}{fg=red}
\setbeamercolor*{example text}{fg=black}
\setbeamercolor*{structure}{fg=black}
\setbeamercolor*{palette tertiary}{fg=white,bg=necblue}
\setbeamercolor*{palette quaternary}{fg=black,bg=black!10}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newcommand{\footertitletext}{Footer title\xspace}
\newcommand{\titletext}{Title Line 1\\Title Line 2\xspace}
\newcommand{\footerauthors}{Footer authors}
\newcommand{\titleauthors}{Title Authors Line 1\\Title Authors Line 2}
\newcommand{\titlebackgroundimage}{title-background.jpg}
\newcommand{\footerimage}{footer.jpg}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\setbeamertemplate{sidebar right}{}
%%%
% The footer we will use for everything except the first slide
%%%
\setbeamertemplate{footline}{
\begin{minipage}[b][1.8cm][b]{\textwidth}
\begin{tikzpicture}
\node[anchor=south west,inner sep=0] (image) at (0,0) {
\includegraphics[width=1\paperwidth]{\footerimage}
};
\node[anchor=south west,white,font={}] at (0.5,0) {
\footertitletext \xspace \footerauthors
};
\node[anchor=south west,white,font={}] at (5,0) {
Some white text in the middle
};
\node[anchor=south east,white,font={}] at (12.85,0) {
\insertframenumber
};
\end{tikzpicture}
\end{minipage}
}
%%%
% Custom commands for this presentations
%%%
\input{latex-beamer-includes}
\begin{document}
%%%
% Just use the background image for the entire slide
%%%
\usebackgroundtemplate{
\includegraphics[width=\paperwidth,height=\paperheight]{\titlebackgroundimage}
}
\begin{frame}[noframenumbering,plain]
%%%
% Our collaborators work places, too :)
%%%
%\includegraphics[height=1.2cm]{logo-1.png}
%\hspace{5.2cm}
%%\includegraphics[height=1.2cm]{logo-2.png}
%\hfill
%\includegraphics[height=1.2cm]{log-3.png}
%\hphantom{0.2cm}
\begin{minipage}{0.9\textwidth}
%%%
% this spacing works for two line; it probably needs to be adjusted
% for more or less
%%%
\vspace{2.25cm}
\textcolor{nectext}{
{\Large {\titletext}}}
\vspace{0.1cm}
{\footnotesize \textcolor{white}{ \titleauthors}
}
\end{minipage}
\end{frame}
%%%
% use the navigation bar at the top, frame titles, and footline
%%%
\usebackgroundtemplate{}
\section{Intro}
\subsection{First slide}
\frame{\frametitle{First slide}
A computer scientist's perspective...
\kld{p}{q} is important
\vspace{15px}
\begin{center}
Hey!
\end{center}
}
\section{Outlook}
\subsection{Last slide}
\frame{\frametitle{Last slide}
A computer scientist's perspective...
\vspace{15px}
\begin{center}
Hey!
\end{center}
}
\end{document}
@bmmalone
Copy link
Author

bmmalone commented May 19, 2017

See here for a discussion about why \input is used for the "includes".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment