2

I'm trying to define an underlined block title in beamer and I'm unable to do it. Could anybody help me with that? I managed to customize the specific font and shape of the block title, but so far no success with the underlining. My (successful) code is the following:

\setbeamerfont{block title}{size=\normalsize, series=\bfseries}

\underline command is not working (neither is \ul with the soul package)... Any help welcome!

6
  • Hello and welcome. Can you provide an MWE? That way we could help you more easily. – Sango Jan 17 '20 at 12:07
  • 4
    I’m voting to close this question because OP after one and half year still not respond to comment nor to received answers. – Zarko Jun 11 at 7:18
  • 7
    @Zarko that's a strange reason for closing. – David Carlisle Jun 11 at 11:58
  • 1
    @Zarko point is the answers may be useful to others even if the OP never returns but they are hidden if you close. – David Carlisle Jun 11 at 17:28
  • 1
    @DavidCarlisle, well, I vas convinced that answers after closed question stay as they were before, and that with this is only prevented that this question is periodically appears as modified. I will retract my vote for closing question when this will be possible. – Zarko Jun 11 at 17:33
3

With this: (taken from here Changing default width of blocks in beamer)

\documentclass[10pt,a4paper]{beamer}
\usepackage[latin1]{inputenc}
\usetheme{Warsaw}


\newenvironment<>{varblock}[2][\textwidth]{%
    \setlength{\textwidth}{#1}
    \begin{actionenv}#3%
        \def\insertblocktitle{\underline{#2}}%
        \par%
        \usebeamertemplate{block begin}}
    {\par%
        \usebeamertemplate{block end}%
\end{actionenv}}
\begin{document}

    \begin{frame}
    \frametitle{Sample frame title}
    This is a text in the first frame. This is a text in the first frame. This is a text in the first frame.
    {\begin{varblock}{title}blabla\end{varblock}}
\end{frame}
\end{document}

Result:

enter image description here

3

To just patch all blocks to have an underlined title, you can add a redefinition of \insertblocktitle as \underline{\insertblocktitle} at the start of the block begin beamer template.

Edit: Similarly, for the exampleblock and alertblock environments, add the same lines to the block example begin and block alerted begin beamer templates.

MWE:

\documentclass{beamer}
\addtobeamertemplate{block begin}{%
    \let\oldinsertblocktitle\insertblocktitle%
    \def\insertblocktitle{\underline{\oldinsertblocktitle}}%
}{}
\addtobeamertemplate{block example begin}{%
    \let\oldinsertblocktitle\insertblocktitle%
    \def\insertblocktitle{\underline{\oldinsertblocktitle}}%
}{}
\addtobeamertemplate{block alerted begin}{%
    \let\oldinsertblocktitle\insertblocktitle%
    \def\insertblocktitle{\underline{\oldinsertblocktitle}}%
}{}
\begin{document}
\begin{frame}{My frame}
\begin{block}{My block}
    has some content
\end{block}
\begin{exampleblock}{My block}
    has some content
\end{exampleblock}
\begin{alertblock}{My block}
    has some content
\end{alertblock}
\end{frame}
\end{document}

enter image description here

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.