How to insert a section title with its number in a beamer frame

\documentclass{beamer}

\setbeamertemplate{frametitle}{\thesection.~\insertsection~\insertframetitle}

\makeatletter
\CheckCommand*\beamer@checkframetitle{\@ifnextchar\bgroup\beamer@inlineframetitle{}}
\renewcommand*\beamer@checkframetitle{\global\let\beamer@frametitle\relax\@ifnextchar\bgroup\beamer@inlineframetitle{}}
\makeatother

\begin{document}

\section{section one} 
\begin{frame}
blub
\end{frame} 

\section{section two} 
\begin{frame}
blub
\end{frame}

\end{document}

enter image description here


In the Latex beamer document class, the frame title (and subtitle) for a frame are defined in beamerouterthemedefault.

To override the definition, you can copy the definition into your Latex file and enclose it with \makeatletter and \makeatother.

For example, to add the section number before the title, change the following line and add \thesection.~\insertsection:~ before \insertframetitle:

\strut\thesection.~\insertsection:~\insertframetitle\strut\par%

Full Example:

\documentclass{beamer}

\usepackage[utf8]{inputenc}
\usetheme{default}

\makeatletter
\defbeamertemplate*{frametitle}{customized}[1][left]
{%
  \ifbeamercolorempty[bg]{frametitle}{}{\nointerlineskip}%
  \@tempdima=\textwidth%
  \advance\@tempdima by\beamer@leftmargin%
  \advance\@tempdima by\beamer@rightmargin%
  \begin{beamercolorbox}[sep=0.3cm,#1,wd=\the\@tempdima]{frametitle}
    \usebeamerfont{frametitle}%
    \vbox{}\vskip-1ex%
    \if@tempswa\else\csname beamer@fte#1\endcsname\fi%
    % The following line was modified to insert
    % section number (\thesection)
    % and section title (\insertsection).
    \strut\thesection.~\insertsection:~\insertframetitle\strut\par%
    {%
      \ifx\insertframesubtitle\@empty%
      \else%
      {\usebeamerfont{framesubtitle}\usebeamercolor[fg]%
         {framesubtitle}\insertframesubtitle\strut\par}%
      \fi
    }%
    \vskip-1ex%
    \if@tempswa\else\vskip-.3cm\fi% set inside beamercolorbox... evil here...
  \end{beamercolorbox}%
}
\makeatother

\begin{document}

\section{Section Title}

\begin{frame}{Frame Title}
Some text.
\end{frame}


\end{document}

Result:

Latex beamer frame with section number and title