TransWikia.com

Change color in beamer template

TeX - LaTeX Asked by user3680510 on January 9, 2021

documentclass[xcolor=dvipsnames,10pt]{beamer}
usetheme{Boadilla}
usepackage{amsmath}
usepackage{mathrsfs}
usepackage{braket}
usepackage{xcolor}
usepackage{dsfont}
definecolor{ocre}{RGB}{243,102,25}
definecolor{blub}{RGB}{51,51,178} 
definecolor{blub2}{RGB}{173,173,224} 
setbeamerfont{itemize/enumerate subbody}{size=scriptsize}

begin{document}

begin{frame}
    frametitle{Approximation of coupler potential}
%setbeamercolor{block title}{fg=white,bg=blub}
%setbeamercolor{block body}{use=structure,bg=white}
        begin{block}{ asd}
asdasdasd
            end{block}
    end{frame}

end{document}

I want to change the block title background color to blub and the block title text color to white.

If i use the command

%setbeamercolor{block title}{fg=white,bg=blub}

The titel is good, however the block content color is also changed i do not understand why and how can i fix this. I want to keep the old colors, which i think is blub2

One Answer

The Boadilla theme internally loads the rose color theme, in which the colors of the block title and block body are defined as follows:

setbeamercolor{block title}{use=structure,fg=structure.fg,bg=structure.fg!20!bg}
setbeamercolor{block body}{parent=normal text,use=block title,bg=block title.bg!50!bg}

Since the block body background color is defined as block title.bg!50!bg it depends on the background color of the block title which is why block body changes upon redefining the block title color. To overcome this and only change the colors of block title while keeping block body as before, you can use the following:

setbeamercolor{block title}{fg=white,bg=blub}
setbeamercolor{block body}{parent=normal text,use=block title,bg=structure.fg!20!bg!50!bg}

enter image description here

documentclass[xcolor=dvipsnames,10pt]{beamer}
usetheme{Boadilla}

definecolor{blub}{RGB}{51,51,178} 

setbeamercolor{block title}{fg=white,bg=blub}
setbeamercolor{block body}{parent=normal text,use=block title,bg=structure.fg!20!bg!50!bg}

begin{document}

begin{frame}
    frametitle{Approximation of coupler potential}
    begin{block}{ asd}
        asdasdasd
    end{block}
end{frame}
end{document}

Correct answer by leandriis on January 9, 2021

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