Text background in a beamer frametitle

Viewed 412

I am trying to create a beamer presentation with a custom frame title (that is compatible with my organization's corporate design). The text should be in white on a blue background, but the background should be only behind the text (i.e. as if the text was markered). I tried to redefine the frametitle macro using \hl from the soul package, but \hl does not work when it contains the \insertframetitle macro. An approach based on \colorbox is not possible with multiline frametitles. Are there any workarounds? Greetings!

enter image description here

1 Answers

You can use the lua-ul package (requires lualatex)

% !TeX TS-program = lualatex
\documentclass{beamer}

\usepackage{luacolor}
\usepackage{lua-ul}

\makeatletter
  \newunderlinetype\@myhighLight[\number\dimexpr1ex@%
                               \luaul@currentcolor]{%
    \luaul@applycolor
    \leaders\vrule height 2.25ex depth .75ex
  }
  \NewDocumentCommand\myhighLight{O{\luaul@highlight@color}+m}{{%
    \luaul@setcolor{#1}%
    \@myhighLight#2%
  }}  
\makeatother  

\setbeamertemplate{frametitle}{\myhighLight[frametitle.bg]{\insertframetitle}}
\setbeamercolor{frametitle}{fg=white,bg=blue}


\begin{document}
    
\begin{frame}
\frametitle{Ütitle}
    abc 
\end{frame} 

\begin{frame}
\frametitle{Überraschungsei title title title title title title title title title title title title}
    abc
\end{frame} 
    
\end{document}

enter image description here

Related