When putting labels on the different environments in a beamer presentation, it creates some unwanted extra space between the block header and the first line in the block body. It makes no difference whether the reference is being used later on or not. This goes for all the environments provided in the code below. Is there a way to remove this extra space?
\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{lemma}{%
\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{corollary}{%
\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}%
}
\newtheorem{opgave}{Opgave}[section]
\AtBeginEnvironment{opgave}{
\setbeamercolor{block title}{fg=white,bg=normal text.bg!10!red}
\setbeamercolor{block title}{fg=white,bg=red}
\setbeamertemplate{itemize items}[circle]
\setbeamercolor{itemize item}{fg=red}
\setbeamercolor{itemize subitem}{fg=red}
\setbeamercolor{itemize subsubitem}{fg=red}
\setbeamercolor{enumerate item}{fg=red}
\setbeamercolor{enumerate subitem}{fg=red}
\setbeamercolor{enumerate subsubitem}{fg=red}
}
\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}[<+->]{Extra unwanted space}
\begin{definition}\label{def:FirstDefinition}
\begin{itemize}
\item Wanted: Extra space above this line removed.
\end{itemize}
\end{definition}
\begin{lemma}\label{lemma:FirstLemma}
\begin{itemize}
\item Wanted: Extra space above this line removed.
\end{itemize}
\end{lemma}
\begin{theorem}\label{th:FirstTheorem}
\begin{itemize}
\item Wanted: Extra space above this line removed.
\end{itemize}
\end{theorem}
\begin{corollary}\label{cor:FirstOpgave}
\begin{itemize}
\item Wanted: Extra space above this line removed.
\end{itemize}
\end{corollary}
\begin{opgave}\label{opg:FirstOpgave}
\begin{itemize}
\item Wanted: Extra space above this line removed.
\end{itemize}
\end{opgave}
\end{frame}
\end{document}
Use at your own risk (from https://github.com/josephwright/beamer/issues/541#issuecomment-552993755 ):
\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{lemma}{%
\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{corollary}{%
\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}%
}
\newtheorem{opgave}{Opgave}[section]
\AtBeginEnvironment{opgave}{
\setbeamercolor{block title}{fg=white,bg=normal text.bg!10!red}
\setbeamercolor{block title}{fg=white,bg=red}
\setbeamertemplate{itemize items}[circle]
\setbeamercolor{itemize item}{fg=red}
\setbeamercolor{itemize subitem}{fg=red}
\setbeamercolor{itemize subsubitem}{fg=red}
\setbeamercolor{enumerate item}{fg=red}
\setbeamercolor{enumerate subitem}{fg=red}
\setbeamercolor{enumerate subsubitem}{fg=red}
}
\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
\def\beamer@inserttarget#1{%
\ifbeamer@inframe%
#1%
\else% defer to next frame
\expandafter\gdef\expandafter\beamer@framehypertargets\expandafter{\beamer@framehypertargets#1}%
\fi%
}
\makeatother
\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}[<+->]{Extra unwanted space}
\begin{definition}\label{def:FirstDefinition}%
\begin{itemize}
\item Wanted: Extra space above this line removed.
\end{itemize}
\end{definition}
\begin{lemma}\label{lemma:FirstLemma}
\begin{itemize}
\item Wanted: Extra space above this line removed.
\end{itemize}
\end{lemma}
\begin{theorem}\label{th:FirstTheorem}
\begin{itemize}
\item Wanted: Extra space above this line removed.
\end{itemize}
\end{theorem}
\begin{corollary}\label{cor:FirstOpgave}
\begin{itemize}
\item Wanted: Extra space above this line removed.
\end{itemize}
\end{corollary}
\begin{opgave}\label{opg:FirstOpgave}
\begin{itemize}
\item Wanted: Extra space above this line removed.
\end{itemize}
\end{opgave}
\end{frame}
\end{document}