I want to make a negative increment of an example-block in beamer because I want to revisit a previous example. The enumeration of the examples follows the section numbers. Unfortunately, this gives rise to an incorrect enumeration, since the examples are numbered according to the section they belong to. Is there a way to either increment environment-blocks with a negative step to the counter and still getting the right enumeration, or another way to make a correct enumeration of the environment-blocks?
\documentclass[9pt,trans,xcolor={table},envcountsect]{beamer} % Plain
\usefonttheme[onlymath]{serif}
\usetheme[shownavsym,right]{Aalborg}
\setbeamertemplate{section in toc}[sections numbered] % Automatic enumeration of sections
\setbeamertemplate{blocks}[rounded][shadow=true]
\definecolor{dgreen}{rgb}{0.,0.6,0.}
\definecolor{aaublue}{RGB}{33,26,82}% dark blue
\usepackage{etoolbox} % In order to still use an outdated beamer version
\AtBeginEnvironment{theorem}{%
\setbeamertemplate{itemize items}[circle] % Shape of bullet-points
\setbeamercolor{block title}{bg=dgreen!100!white,fg=white}%
\setbeamercolor{itemize item}{fg=dgreen!100!white}%
\setbeamercolor{itemize subitem}{fg=dgreen!100!white}%
\setbeamercolor{itemize subsubitem}{fg=dgreen!100!white}%
\setbeamercolor{enumerate item}{fg=dgreen!100!black}%
\setbeamercolor{enumerate subitem}{fg=dgreen!100!black}%
\setbeamercolor{enumerate subsubitem}{fg=dgreen!100!black}%
}
\AtBeginEnvironment{definition}{%
\setbeamertemplate{itemize items}[circle] % Shape of bullet-points
\setbeamercolor{block title}{bg=blue,fg=white}%
\setbeamercolor{itemize item}{fg=blue}%
\setbeamercolor{itemize subitem}{fg=blue}%
\setbeamercolor{itemize subsubitem}{fg=blue}%
\setbeamercolor{enumerate item}{fg=blue}%
\setbeamercolor{enumerate subitem}{fg=blue}%
\setbeamercolor{enumerate subsubitem}{fg=blue}%
}
\def \exampleblockcolour {cyan}
\AtBeginEnvironment{example}{%
\setbeamertemplate{itemize items}[circle] % Shape of bullet-points
\setbeamercolor{block title}{bg=\exampleblockcolour,fg=white}%
\setbeamercolor{itemize item}{fg=\exampleblockcolour}%
\setbeamercolor{itemize subitem}{fg=\exampleblockcolour}%
\setbeamercolor{itemize subsubitem}{fg=\exampleblockcolour}%
\setbeamercolor{enumerate item}{fg=\exampleblockcolour}%
\setbeamercolor{enumerate subitem}{fg=\exampleblockcolour}%
\setbeamercolor{enumerate subsubitem}{fg=\exampleblockcolour}%
}
\let\example\undefined
\newtheorem{example}{\translate{Example}}[section]
\uselanguage{danish}
\languagepath{danish}
\deftranslation[to=danish]{Example}{Eksempel}
\setbeamercolor*{block body}{bg=black!10!white,fg=black}
\setbeamercolor*{block body alerted}{bg=normal text.bg!90!black,fg=black}
\setbeamercolor*{block body example}{bg=normal text.bg!90!black,fg=black}
\setbeamercolor*{block title}{parent=structure2,bg=normal text.bg!0!blue}
\setbeamercolor*{block title alerted}{use={normal text,alerted text},fg=alerted text.fg!0!white,bg=normal text.bg!10!red}
\setbeamercolor*{block title example}{use={normal text,example text},fg=white,bg=cyan}
\setbeamercolor*{block title theorem}{use={normal text,example text},fg=example text.fg!100!normal text.fg,bg=normal text.bg!0!dgreen}
\makeatletter
\pgfdeclareverticalshading[lower.bg,upper.bg]{bmb@transition}{200cm}{color(0pt)=(lower.bg); color(4pt)=(lower.bg); color(4pt)=(upper.bg)}
\makeatother
\makeatletter
\newcommand{\ShiftSectionNumber}[1]{%
\beamer@tocsectionnumber=\numexpr#1+\beamer@tocsectionnumber}
\makeatother
\setbeamertemplate{theorems}[numbered]
\addtobeamertemplate{theorem begin}{\normalfont}
\let\definition\undefined
\newtheorem{definition}{\translate{Definition}}[section]
\begin{document}
\begin{frame}%[allowframebreaks]
\frametitle{Overview}
\tableofcontents
\end{frame}
\ShiftSectionNumber{4}
\addtocounter{section}{4} % Enumeration of theorems and examples follows section numbers
\section{Section}
\begin{frame}[<+->]{Negative incrementation of enumeration of environments}
\begin{example}
First example in fifth section.
\end{example}
\section{Section}
\addtocounter{example}{-1}
\begin{example}[Wanted: Eksempel 5.1]
Negative incrementation of the enumeration of blocks.
\end{example}
\end{frame}
\end{document}
Instead of messing with the counters, you can restate your theorem using https://tex.stackexchange.com/a/443/36296
\documentclass[9pt,trans,xcolor={table},envcountsect]{beamer} % Plain
\usefonttheme[onlymath]{serif}
\usetheme[shownavsym,right]{Aalborg}
\setbeamertemplate{section in toc}[sections numbered] % Automatic enumeration of sections
\setbeamertemplate{blocks}[rounded][shadow=true]
\definecolor{dgreen}{rgb}{0.,0.6,0.}
\definecolor{aaublue}{RGB}{33,26,82}% dark blue
\usepackage{etoolbox} % In order to still use an outdated beamer version
\AtBeginEnvironment{theorem}{%
\setbeamertemplate{itemize items}[circle] % Shape of bullet-points
\setbeamercolor{block title}{bg=dgreen!100!white,fg=white}%
\setbeamercolor{itemize item}{fg=dgreen!100!white}%
\setbeamercolor{itemize subitem}{fg=dgreen!100!white}%
\setbeamercolor{itemize subsubitem}{fg=dgreen!100!white}%
\setbeamercolor{enumerate item}{fg=dgreen!100!black}%
\setbeamercolor{enumerate subitem}{fg=dgreen!100!black}%
\setbeamercolor{enumerate subsubitem}{fg=dgreen!100!black}%
}
\AtBeginEnvironment{definition}{%
\setbeamertemplate{itemize items}[circle] % Shape of bullet-points
\setbeamercolor{block title}{bg=blue,fg=white}%
\setbeamercolor{itemize item}{fg=blue}%
\setbeamercolor{itemize subitem}{fg=blue}%
\setbeamercolor{itemize subsubitem}{fg=blue}%
\setbeamercolor{enumerate item}{fg=blue}%
\setbeamercolor{enumerate subitem}{fg=blue}%
\setbeamercolor{enumerate subsubitem}{fg=blue}%
}
\def \exampleblockcolour {cyan}
\AtBeginEnvironment{example}{%
\setbeamertemplate{itemize items}[circle] % Shape of bullet-points
\setbeamercolor{block title}{bg=\exampleblockcolour,fg=white}%
\setbeamercolor{itemize item}{fg=\exampleblockcolour}%
\setbeamercolor{itemize subitem}{fg=\exampleblockcolour}%
\setbeamercolor{itemize subsubitem}{fg=\exampleblockcolour}%
\setbeamercolor{enumerate item}{fg=\exampleblockcolour}%
\setbeamercolor{enumerate subitem}{fg=\exampleblockcolour}%
\setbeamercolor{enumerate subsubitem}{fg=\exampleblockcolour}%
}
\let\example\undefined
\newtheorem{example}{\translate{Example}}[section]
\uselanguage{danish}
\languagepath{danish}
\deftranslation[to=danish]{Example}{Eksempel}
\setbeamercolor*{block body}{bg=black!10!white,fg=black}
\setbeamercolor*{block body alerted}{bg=normal text.bg!90!black,fg=black}
\setbeamercolor*{block body example}{bg=normal text.bg!90!black,fg=black}
\setbeamercolor*{block title}{parent=structure2,bg=normal text.bg!0!blue}
\setbeamercolor*{block title alerted}{use={normal text,alerted text},fg=alerted text.fg!0!white,bg=normal text.bg!10!red}
\setbeamercolor*{block title example}{use={normal text,example text},fg=white,bg=cyan}
\setbeamercolor*{block title theorem}{use={normal text,example text},fg=example text.fg!100!normal text.fg,bg=normal text.bg!0!dgreen}
\makeatletter
\pgfdeclareverticalshading[lower.bg,upper.bg]{bmb@transition}{200cm}{color(0pt)=(lower.bg); color(4pt)=(lower.bg); color(4pt)=(upper.bg)}
\makeatother
\makeatletter
\newcommand{\ShiftSectionNumber}[1]{%
\beamer@tocsectionnumber=\numexpr#1+\beamer@tocsectionnumber}
\makeatother
\setbeamertemplate{theorems}[numbered]
\addtobeamertemplate{theorem begin}{\normalfont}
\let\definition\undefined
\newtheorem{definition}{\translate{Definition}}[section]
\makeatletter
\newtheorem*{rep@theorem}{\rep@title}
\newcommand{\newreptheorem}[2]{%
\newenvironment{rep#1}[1]{%
\def\rep@title{#2 \ref{##1}}%
\begin{rep@theorem}}%
{\end{rep@theorem}}}
\makeatother
\newreptheorem{example}{Eksempel}
\AtBeginEnvironment{repexample}{%
\setbeamertemplate{itemize items}[circle] % Shape of bullet-points
\setbeamercolor{block title}{bg=\exampleblockcolour,fg=white}%
\setbeamercolor{itemize item}{fg=\exampleblockcolour}%
\setbeamercolor{itemize subitem}{fg=\exampleblockcolour}%
\setbeamercolor{itemize subsubitem}{fg=\exampleblockcolour}%
\setbeamercolor{enumerate item}{fg=\exampleblockcolour}%
\setbeamercolor{enumerate subitem}{fg=\exampleblockcolour}%
\setbeamercolor{enumerate subsubitem}{fg=\exampleblockcolour}%
}
\begin{document}
\begin{frame}%[allowframebreaks]
\frametitle{Overview}
\tableofcontents
\end{frame}
\ShiftSectionNumber{4}
\addtocounter{section}{4} % Enumeration of theorems and examples follows section numbers
\section{Section}
\begin{frame}[<+->]{Negative incrementation of enumeration of environments}
\begin{example}
\label{quack}
First example in fifth section.
\end{example}
\end{frame}
\section{Section}
\begin{frame}
\begin{repexample}{quack}
That theorem again
\end{repexample}
\end{frame}
\end{document}