Beamer

From XennisWiki
Jump to: navigation, search

Beamer is a LaTeX document class for creating slides for presentations. It supports both pdfLaTeX and LaTeX + dvips. The name is taken from the German word Beamer, a pseudo-anglicism for video projector. (Wikipedia)

Basics

Uncover text and items

Uncover text

Here you can see: \uncover<2->{The World!}

Uncover item in the itemize environment

\begin{frame}{Title}
  \begin{itemize}
    \item<1-> Show this item on both slides
    \item<2-> Show this item on the second on following slides
    \item<2-2> Show this item on the second slide only
  \end{itemize}
\end{frame}

Break a frame

Just use the allowframebreaks option, to allow Beamer to break slides automatically. If you wanna force a break use \framebreak.

\begin{frame}[allowframebreaks]
  \begin{itemize}
    \item<1-> Show this item on both slides
    \item<2-> Show this item on the second on following slides
    \item<2-2> Show this item on the second slide only
  \end{itemize}
\end{frame}

Usage of lstlisting

To use the listings environment you have to add the fragile option

\begin{frame}[fragile]{Title}
  \begin{lstlisting}[language=JavaScript]
     % ...		
  \end{itemize}
\end{frame}

Create a plain frame

Use the plain option

\begin{frame}[plain]{}
  % ...
\end{frame}

If necessary you can use the plain option in combination with the shrink

\begin{frame}[plain,shrink]{Slide title}
  % ...
\end{frame}

Display a footnote

Use the frame option on a \footnote to display it on the bottom of the slide

\begin{frame}
  Example text\footnote[frame]{Just a the frame option.}
\end{frame}

Show table of contents at the begin of sections

Before the documents begins, add the following code

\AtBeginSection[] % Do nothing for \section*
{
  \begin{frame}
    \tableofcontents[currentsection]
  \end{frame}
}

TikZ and Beamer

Use the uncover command on a graph

\begin{frame}{Sender-to-receiver and receiver-to-receiver synchronization}
  \begin{tikzpicture}[->,>=stealth',shorten >=1pt,auto,node distance=2.2cm, thick, node/.style={circle,draw}]
    \node[node]	(A) {A};
    \node[node]	(1) [below left of=A] {1};
    \node[node]	(2) [below right of=A] {2};
	
    \uncover<2->{\path
      (A) edge node [below right] {$C_A(t)$} (1)
      (A) edge node [below left] {} (2)
    ;}
    \uncover<3->{\path
      (1) edge [bend left] node [above] {M} (A)
      (2) edge [bend right] node [above] {M} (A)
     ;}
  \end{tikzpicture}
\end{frame}

Advanced

Animated TikZ mindmap

Use the following tikzset configuration

\usepackage{tikz}
\usetikzlibrary{mindmap,trees}

\tikzset{
  invisible/.style={opacity=0},
  visible on/.style={alt={#1{}{invisible}}},
  alt/.code args={<#1>#2#3}{%
    \alt<#1>{\pgfkeysalso{#2}}{\pgfkeysalso{#3}} % \pgfkeysalso doesn't change the path
  },
}

Usage inside of a frame (e.g. append visible on=<2-> on a node)

\begin{frame}[plain]{}
  \begin{tikzpicture}
    \path[mindmap,concept color=black,text=white]
      node[concept] {main node}
      [clockwise from=0]   
      child[concept color=green!50!black] {
        node[concept] {first node}
        [clockwise from=90]
        child { node[concept] {1. slide} }
        child { node[concept, visible on=<2->] {2. slide} }
      }  
      child[concept color=blue, visible on=<2->] {
        node[concept] {second node}
      }
    ;
  \end{tikzpicture}
\end{frame}

Custom theme

Example: Lambda Theme

beamerthemeLambda.sty

\ProvidesPackage{beamerthemeLambda}

\mode<presentation>

% Basics
\usecolortheme{LambdaDark}
\setbeamercovered{dynamic}
\beamertemplatenavigationsymbolsempty

% Font
\usepackage{palatino}
\usefonttheme[onlymath]{serif} % Serif font in math mode
\setbeamerfont{frametitle}{size={\fontsize{10}{0}}} % Smaller frametitle
\let\Tiny=\tiny % Fix beamer font

% Line spacing
\usepackage{setspace}
\setstretch{1.5}
\setlength{\parindent}{0pt}


% Headline
\defbeamertemplate*{headline}{}{
  \leavevmode
  \begin{beamercolorbox}[ht=7em,wd=\paperwidth,sep=1em,rightskip=1.5em,leftskip=0.5em]{}
    \includegraphics[height=5em]{style/logo}
  \end{beamercolorbox}
}

% Footline
\defbeamertemplate*{footline}{}{
  \leavevmode
  % Author, title and current frame number
  \begin{beamercolorbox}[ht=1em,dp=1ex]{maininverse}
    \begin{beamercolorbox}[wd=.30\paperwidth,ht=1em,left]{}
      \hspace*{2ex}\insertshortauthor
    \end{beamercolorbox}
    \begin{beamercolorbox}[wd=.39\paperwidth,ht=1em,center]{}
      \inserttitle
    \end{beamercolorbox}
    \begin{beamercolorbox}[wd=.30\paperwidth,ht=1em,right,rightskip=0.5em]{}
       \insertframenumber{}
    \end{beamercolorbox}
  \end{beamercolorbox}
  \vskip0pt
}

% Frametitle
\setbeamertemplate{frametitle}{
  \begin{beamercolorbox}[wd=\paperwidth,ht=1em,dp=0.55ex]{maininverse}
    \hspace*{2ex}
      \insertframetitle
     \hspace*{2ex}
  \end{beamercolorbox}%
}

beamerthemeLambda.sty

\ProvidesPackage{beamerthemeLambda}

\mode<presentation>

% Basics
\usecolortheme{LambdaDark}
\setbeamercovered{dynamic}
\beamertemplatenavigationsymbolsempty

% Font
\usepackage{palatino}
\usefonttheme[onlymath]{serif} % Serif font in math mode
\setbeamerfont{frametitle}{size={\fontsize{10}{0}}} % Smaller frametitle
\let\Tiny=\tiny % Fix beamer font

% Line spacing
\usepackage{setspace}
\setstretch{1.5}
\setlength{\parindent}{0pt}


% Headline
\defbeamertemplate*{headline}{}{
  \leavevmode
  \begin{beamercolorbox}[ht=7em,wd=\paperwidth,sep=1em,rightskip=1.5em,leftskip=0.5em]{}
    \includegraphics[height=5em]{style/logo}
  \end{beamercolorbox}
}

% Footline
\defbeamertemplate*{footline}{}{
  \leavevmode
  % Author, title and current frame number
  \begin{beamercolorbox}[ht=1em,dp=1ex]{maininverse}
    \begin{beamercolorbox}[wd=.30\paperwidth,ht=1em,left]{}
      \hspace*{2ex}\insertshortauthor
    \end{beamercolorbox}
    \begin{beamercolorbox}[wd=.39\paperwidth,ht=1em,center]{}
      \inserttitle
    \end{beamercolorbox}
    \begin{beamercolorbox}[wd=.30\paperwidth,ht=1em,right,rightskip=0.5em]{}
       \insertframenumber{}
    \end{beamercolorbox}
  \end{beamercolorbox}
  \vskip0pt
}

% Frametitle
\setbeamertemplate{frametitle}{
  \begin{beamercolorbox}[wd=\paperwidth,ht=1em,dp=0.55ex]{maininverse}
    \hspace*{2ex}
      \insertframetitle
     \hspace*{2ex}
  \end{beamercolorbox}%
}

See also

External links