# Extra space below customized theorems in beamer

I'm trying to customize beamer theorems, putting theorem name and theorem body in the same box. But my customization causes extra space below theorems.

A MWE is as follows:

\documentclass{beamer}

\newtheorem{thm}{Theorem}

\begin{document}

\begin{frame}

\begin{thm}Text$$Math$$\end{thm}
\hrule Text

\setbeamertemplate{theorem end}{}

\begin{thm}Text$$Math$$\end{thm}
\hrule Text

\end{frame}

\end{document}


How could I remove extra space below my customized theorems?

You can end the paragraph in the theorem end template:

\setbeamertemplate{theorem end}{\par}


and, if required, add a negative \vskip to decrease ven more the spacing (although I'd say it's OK as it is now).

I added to my answer some other elements to the definition (numbering and the addition of an eventual annotation with the optional argument for the environments, but they are, or course, optional):

\documentclass{beamer}

\newtheorem{thm}{Theorem}

\begin{document}

\begin{frame}

\begin{thm}
Text
$a=b$
\end{thm}
\hrule Text

\setbeamertemplate{theorem begin}{%
{%
\inserttheoremname
\inserttheoremnumber
\inserttheorempunctuation}~%
}
\setbeamertemplate{theorem end}{\par}

\begin{thm}
Text
$a=b$
\end{thm}
\hrule Text

\end{frame}

\end{document}


As a side note, you shouldn't use the old TeX syntax $$...$$ for displayed math; you should use $...$ instead; please see Why is $...$ preferable to $$...$$?.