# Customizing theorem name

Suppose I have a series of theorems that I would like displayed as

Jim's Theorem.

Bob's Theorem.

Will's Theorem.

rather than as “Theorem (Jim).”, “Theorem (Bob).”, and “Theorem (Will)”. If I have a lot of these, it becomes tedious having to always go back to the preamble to define a new theorem environment. So I'm curious whether there may be some way to define a new theorem environment that accepts the theorem title as an argument. Ideally, I would like something which I can enter, for example, as

\begin{namedtheorem}{Jim's Theorem}
...
\end{namedtheorem}


and which produces

Jim's Theorem. ...

I can achieve a pretty similar effect by defining a separate new environment, but I cannot get the spacing before and after it to match up with the normal spacing that precedes and follows a theorem environment.

Thanks for any suggestions you may have.

-
Welcome to tex.sx! A tip: If you indent lines by 4 spaces, then they are marked as a code sample. You can also highlight the code and click the "code" button (with "101010" on it). –  Caramdir Mar 8 '11 at 4:08

You can use the amsthms customisable theoremstyles to do this. The trick is just figuring out what arguments to pass! By trial-and-error, I came up with the following:

\documentclass{minimal}

\usepackage{amsthm}

\newtheorem*{theorem}{Theorem}

\newtheoremstyle{named}{}{}{\itshape}{}{\bfseries}{.}{.5em}{\thmnote{#3's }#1}
\theoremstyle{named}
\newtheorem*{namedtheorem}{Theorem}

\begin{document}

Now let us present that most famous of all theorems.

\begin{theorem}[Fred]
All odd numbers are prime.
\end{theorem}

If you don't believe that Fred was involved, you may prefer the following.

\begin{theorem}
All odd numbers are prime.
\end{theorem}

The proof of this is left as an exercise.
Of course, some may prefer to see this as follows.

\begin{namedtheorem}[Fred]
All odd numbers are prime.
\end{namedtheorem}

But still, we shan't bother with the proof here.
As we said, some people don't think that Fred had much to do with this.

\begin{namedtheorem}
All odd numbers are prime.
\end{namedtheorem}

Nonetheless, the proof remains trivial.

\end{document}


Here's the result. Note that the first theorem is in the default style so it's the second pair that you should be looking at.

(Added in edit: I wasn't clear what \thmnote was doing; a little further experimenting shows that if the optional argument isn't given then \thmnote swallows its argument whole so it can be used to change the behaviour depending on whether or not the argument is given. This makes it look better if you do forget the Fred.)

-

\documentclass{article}
\usepackage{amsthm}
\newcommand{\namedthm}[2]{\theoremstyle{plain}
\newtheorem*{thm#1}{#1's Theorem}\begin{thm#1}#2\end{thm#1}}
\begin{document}

\namedthm{Jim}{Hello.  My name is Jim.}

\namedthm{Bob}{Hello.  My name is not Jim.}

\end{document}


One disadvantage is that it's a command, not an environment, and so you have to give the statement of the theorem as the second argument. But it's defined in terms of the \newtheorem command, so it should be typeset consistently with other theorems.

-
Using \newenvironment, you should be able to make the desired syntax from the question work. –  Hendrik Vogt Mar 8 '11 at 10:22

the ntheorem package is more flexible

\documentclass[a4paper]{memoir}
\usepackage{amsmath}
\usepackage[amsmath,thmmarks]{ntheorem}
% normal theorem
\theoremseparator{.}
\newtheorem{theorem}{Theorem}
% Now the optional argument takes over
\theoremstyle{empty}
\newtheorem{namedtheorem}{}
\begin{document}

\begin{theorem}
Some text
\end{theorem}

\begin{namedtheorem}[Jim's Theorem.]
Extra text
\end{namedtheorem}
\end{document}

-

Along the line of Hendrik's comment to John Palmieri's answer somewhere on this page (or maybe the previous or the next, if this question gets sufficiently many answers :) )

\documentclass{article}
\usepackage{amsthm}

\newcounter{nmdthmcnt}
\theoremstyle{plain}\newtheorem*{nmdthm\roman{nmdthmcnt}}{#2's Theorem}%
\begin{nmdthm\roman{nmdthmcnt}}[#1]}{\end{nmdthm\roman{nmdthmcnt}}}

\begin{document}

Test. This is

\begin{namedthm}{Willie}
A theorem that I just proved recently
\end{namedthm}

here's another

\begin{namedthm}{Some big-shot dude}
A theorem that I am just borrowing
\end{namedthm}

And my theorem again,

\begin{namedthm}[version 2]{Willie}
Restatement of the theorem.
\end{namedthm}
\end{document}


I use a counter for each theorem environment, instead of just the "name" of the contributor, so that spaces and special characters in the name won't break the \newtheorem command, and that I don't have to worry about name collisions. I also included compatibility with the optional argument for theorems, as you can see in the third example.

-
Writing "below" is dubious in most cases :-) –  Hendrik Vogt Mar 8 '11 at 11:10
@Hendrik: good point. It did not occur to me that the sort on SE is not necessarily by activity. Corrected :) –  Willie Wong Mar 8 '11 at 11:41
Remember that one of the main inventions in connection with the WWW was links! –  Hendrik Vogt Mar 8 '11 at 11:44
@Hendrik: you could've said that to begin with. Now really corrected. –  Willie Wong Mar 8 '11 at 16:27