[Tex/LaTex] How to modify (default) Beamercolortheme

beamercolorthemes

I created a latex beamer presentation using "Montepellier" theme with default color theme. I need to modify this theme (I want to change the color of the upper and lower border of header – separately).
So I copied "beamercolorthemedefault" to my project, renamed and included it (this is working!). But I can't change any colors – changing colors has no effect. I changed the default the this way (only the changed first lines):

\ProvidesPackageRCS $Header:   

    /Users/joseph/Documents/LaTeX/beamer/base/themes/color/beamercolorthemedefault.sty,v d02a7cf4d8ae 2010/06/17 09:11:41 rivanvx $


\mode<presentation>

\definecolor{beamer@blendedblue}{rgb}{0.5,0.5,0.3} % changed this

\setbeamercolor{normal text}{fg=black,bg=white}
\setbeamercolor{alerted text}{fg=red}
\setbeamercolor{example text}{fg=green!50!black}

\setbeamercolor{structure}{fg=beamer@blendedblue}

\setbeamercolor{background canvas}{parent=normal text}
\setbeamercolor{background}{parent=background canvas}

\setbeamercolor{palette primary}{fg=yellow,bg=yellow} % changed this
\setbeamercolor{palette secondary}{use=structure,fg=structure.fg!100!green} % changed this
\setbeamercolor{palette tertiary}{use=structure,fg=structure.fg!100!green} % changed this

But all this changes have no effect?! (replacing the complete content by another theme works)
So how to change any colors and how to change the borders of header?

Best Answer

I think you did something very complicated while the solution could have been much more easy. Moreover it is preferable to not modify the default themes: if you do it, at least change theme name.

For example, look at this code:

\documentclass{beamer}
\usetheme{Montpellier}
\begin{document}

\title{My title}
\author{My name}
\institute{My institute}

\makeatletter
\definecolor{beamer@blendedblue}{rgb}{0.5,0.5,0.3} % changed this

\setbeamercolor{normal text}{fg=black,bg=white}
\setbeamercolor{alerted text}{fg=red}
\setbeamercolor{example text}{fg=green!50!black}

\setbeamercolor{structure}{fg=beamer@blendedblue}

\setbeamercolor{background canvas}{parent=normal text}
\setbeamercolor{background}{parent=background canvas}

\setbeamercolor{palette primary}{fg=yellow,bg=yellow} % changed this
\setbeamercolor{palette secondary}{use=structure,fg=structure.fg!100!green} % changed this
\setbeamercolor{palette tertiary}{use=structure,fg=structure.fg!100!green} % changed this
\makeatother

\begin{frame}
\titlepage
\end{frame}

\begin{frame}{A frame}
\begin{itemize}
\item hello
\item hello again
\end{itemize}
\end{frame}

\end{document}

In a very simple manner I got:

enter image description here

enter image description here

If you want to create your own color theme, create a file called for example beamercolorthememyct.sty as:

\definecolor{beamer@blendedblue}{rgb}{0.5,0.5,0.3} % changed this

\setbeamercolor{normal text}{fg=black,bg=white}
\setbeamercolor{alerted text}{fg=red}
\setbeamercolor{example text}{fg=green!50!black}

\setbeamercolor{structure}{fg=beamer@blendedblue}

\setbeamercolor{background canvas}{parent=normal text}
\setbeamercolor{background}{parent=background canvas}

\setbeamercolor{palette primary}{fg=yellow,bg=yellow} % changed this
\setbeamercolor{palette secondary}{use=structure,fg=structure.fg!100!green} % changed this
\setbeamercolor{palette tertiary}{use=structure,fg=structure.fg!100!green} % changed this

You can put it in the same folder of your .tex presentation file (I have TeXLive and it works) or in your personal tree.

Then, the MWE shown above will become:

\documentclass{beamer}

\usetheme{Montpellier}
\usecolortheme{myct}
\begin{document}

\title{My title}
\author{My name}
\institute{My institute}
\begin{frame}
\titlepage
\end{frame}

\begin{frame}{A frame}
\begin{itemize}
\item hello
\item hello again
\end{itemize}
\end{frame}
\end{document}

with the same two frames as graphical result.

EDIT

To change just colors in the upper and lower line head you should use the proper keys. For example adding these lines to your theme color:

\setbeamercolor{upper separation line head}{bg=green}
\setbeamercolor{lower separation line head}{bg=red}

allows you to get:

enter image description here

enter image description here

Related Question