9

When we write a theorem in beamer, by default the theorem name and theorem content are in different lines, like this:

|-------------------------------------------
|Theorem 1
|-------------------------------------------
|Some theorem content.
|-------------------------------------------

How to make the theorem name and theorem content show in the same line? like this:

|---------------------------------------------
|Theorem 1: Some theorem content.
|---------------------------------------------
1
12

beamer provides a means to modify the start and end of a theorem environment by setting the appropriate template. The start of the theorem environment template is defined within theorem begin, and the end in the template theorem end:

\documentclass{beamer}

\makeatletter
\setbeamertemplate{theorem begin}
{%
  \inserttheoremheadfont% \bfseries
  \inserttheoremname \inserttheoremnumber
  \ifx\inserttheoremaddition\@empty\else\ (\inserttheoremaddition)\fi%
  \inserttheorempunctuation
  \normalfont
}
\setbeamertemplate{theorem end}{%
  % empty
}
\makeatother

\begin{document}
\begin{frame}
  \begin{theorem}[Theorem name]
    This is a very important theorem and requires an exceptional proof.
  \end{theorem}
\end{frame}
\end{document}

enter image description here

\inserttheoremheadfont formats the header as \bfseries. If you want to modify this (and add some colour or perhaps even a different style (\itshape, say), input it directly as needed. Ending in \normalfont switches back to the normal font shape for typesetting the remainder of the theorem content. \inserttheoremname inserts Theorem, while \inserttheoremnumber inserts the theorem number. Whatever is specified as the optional argument to theorem is considered as a "theorem addition", and is inserted using \inserttheoremaddition. Punctuation, if any, is provided by \insertpunctuation (default is a period .).

The redefinition of theorem end is also required. In this case, it is left empty.

4
  • How to modify this for proof? – Subhajit Paul May 22 '20 at 18:56
  • @SubhajitPaul: Try adding this to your preamble. – Werner May 22 '20 at 19:28
  • Thanks for your effort. But I have another code running for continuous proof environments spread over multiple slides. A snippet of which is kept here. And your additional piece of code is not going well with that. If this requires a new question to be posted, I will do the needful. Please suggest. – Subhajit Paul May 22 '20 at 19:44
  • @SubhajitPaul: Yeah, I'd suggest asking a new question. – Werner May 22 '20 at 19:46

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.