4

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 begin}{\bfseries\inserttheoremname\quad\normalfont}
\setbeamertemplate{theorem end}{}

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

\end{frame}

\end{document}

enter image description here

How could I remove extra space below my customized theorems?

3

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}{%
  {%
    \inserttheoremheadfont
    \inserttheoremname
    \inserttheoremnumber
    \ifx\inserttheoremaddition\empty\relax\else\(\inserttheoremaddition)\fi%
    \inserttheorempunctuation}~%
  }
\setbeamertemplate{theorem end}{\par}

\begin{thm}
Text
\[
a=b
\]
\end{thm}
\hrule Text

\end{frame}

\end{document}

enter image description here

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 $$ ... $$?.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.