## 1. Create a Simple block in Beamer

It can be useful to treat some content differently by putting it into a block. In Beamer, we can separate a specific section of text or graphics from the rest of the frame using “block” environment:

% Block environment
\documentclass{beamer}

% Theme choice

\begin{document}

\begin{block}{Block title}
It can be useful to treat some content differently by putting it into a block. This can be done by using blocks!
\end{block}

\end{frame}

\end{document}

We used Madrid theme for our presentation and inside a frame we added a block environment with title “Block title“. Here is the obtained result:

It should be noted that the block style depends on the used theme and theme color. Let us consider the same code as above and we change only the them to Bergen. The obtained result is shown below:

## 2. Main styles of blocks in Beamer

There are three basic types of blocks : Standard/Generic block, Alert block, and Example block. There are also special blocks for math environments like Theorem, Definition, Proof, Corollary, Example, etc.

The following table illustrates different blocks with sample code syntax in beamer:

Here is an example code using different types of blocks in a Beamer presentation:

% Different styles of blocks
\documentclass{beamer}

% Theme choice
\usetheme{Copenhagen}

\begin{document}

% Frame 1
\begin{frame}{Basic Blocks}
\begin{block}{Standard Block}
This is a standard block.
\end{block}

\begin{exampleblock}{An example of typesetting tool}
Example: MS Word, \LaTeX{}
\end{exampleblock}
\end{frame}

% Frame 2
\begin{frame}{Mathematical Environment Blocks}
\begin{definition}
This is a definition.
\end{definition}

\begin{theorem}
This is a theorem.
\end{theorem}

\begin{lemma}
This is a proof idea.
\end{lemma}
\end{frame}

% Frame 3
\begin{frame}{Mathematical Environment Blocks-Continued}
\begin{proof}
This is a proof.
\end{proof}

\begin{corollary}
This is a corollary
\end{corollary}

\begin{example}
This is an example
\end{example}
\end{frame}

\end{document}


Compiling this code yields the following:

Using Boadilla theme instead of Copenhagen, we get the following style for different beamer blocks:

## 3. German block environment

Here is an illustrative example:

% German block environment
\documentclass{beamer}

% Theme choice
\usetheme{AnnArbor}

\begin{document}

\begin{frame}[fragile]{Basic Blocks}
\begin{Problem}
This block can be used for problems description.
\end{Problem}

\begin{Loesung}
This block can be used for presenting a solution.
\end{Loesung}

\begin{Definition}
This block is equivalent to \verb|Definition| block
\end{Definition}
\end{frame}

\begin{frame}[fragile]{Mathematical Environment Blocks}
\begin{Satz}
This is equivalent to \verb|theorem| block
\end{Satz}

\begin{Beweis}
This is equivalent to \verb|proof| block
\end{Beweis}

\begin{Folgerung}
This is equivalent to \verb|lemma| block
\end{Folgerung}
\end{frame}

\begin{frame}[fragile]{Mathematical Environment Blocks-Continued}
\begin{Lemma}
This is equivalent to \verb|lemma| block
\end{Lemma}

\begin{Fakt}
This is equivalent to \verb|fact| block
\end{Fakt}

\begin{Beispiel}
This is equivalent to \verb|Example| block
\end{Beispiel}

\begin{Beispiele}
This is equivalent to \verb|Examples| block
\end{Beispiele}
\end{frame}

\end{document}


This code yields the following:

In this example, we used AnnArbor theme and you may remarked the frame option [fragile] which allows us to use verbatim style inside a frame.

## 4. Customization and Basic blocks

We can modify blocks’ shapes by playing with the command: \setbeamertemplate{blocks}[Options]. Here are available pre-defined options for this command:

• [default]: This default value typesets the block title on its line.
• [rounded]: makes the blocks’ corners rounded.
• [shadow=true]: If the shadow is set as true, a shadow is portrayed behind the block.

Here is an illustrative example:

% Customize blocks
\documentclass{beamer}

% Default style
%\setbeamertemplate{blocks}[default]

\begin{document}

\begin{frame}{Basic Blocks Example}

\begin{block}{Standard Block}
This is an standard block with shadow
\end{block}

\begin{exampleblock}{An example of typesetting tool}
Example: MS Word, Latex
\end{exampleblock}

\end{frame}

\end{document}


Here is the output:

## 5. Change colors of blocks

From above, we know that blocks’ style depends on the used theme and In this part, we will learn how to change the blocks colors without changing the theme.

In the next example, we changed colors of standard block, alert block and example block. Check the obtained result:

And here is piece of codes of each block customization:

### -1- Customize standard block colors

% Change standard block colors

% 1- Block title (background and text)
\setbeamercolor{block title}{bg=cyan, fg=white}

% 2- Block body (background)
\setbeamercolor{block body}{bg=cyan!10}

### -2- Customize alert block colors

% Change alert block colors

% 1- Block title (background and text)

% 2- Block body (background)
\setbeamercolor{block body alerted}{bg=orange!25}

### -3- Customize example block colors

% Change example block colors

% 1- Block title (background and text)
\setbeamercolor{block title example}{fg=white, bg=teal}

% 2- Block body (background)
\setbeamercolor{block body example}{bg=teal!25}

The fill code of the above image is:

% Change color of Beamer blocks
\documentclass{beamer}

% Change example block colors

% 1- Block title (background and text)
\setbeamercolor{block title example}{fg=white, bg=teal}

% 2- Block body (background and text)
\setbeamercolor{block body example}{ bg=teal!25}

% 1- Block title (background and text)

% 2- Block body (background and text)

% Change standard block colors

% 1- Block title (background and text)
\setbeamercolor{block title}{bg=cyan, fg=white}

% 2- Block body (background)
\setbeamercolor{block body}{bg=cyan!10}

\begin{document}

\begin{frame}{Basic Blocks Example}

\begin{block}{Standard block}
Observation through sound or listening can tell us about our surrounding environment.
\end{block}

A-weighting mirrors the range of hearing, with frequencies of 20 Hz to 20,000 Hz.

\begin{exampleblock}{Example block}
Recommendations for leisure noise in 2018 were conditional and based on the equivalent sound pressure level during an average 24 hour period in a year without weights for nighttime noise.
\end{exampleblock}

\end{frame}

\end{document}


## Summary

• Beamer provides different blocks to highlight ideas and present results. This includes standard blocks, alert blocks and example blocks.
• For mathematicians, we have blocks for: theorems, corollaries, proofs, lemmas and much more!
• We can change the color of each block which consists of a title and body parts using the command \setbeamercolor.
• We can also change the block style: rounded corners and add shading which is achieved by the command \setbeamertemplate.

Next Lesson: 08 Beamer Themes — Full List