63

I want to put boxed text/block in Beamer and my LaTeX source is

\documentclass[pdf]{beamer}
\begin{document}
\begin{frame}
\begin{block}{Observation 1}
Simmons Hall is composed of metal and concrete.
\end{block}
\begin{block}{Observation 2}
Simmons Dormitory is composed of brick.
\end{block}
\begin{block}{Conclusion}
Simmons Hall $\not=$ Simmons Dormitory.
\end{block}
\end{frame}
\end{document}

This results in enter image description here whereas what I want is enter image description here

3 Answers 3

65

Your MWE is using the default beamer theme, which doesn't define the blocks to have the colors you want. Try using a different theme, as below. Also, to get blue/green/red use block/exampleblock/alertblock, respectively.

\documentclass[pdf]{beamer}
\usetheme{Copenhagen}
\begin{document}
\begin{frame}
\frametitle{Frame title}
\begin{block}{Observation 1}
Simmons Hall is composed of metal and concrete.
\end{block}
\begin{exampleblock}{Observation 2}
Simmons Dormitory is composed of brick.
\end{exampleblock}
\begin{alertblock}{Conclusion}
Simmons Hall $\not=$ Simmons Dormitory.
\end{alertblock}
\end{frame}
\end{document}

You can also customize how things look by using \useinnertheme{} and \usecolortheme{}. See the beamer documentation for more info.

enter image description here

0
43

This has already been answered but I should like to add that you can still use whichever theme you want with invisible blocks, and then set the colors to make blocks apparent. In the preamble you could include those parameters for instance,

\setbeamercolor{block body alerted}{bg=alerted text.fg!10}
\setbeamercolor{block title alerted}{bg=alerted text.fg!20}
\setbeamercolor{block body}{bg=structure!10}
\setbeamercolor{block title}{bg=structure!20}
\setbeamercolor{block body example}{bg=green!10}
\setbeamercolor{block title example}{bg=green!20}

With these settings you would get green blocks for examples, blocks of the color of the alert text for alert boxes, and the color of the structure for the default boxes, so it follows somehow the theme you're using.

Ah, and you might want to add this line to round the edges of your blocks and cast a shadow. Some templates with invisible block contours might not have included this.

\setbeamertemplate{blocks}[rounded][shadow]
3
  • 3
    This should be the accepted answer. Thanks for sharing!
    – pg2455
    Aug 24, 2021 at 18:06
  • Could you please explain your code? Is "setbeamercolor{block title example}{bg=green!20}" setting the color of the title part of "example block"? Are "alerted text.fg!10" and "structure!10" also colors?
    – Ypbor
    2 days ago
  • Exactly, these colors are already preset in the beamer style you are using, this code uses these preset colors specifically to match any theme. I'd let the beamer experts explain better than me what exactly are alerted text, structure and where they are defined, but for now just know that alerted text.fg is the alerted text font color of your style (.fg stands for foreground, as opposed to .bg for background), and !20 blends it with white (see the xcolor package documentation).
    – Cryme
    yesterday
18

You need to use a theme to have blocks appearing this way. Here is an example with "Boadilla"

\documentclass[10pt,a4paper]{beamer}
\usepackage[utf8]{inputenc}

\usetheme[secheader]{Boadilla}

\begin{document}

\begin{frame}{Title Frame}
    Introduction sentece
    \begin{block}{Title Block 1}
    {
        \begin{itemize}
        \item item 1
        \item item 2
        \end{itemize}
    }
    \end{block}
    \begin{exampleblock}{Title Block 2}
    {
        Text.
    }
    \end{exampleblock}
    \begin{alertblock}{Title Block 3}
    {
        You
    }
    \end{alertblock}    
\end{frame}

\end{document}

giving the result :

Preview of blocks

You need to use block, exampleblock and alertblock.

1
  • Any chance having those in regular (Not Beamser) LaTeX document?
    – Royi
    Aug 5, 2017 at 13:56

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .