Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I'm writing a beamer presentation and using the theorem environment in the standard manner:

\begin{theorem}[Subject]
this is text
\end{theorem}

Which creates the textbox with the proper look but my problem is with the title, right now it is Theorem (Subject) while I would like it to be only Subject.

I'm thinking there should be a way to change the title while still using theorem.

share|improve this question
3  
And what about block environment in beamer? It would typeset what you want. –  m0nhawk Dec 28 '12 at 20:17
    
Honestly it's just that I've already written a lot of theorem in the slides and I don't have any experience with block. –  George Bora Dec 28 '12 at 20:46

1 Answer 1

up vote 9 down vote accepted

Yes you can achieve that with amsthm, cf. the following minimal working example.

\documentclass{beamer} 
\usepackage{etoolbox} 

\newcommand\mybeamerthm[2]{%
  \newtheorem*{#1}{#2}%
  \AtBeginEnvironment{#1}{%
     \setbeamercolor{block body}{fg=yellow,bg=blue!40}%
  }%
}

\begin{document}
\begin{frame}
\frametitle{test}

\mybeamerthm{subj}{Subject}
\begin{subj}
  theorem on subject
\end{subj}

\mybeamerthm{foo}{bar}
\begin{foo}
  theorem on bar
\end{foo}
\end{frame}
\end{document}                                                                  
share|improve this answer
2  
beamer preloads amsthm, so there should be no reason to load it explicitly. –  Werner Dec 28 '12 at 20:20
    
Depends on whether or not you set the noamsthm option to the documentclass, but since i didn't set it you are of course right. I changed the answer –  Max Dec 28 '12 at 20:27
    
I would also be tempted to define subj in the document preamble, rather than in the frame. It's just good practice to separate content from structure. Add in the reference to beamer loading amsthm, and I'll delete my comments. –  Werner Dec 28 '12 at 20:30
    
This is what I'm looking for but I forgot to add in the theorem block I switched some colors like the answer in this question tex.stackexchange.com/questions/87216/… . Which environment would I need to replace theorem with in this case? –  George Bora Dec 28 '12 at 20:57
2  
With the updated solution you could even create a command/environment that takes the name of the theorem and creates the correct environment on the fly and squeezes the content in between. If you like it nasty you could even redefine theorem to that so you don't have to edit your document. That would be rather on the dark side though and i strongly advise against it. –  Max Dec 28 '12 at 21:21

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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