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.

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.

share|improve this question
    
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

6 Answers 6

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.

named theorems

(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.)

share|improve this answer

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}
share|improve this answer

How about this:

\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.

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

Loop Space's answer is good, but has the disadvantage of clobbering the optional argument, so attribution can't be specified any more.

I'd suggest using a mandatory argument.

\documentclass{article}
\usepackage{amsthm}

\swapnumbers % optional, of course
\newtheorem{thm}{Theorem}[section] % the main one
\newtheorem{lemma}[thm]{Lemma}
% other statement types

% for specifying a name
\theoremstyle{plain} % just in case the style had changed
\newcommand{\thistheoremname}{}
\newtheorem{genericthm}[thm]{\thistheoremname}
\newenvironment{namedthm}[1]
  {\renewcommand{\thistheoremname}{#1}%
   \begin{genericthm}}
  {\end{genericthm}}

\begin{document}

\section{Something}

A theorem

\begin{thm}
$1+1=2$.
\end{thm}

And a named theorem

\begin{namedthm}{Zorn's Lemma}[Zermelo]
All well-behaved ordered sets have maximal elements.
\end{namedthm}

\end{document}

enter image description here

Of course the optional argument after the mandatory argument to \begin{namedthm} is really optional.

For unnumbered theorems, define a genericthm* theorem in the same fashion

\newtheorem*{genericthm*}{\thistheoremname}
\newenvironment{namedthm*}[1]
  {\renewcommand{\thistheoremname}{#1}%
   \begin{genericthm*}}
  {\end{genericthm*}}

and

\begin{namedthm*}{Zorn's Lemma}

or

\begin{namedthm*}{Zorn's Lemma}[Zermelo]

will do.

share|improve this answer
    
This works brilliantly for what I want! Thanks! Is it also possible to define the "thm" environment to behave normally if it hasn't an optional argument, and if it has an argument, behave like your namedthm ? –  Kasper Oct 2 at 11:28

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}
\newenvironment{namedthm}[2][]{\addtocounter{nmdthmcnt}{1}%
    \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.

share|improve this answer

I'ld recommend taking a look at the various documents related to math typesetting available here: http://tug.org.in/ and in particular, the LaTeX primer document downloadable from http://sarovar.org/projects/ltxprimer/ The chapter on math typesetting in the latter discusses in detail how to do various kinds of customization of theorem names, etc.

share|improve this answer
    
The closest I found in ltxprimer is on page 113/114 in the chapter about typesetting theorems, but it doesn't say anything about the syntax the OP would like. –  Hendrik Vogt Mar 8 '11 at 10:08

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.