Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I would like to have the ability to add "headings" to content in my beamer slides. By heading I just mean slightly larger text that automatically breaks the row and adds some margins to the surrounding text. Basically something that is exactly like the \section command when writing an article.

I have so far done this using the block environment like

\begin{block}{The heading}
The content goes here.
\end{block}

which worked with my previous theme since the block background was the same as the slide background. But in my new theme I want to have the usual colored boxes, so some other method is required.

I tried implementing a new headingblock environment that is basically a block environment with new colors:

\newenvironment{headingblock}[1]{%
  \setbeamercolor{block body}{bg=white, fg=black}
  \setbeamercolor{block title}{bg=white, fg=liu_blue}
  \begin{block}{#1}}{\end{block}}

The problem is that everything else inside the block is affected by the \setbeamercolor calls which means I can't have another block inside the headingblock. Also it feels kind of hackish.

What is the best way to implement this?

Edit To be extra clear, I am not looking for a frame title, but subheadings within the frame. Something like:

\begin{frame}
  \frametitle{The slide}

  \myheading{The first heading}
  Some text and stuff that goes with the first heading

  \myheading{Second heading}
  More stuff goes here.
\end{frame}
share|improve this question
    
Welcome to TeX.sx! –  hpesoj626 Mar 12 '13 at 8:50
    
Ok, I thought the \framesubtitle{...} command would solve this. But there can only be one subtitle to every frame... –  Dave Mar 12 '13 at 9:40

1 Answer 1

up vote 6 down vote accepted

You can define your own block structure in a similar way in which beamer defines exampleblock or alertblock, and set the block title and block body colors for this new block as desired. The original definitions can be found in the file beamerbaselocalstructure.sty. Here's a definition of such a block that you can adjust according to your needs:

\documentclass{beamer}

\newenvironment<>{headingblock}[1]{%
    \begin{actionenv}#2%
      \def\insertblocktitle{#1}%
      \par%
      \mode<presentation>{%
        \setbeamercolor{heading}{fg=black,bg=yellow}
      }%
     \setbeamercolor{block title}{fg=orange,bg=structure}
     %\setbeamercolor{block body}{fg=green,bg=orange} % to customize the colors of the block body
      \usebeamertemplate{block begin}}
    {\par%
      \usebeamertemplate{block end}%
    \end{actionenv}}

\begin{document}

\begin{frame}
\begin{headingblock}{A test heading}
Some test text.
\end{headingblock}
\end{frame}

\end{document}

enter image description here

If you are not interested in a block and want something simpler, you can do something along the following lines (again, adjust the settings according to your needs):

\documentclass{beamer}

\newcommand\myheading[1]{%
  \par\bigskip
  {\Large\bfseries#1}\par\smallskip}

\begin{document}

\begin{frame}
Some test text.
\myheading{A test heading}
Some test text.
\end{frame}

\end{document}

enter image description here

share|improve this answer
    
I finally settled on using something similar to your final example. Thanks! –  kigurai Mar 14 '13 at 9:37

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.