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.

This is a follow-up question of this question.

when using \begin{theorem}[Open mapping]...\end{theorem},

I received

this

Is it possible to change the format into "Theorem: Open Mapping."(boldface)?

Thanks a lot!

share|improve this question
add comment

3 Answers

up vote 6 down vote accepted

the optional element of a theorem heading is designated as \thmnote, but this isn't defined in amsthm as an independent element. it is expanded in two places, one for theorem headings with the number following the main heading word, and (as you have it) with the numbers "swapped" as for section headings using \swapnumbers.

probably the easiest way to produce the style you want -- all bold, a colon after the heading word, and no parentheses -- is to redefine the internal command for the swapped form of the heading:

\makeatletter
\renewcommand{\swappedhead}[3]{%
  \thmnumber{\@upn{\@secnumfont#2\@ifnotempty{#1}{.~}}}%
  \thmname{#1}%
   \thmnote{: #3}}
%  \thmnote{ {\the\thm@notefont(#3)}}}
\makeatother

i've left the original definition with \thmnote commented out so that you can see how the change in spacing is applied. the \thm@notefont and the extra braces to isolate its invocation are omitted since the default font isn't changed.

changes of this sort are requested from time to time, so i will take this as a formal request to consider allowing variations in the style of the optional element to be made more easily, when the package is overhauled (perhaps late next year).

share|improve this answer
add comment

Here's a version that uses the \patchcmd macro of the etoolbox package. It contains code for resetting the style for both "ordinary" (theorem-number) and "swapped" (number-theorem) theorem styles.

\documentclass{article}
\usepackage{etoolbox,amsthm}

\makeatletter
% case 1: theorem name--number ("ordinary") style
\patchcmd{\thmhead@plain}%
   {\thmnote{ {\the\thm@notefont(#3)}}}%  original form
   {\thmnote{:  #3}}%  new form
   {}{}
\let\thmhead\thmhead@plain
% case 2: number--theorem name ("swapped") style
\patchcmd{\swappedhead}%
   {\thmnote{ {\the\thm@notefont(#3)}}}%  original form
   {\thmnote{:  #3}}%  new form
   {}{}
\let\swappedhead@plain=\swappedhead
\makeatother
\swapnumbers % switch to "swapped" style for this MWE
\newtheorem{thm}{Theorem}

\begin{document}
\begin{thm}[Pythagoras] $a^2+b^2=c^2.$ \end{thm}
\end{document}

enter image description here

share|improve this answer
add comment

Another option, not involving redefinitions of internal commands can be obtained using the thmtools package as a front-end for amsthm:

\documentclass{article}
\usepackage{amsthm}
\usepackage{thmtools}

\declaretheoremstyle[
notefont=\bfseries, notebraces={}{},
bodyfont=\normalfont\itshape,
headformat=\NUMBER~\NAME:\NOTE
]{nopar}
\declaretheorem[style=nopar]{theorem}

\begin{document}

\begin{theorem}[FTA]
Every non-constant single-variable polynomial with complex coefficients has at least one complex root. 
\end{theorem}

\end{document}

enter image description here

share|improve this answer
    
A really neat use of the thmtools package! By the way, I don't know how picky the OP is, but you may want to get rid of the period placed after the theorem number. –  Mico Apr 20 '12 at 0:23
    
@Mico: yes, that period! It's a cultural thing, I guess; we tend to use periods after every enumeration number. Thnak you. –  Gonzalo Medina Apr 20 '12 at 1:05
    
it seems like thmtools conflicts with hyperref... –  newbie Apr 20 '12 at 15:45
add comment

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.