1

In the following MWE I have managed to overlap block title and block body. However, I want to send block body to the back or block title to the front.

\documentclass{beamer} 
\usetheme{Dresden}
\setbeamercolor{block title}{fg=white,bg=blue}
\setbeamercolor{block body}{fg=black,bg=black!5}
\setbeamerfont{block title}{size=\normalsize,series=\bf}
\setbeamerfont{block body}{size=\normalsize}
\setbeamertemplate{block begin}{
    \begin{beamercolorbox}[rounded=true]{block title}
        \usebeamerfont*{block title}\insertblocktitle
    \end{beamercolorbox}
    \vskip-1pt
    \usebeamerfont{block body}
    \begin{beamercolorbox}[wd=1\linewidth,sep=1pt,leftskip=0.2cm,rightskip=0.2cm]{block body}\vskip1pt
}
\setbeamertemplate{block end}{
    \vskip6pt
    \end{beamercolorbox}
}
\begin{document}

\begin{frame}
\begin{block}{Title}
some text here
\end{block}

\end{frame}

\end{document}

enter image description here

1
  • 1
    If you're open to tcolorbox boxes, examples in its package manual, sec. 10.2.2 "Options for the Boxed Title Placement" would help. Commented Dec 6, 2021 at 8:37

1 Answer 1

1

As with all non-standard block customisations, the answer is use tcolorbox:

\documentclass{beamer} 

\usetheme{Dresden}

\usepackage[most]{tcolorbox}


\setbeamertemplate{block begin}{
    \usebeamercolor[fg]{block body}
    \usebeamercolor[fg]{block title}
    \usebeamercolor[bg]{block body}
    \usebeamercolor[bg]{block title}    
    \begin{tcolorbox}[
      title=\parbox{\linewidth}{\insertblocktitle},
      attach boxed title to top center={yshift=-2mm},
      enhanced,
      colback=structure.fg!75!black!10!,
      colbacktitle=structure.fg!75!black,
      frame empty, 
      ]
}
\setbeamertemplate{block end}{
    \end{tcolorbox}
}
\begin{document}

\begin{frame}
\begin{block}{Short title}
some text here
\end{block}
\begin{block}{A bit more long title}
some text here
\end{block}
\end{frame}

\end{document}

enter image description here

The code can be further simplified with the new tcolorbox inner theme (https://www.ctan.org/pkg/beamertheme-tcolorbox ):

\documentclass{beamer} 

\usetheme{Dresden}
\usecolortheme{orchid}

\useinnertheme[rounded]{tcolorbox}

\tcbset{
  minipage boxed title,
  attach boxed title to top center={yshift=-1mm},
  enhanced,
  bottom=1mm,
}

\begin{document}

\begin{frame}
\begin{block}{Short title}
some text here
\end{block}
\begin{block}{A bit more long title}
some text here
\end{block}
\end{frame}

\end{document}

enter image description here

You must log in to answer this question.

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