2

I am trying to create custom beamer blocks for a template using a tikzpicture for the title of the block and a beamercolorbox for the body.

Here is a MCVE:

\documentclass[t]{beamer}

\usepackage{tikz}
\usepackage{calc}

\setbeamercolor{block body}{fg = black, bg=blue!10}
\setbeamertemplate{block begin}{%
  \tikz\node[text width=\textwidth{} - .4cm, inner sep=.2cm, fill=blue]{
    \color{white}\insertblocktitle};
  \begin{beamercolorbox}[leftskip=.2cm, rightskip=.2cm, dp=1ex, vmode]{block body}%
    \vspace*{0.15cm}
}

\setbeamertemplate{block end}{%
\end{beamercolorbox}
}

\begin{document}

\begin{frame}
  \begin{block}{Default}
    Content.
  \end{block}

  Some text after\ldots{}
\end{frame}

\end{document}

I have two problems with the above code:

  1. There is a small space between the tikzpicture and the beamercolorbox that I would like to get rid of... I could use a negative vspace, but not knowing where the space comes from, I do not want to put a random value.

  2. Combining the tikzpicture with the beamercolorbox creates extra space below the block... Removing the tikzpicture or the beamercolorbox fix the issue, but I need both.

Here is the output I get:

enter image description here

2

I found out how to fix both issues with a simple change right after posting this... You need to separate the tikzpicture and the beamercolorbox into two latex "paragraph" and use nointerlineskip:

}; % End of the tikz picture

\nointerlineskip%
\begin{beamercolorbox}

The extra blank line is required for this to work.

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.