TransWikia.com

customize beamer block environment: underline block title

TeX - LaTeX Asked by euskal on November 8, 2020

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!

2 Answers

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%
        definsertblocktitle{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}blablaend{varblock}}
end{frame}
end{document}

Result:

enter image description here

Answered by Sango on November 8, 2020

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}{%
    letoldinsertblocktitleinsertblocktitle%
    definsertblocktitle{underline{oldinsertblocktitle}}%
}{}
addtobeamertemplate{block example begin}{%
    letoldinsertblocktitleinsertblocktitle%
    definsertblocktitle{underline{oldinsertblocktitle}}%
}{}
addtobeamertemplate{block alerted begin}{%
    letoldinsertblocktitleinsertblocktitle%
    definsertblocktitle{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

Answered by Tiuri on November 8, 2020

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP