61

Is it possible to create a customised beamer block environment that only has a body and not a title?

For example, I wish to typeset the following quote within a coloured block so that it stands out but I have no need for the block's title. I just want the quote to be superimposed on a coloured, rounded, and shadowed box.

\begin{example}
{\large ``To be, or not to be: that is the question.''}
\vskip5mm
\hspace*\fill{\small--- William Shakespeare, Hamlet}
\end{example}

If not, are there suggestions for how to do this in another package, like tikz?

7
  • 1
    Just leave the title empty...
    – Seamus
    Aug 22, 2011 at 12:36
  • 1
    Certainly when I've done this, it's been by leaving the title empty as Seamus says. This might be theme-dependent so if it doesn't work, be sure to say which themes you are using. Aug 22, 2011 at 12:39
  • Leaving the title empty works on an ordinary block but not an example block (which always has the title "Example"). So my next step would be to change the colour of the body section, to something similar to the example block for my theme. In the beamer user guide there are instructions for changing the font colour, is it possible to change the background colour.
    – Steve
    Aug 22, 2011 at 12:49
  • Forgot to add, the problem with using an ordinary block is that the block's body background colour is light grey for the theme I am using (Warsaw) and I would prefer the light green of the example block. Perhaps I should edit the question to make this clearer?
    – Steve
    Aug 22, 2011 at 12:57
  • @Steve: Those comments would have been helpful to have had in the question! They make it easier to see exactly where the problem lies and so easier to find an answer (as Gonzalo has now done for you). Neither Seamus nor I twigged that the example block puts "Example" in its title (had either of us actually compiled some code we would have seen it!). Incidentally, it is possible to change background colours in beamer. The manual has the details, and if that's not clear then ask a fresh question about it. Aug 22, 2011 at 13:20

5 Answers 5

61

You could use an exampleblock environment with empty title:

\documentclass{beamer}
\usetheme{Warsaw}

\begin{document}

\begin{frame}
\begin{exampleblock}{}
  {\large ``To be, or not to be: that is the question.''}
  \vskip5mm
  \hspace*\fill{\small--- William Shakespeare, Hamlet}
\end{exampleblock}
\end{frame}

\end{document}

enter image description here

3
  • Thanks, this specifically answers the question! For a more general solution see that given by percusse below.
    – Steve
    Aug 22, 2011 at 14:24
  • You don't actually need the Warsaw theme for that.
    – einpoklum
    Jun 8, 2016 at 9:22
  • @GonzaloMedina I want block title color without the title.
    – alhelal
    Feb 24, 2018 at 16:16
25

A simple solution, as given in the Beamer manual p.124, might be customizing the following code to your needs.

\setbeamercolor{postit}{fg=black,bg=yellow}
\begin{beamercolorbox}[sep=1em,wd=5cm]{postit}
Place me somewhere!
\end{beamercolorbox}

Also you can make it look like a block without its title.

2
  • 2
    Thanks, this is also great answer as it offers a general solution to the problem of framing text in beamer. I am able to recreate Gonzalo's solution with the following code: \setbeamercolor{postit}{fg=black,bg=example text.fg!75!black!10!bg} \begin{beamercolorbox}[wd=\textwidth,rounded=true,shadow=true]{postit} Quote here. \end{beamercolorbox}
    – Steve
    Aug 22, 2011 at 14:27
  • Well, I just copied it from the manual but you are a quick study, good luck. :)
    – percusse
    Aug 22, 2011 at 19:29
23

Another working quick-fix in cases where \begin{block}{} causes some ugliness at the top of the block, you can use negative vertical space as the block title:

\documentclass{beamer}

\usetheme{Copenhagen}

\setbeamertemplate{blocks}[default]

\begin{document}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{frame}

\begin{block}{abc}
abcabc
\end{block}

\begin{block}{}
defdef
\end{block}

\begin{block}{\vspace*{-3ex}}
ghighi
\end{block}

\end{frame}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\end{document}
3
  • 6
    The accepted solution didn't work for me. This one did.
    – Rufo
    Jun 19, 2017 at 10:47
  • Thanks for this nice little trick!
    – Karlo
    Mar 19, 2019 at 17:42
  • Cool! Following worked for me with IEEEeqnarray environment \begin{block}{}\vspace*{-3ex} \begin{IEEEeqnarray}{rCl} a^2=b^2+c^2 \label{a} \end{IEEEeqnarray} \end{block}
    – kaka
    Jun 4, 2022 at 2:11
10

This is just a remark regarding percusses solution and Steve's usage, but i can't add a comment, because their discussion has been over too long ago. Instead of creating a new beamer color with approximately the same colors as the block body example color, it would be wiser to just use the predefined color if one intents to create a block with the same appearance:

\begin{beamercolorbox}[wd=\textwidth,rounded=true,shadow=true]{block body example}
   Quote here.
\end{beamercolorbox}
0
4

My solution would be to change the block begin template. It's default is defined in beamerinnerthemedefault.sty as

\defbeamertemplate*{block begin}{default}
{
  \par\vskip\medskipamount%
  \begin{beamercolorbox}[colsep*=.75ex]{block title}
    \usebeamerfont*{block title}\insertblocktitle%
  \end{beamercolorbox}%
  {\parskip0pt\par}%
  \ifbeamercolorempty[bg]{block title}
  {}
  {\ifbeamercolorempty[bg]{block body}{}{\nointerlineskip\vskip-0.5pt}}%
  \usebeamerfont{block body}%
  \begin{beamercolorbox}[colsep*=.75ex,vmode]{block body}%
    \ifbeamercolorempty[bg]{block body}{\vskip-.25ex}{\vskip-.75ex}\vbox{}%
}

In your document you can create an additional option for block begin with has no title by deleting the first few lines of the definition:

%create template for block without title
\defbeamertemplate{block begin}{notitle}
{
  \usebeamerfont{block body}%
  \begin{beamercolorbox}[colsep*=.75ex,vmode]{block body}%
    \ifbeamercolorempty[bg]{block body}{\vskip-.25ex}{\vskip-.75ex}\vbox{}%
}

Now you can turn off the title bar with \setbeamertemplate{block begin}[notitle] and turn it back on with \setbeamertemplate{block begin}[default].

Of course this is only true if you use a inner theme which uses \setbeamertemplate{block begin}[default]. If your inner theme uses another option for block begin, you need to make a copy of that and change it accordingly. rounded for example (used by inner theme rounded) is defined in beamerauxtemplates.sty. Also the command to turn titles back on would need to be copied from your theme, in that case from beamerinnerthemerounded.sty.

You must log in to answer this question.

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