[Tex/LaTex] special circled frame number in beamer

beamerpage-numbering

Is it possible to customize frame number like figure below?enter image description here

Best Answer

Below I present two options:

\documentclass{beamer}
\usepackage{tikz}

\definecolor{color1}{RGB}{173,216,230}
\definecolor{color2}{RGB}{255,140,0}

\newcounter{totavalue}

\def\aux{1}
\def\radius{20pt}

\newcommand\circcounteri{%
\ifnum\inserttotalframenumber<2\relax
\else
  \setcounter{totavalue}{\inserttotalframenumber}%
\fi%
\pgfmathsetmacro{\aux}{360/\thetotavalue}%
\begin{tikzpicture}[overlay]
  \fill[color1] 
    (0,0) -- (0:\radius) arc  (0:360:\radius) -- cycle;
  \fill[color2] 
    (0,0) -- (90:\radius) arc  (90:90-\insertframenumber*\aux:\radius) -- cycle;
  \node[font=\color{white}] at (0,0) {\strut\Large\insertframenumber};
\end{tikzpicture}%
}

\addtobeamertemplate{headline}{}{\vskip1cm\hspace*{15pt}smash\circcounteri\hfill}

\newcommand\TestFr{\begin{frame}
test
\end{frame}}

\begin{document}

\TestFr\TestFr\TestFr\TestFr\TestFr\TestFr\TestFr\TestFr
\TestFr\TestFr\TestFr\TestFr\TestFr\TestFr\TestFr\TestFr
\TestFr\TestFr\TestFr\TestFr\TestFr\TestFr\TestFr\TestFr
\TestFr\TestFr\TestFr\TestFr\TestFr\TestFr\TestFr\TestFr

\end{document}

enter image description here

The second fancier option (this might take longer to process for a presentation with many frames):

\documentclass{beamer}
\usepackage{tikz}

\definecolor{color1}{RGB}{173,216,230}
\definecolor{color2}{RGB}{255,140,0}

\newcounter{totavalue}
\newcounter{parvalue}

\def\aux{1}
\def\radius{20pt}
\def\step{4pt}

\newcommand\circcounter{%
\ifnum\inserttotalframenumber<2\relax
\else
  \setcounter{totavalue}{\inserttotalframenumber}
  \setcounter{parvalue}{\insertframenumber}
  \ifnum\inserttotalframenumber>45\relax
    \renewcommand\step{0pt}
  \fi%
  \pgfmathsetmacro{\aux}{360/\thetotavalue}
  \begin{tikzpicture}[remember picture,overlay,rotate=90+\aux]
  \foreach \i in {0,1,...,\thetotavalue}
    \fill[color1] 
      (0,0) -- (-\i*\aux:\radius) arc  (-\i*\aux:-(\i+1)*\aux+\step:\radius) -- cycle;
  \foreach \i in {1,...,\insertframenumber}
    \fill[color2] 
      (0,0) -- (-\i*\aux:\radius) arc  (-\i*\aux:-(\i+1)*\aux+\step:\radius) -- cycle;
  \fill[white] circle (\radius/2);
  \node at (0,0) {\large\insertframenumber}; 
  \end{tikzpicture}%
\fi%
}

\addtobeamertemplate{headline}{}{\vskip1cm\hfill\circcounter\hspace*{1cm}}

\newcommand\TestFr{\begin{frame}
test
\end{frame}}

\begin{document}

\TestFr\TestFr\TestFr\TestFr\TestFr\TestFr\TestFr\TestFr
\TestFr\TestFr\TestFr\TestFr\TestFr\TestFr\TestFr\TestFr
\TestFr\TestFr\TestFr\TestFr\TestFr\TestFr\TestFr\TestFr

\end{document}

enter image description here