[Tex/LaTex] Slide number in beamer Berkeley header

beamer

Could someone please tell me how to get the page numbers to appear in the header line of the Berkeley theme?

Thanks

Best Answer

Although beamer provides many hooks for modifying the way things look, the author couldn't think of every possible tweak, and so some things that you might think would be simple are not. This is one of those cases, since it involves hunting through the beamer source code (specifically in beamerouterthemesidebar.sty) to find the definition of the frametitle and then modifying a copy of the relevant code in the preamble of the document.

\documentclass{beamer}
\usetheme{Berkeley}

\makeatletter
\setbeamertemplate{frametitle}{%
    \nointerlineskip%
    \vskip-\beamer@headheight%
    \vbox to \beamer@headheight{%
      \vfil
      \leftskip=-\beamer@leftmargin%
      \advance\leftskip by0.3cm%
      \rightskip=-\beamer@rightmargin%
      \advance\rightskip by0.3cm plus1fil%
      {\usebeamercolor[fg]{frametitle}
          \usebeamerfont{frametitle}\insertframetitle\hfill\insertframenumber\par}% added number
      {\usebeamercolor[fg]{framesubtitle}
           \usebeamerfont{framesubtitle}\insertframesubtitle\par}%
      \vbox{}%
      \vskip-1em%
      \vfil
    }%
  }
\makeatother
\begin{document}
\section{A section}
\begin{frame}{A frame}
\end{frame}
\end{document}

output of code