2

I'm having an issue with the Blocks from the Beamer Package. The spacing below the title in these blocks is different between the different block types, in my case between exampleblock and alertblock. Here's an image that illustrates what I mean: enter image description here

As you can see, the title in the top example block is closer to the body than the title of the bottom alert block. I would like to have the example block look the same as the alert block. How can I go about this?

Here's a minimal working example of my code:

\documentclass[aspectratio=169,xcolor=dvipsnames]{beamer}
\setbeamertemplate{navigation symbols}{}

\definecolor{blue}{rgb}{0,0.568627,0.862745}
\definecolor{lightblue}{rgb}{0.784313,0.901960,0.980392}
\definecolor{grey}{rgb}{0.713725,0.745098,0.776470}
\definecolor{lightgrey}{rgb}{0.898039,0.909803,0.921568}

\usecolortheme[named=black]{structure}

\setbeamertemplate{blocks}[default]
\setbeamercolor{block title}{bg=blue,fg=white}
\setbeamercolor{block body}{bg=lightgrey}
\setbeamercolor{block title alerted}{bg=white}
\setbeamercolor{block body alerted}{bg=lightblue}
\setbeamercolor{block title example}{fg=blue}
\setbeamercolor{block body example}{bg=lightblue}

\setbeamertemplate{itemize items}[circle]
\setbeamertemplate{itemize item}{\color{blue}$\bullet$}
\setbeamertemplate{itemize subitem}{\color{blue}$\bullet$}


\setbeamertemplate{frametitle}{\vspace*{1.7cm}\textbf{\small\insertframetitle}}

\begin{document}
    \frame {
        \frametitle{Vor-und Nachteile}
        \begin{exampleblock}{Vorteile}
            \begin{itemize}
                \item Vorteil 1
                \item Vorteil 2
            \end{itemize}
        \end{exampleblock}
        \begin{alertblock}{Nachteile}
            \begin{itemize}
                \item Nachteil 1
                \item Nachteil 2
            \end{itemize}
        \end{alertblock}
    }
\end{document}

Compiled with MiKTeX XeTeX on Windows 10

1 Answer 1

2

The difference between your example and alert blocks is that in one case you set the block title background colour to white, in the other case you don't set it. Beamer uses different margins for empty block backgrounds.

You can avoid the problem by either setting the colour for both cases or leave it empty for both, just be consistent.

\documentclass[aspectratio=169,xcolor=dvipsnames]{beamer}

\definecolor{blue}{rgb}{0,0.568627,0.862745}
\definecolor{lightblue}{rgb}{0.784313,0.901960,0.980392}
\definecolor{grey}{rgb}{0.713725,0.745098,0.776470}
\definecolor{lightgrey}{rgb}{0.898039,0.909803,0.921568}


\setbeamercolor{block title}{bg=blue,fg=white}
\setbeamercolor{block body}{bg=lightgrey}
\setbeamercolor{block title alerted}{bg=white}
\setbeamercolor{block body alerted}{bg=lightblue}
\setbeamercolor{block title example}{fg=blue,bg=white}
\setbeamercolor{block body example}{bg=lightblue}



\begin{document}
    \frame {
        \frametitle{Vor-und Nachteile}
        \begin{exampleblock}{Nachteile}
                    \begin{itemize}
                        \item Nachteil 1
                        \item Nachteil 2
                    \end{itemize}
        \end{exampleblock}
        \begin{alertblock}{Nachteile}
            \begin{itemize}
                \item Nachteil 1
                \item Nachteil 2
            \end{itemize}
        \end{alertblock}
    }
\end{document}

enter image description here

2
  • Thank you very much! I didn't know that not setting the background to white for the title also affects this, but it makes perfect sense! Sep 22 at 12:41
  • 1
    @JakobDannel You're welcome! Sep 22 at 12:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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