\setbeamertemplate no effect in **infolines** outer theme

I am attempting to modify the section in header of my beamer. I use outer theme infolines. The command \setbeamertemplate has no effect in my case. Below is my MWE:

\documentclass{beamer}
\useoutertheme{infolines}
\begin{document}
\section{title}
\begin{frame}
content...
\end{frame}
\end{document}


Why I cannot redefine the section in header or footer using command \setbeamertemplate?

• infolines theme defines a header and a footer that doesn't use section in head/foot. – Ignasi May 10 '16 at 18:59
• @Ignasi so what is the beamer element used? – Say OL May 11 '16 at 1:05
• It's a beamercolorbox which calls \insertsectionhead. You can look for it. Search beamerouterthemeinfolines.sty file in your system or read it from CTAN – Ignasi May 11 '16 at 6:05
• @Ignasi so this means that we are not able to simply use \setbeamertemplate to redefine the section in header in infolines outer theme! – Say OL May 11 '16 at 6:10

If you look at file beamerouterthemeinfolines.sty where infolines outer theme is defined will see that infolines headline is defined with a beamercolorbox and not with a section in head/foot template. So if you want to change this theme it's better to take the original definition and change it according your taste. This is what I've done in following code. The original \defbeamertemplate*{headline} has been copied and converted to \setbeamertemplate, inserted between \makeatother+\makeatletter and changed to show \thesection.\insertsectionhead.

\documentclass{beamer}

\makeatletter
{
\leavevmode%
\hbox{%
\end{beamercolorbox}%
\end{beamercolorbox}}%
\vskip0pt%
}
\makeatother

\begin{document}
\section{title}
\subsection{subsection}
\begin{frame}
content...
\end{frame}
\section{new title}
\subsection{another subsection}
\begin{frame}
content...
\end{frame}
\end{document}


This is the result: