10

The difficulty that I am having is that I make a newtheorem:

\newtheorem{definition}[theorem]{Definition}

It however seems to act nearly the same as with newenvironment:

\newenvironment{definition}[1][Definition]{\begin{trivlist}
\item[\hskip \labelsep {\bfseries #1}]}{\end{trivlist}}

so why would I use one over the other?

as far as the manipulating them goes, I find resources for newtheorem with all sorts of combinations of arguments i.e.:

\newtheorem{theorem}{Theorem}[section]
\newtheorem{lemma}[theorem]{Lemma}
\newtheorem{proposition}[theorem]{Proposition}
\newtheorem{corollary}[theorem]{Corollary}

which looks similar to the newenvironment setup except that we have an [1] in front of [Definition] in newenvironment which I am guessing is taking in an argument and thus could be expanded to several. Also there seems to be a bunch of stuff defined in the 3'rd item of newenvironment where - \begin{trivlist}\item[\hskip \labelsep {\bfseries #1}]{\end{trivlist} is defined. Are newtheorems arguments already defined in the system or something and not expandable to multiple arguments - is that one of the differences?

Anyways I am just trying to figure out when to use newtheorem and when to use newenvironment

9
  • 4
    The first one gives you automatic numbering; the second one doesn't; the first one gives you italics for the body of the structure, the second one, doesn't. If, additionally, you are using the amsthm package, you have three predefined styles that can be easily applied to structures (using \theoremstyle) and additionally, you can use the powerful \newtheoremstyle to customize the structures defined using \newtheorem. Commented Jan 24, 2014 at 1:39
  • 2
    See en.wikibooks.org/wiki/LaTeX/Theorems for all the kinds of things you can do with \newtheorem - numbering, describing, labeling, ... . Use it instead of \newevironment when you need those features. Commented Jan 24, 2014 at 1:41
  • A tip: If you indent lines by 4 spaces or enclose words in backticks `, they'll be marked as code, as can be seen in my edit. You can also highlight the code and click the "code" button (with "{}" on it).
    – Adam Liter
    Commented Jan 24, 2014 at 1:42
  • 1
    a theorem is indeed a kind of environment. the reason that \newtheorem exists is that mathematians write a lot of theorems, the format of theorems is well defined by tradition, and it would be silly for every mathematician to have to define his/her own environment for every new document. besides, publishers of mathematics do like to have some control over the style of their publications, so a reliable package is desirable. Commented Jan 24, 2014 at 2:53
  • 1
    @GonzaloMedina Make that an answer, please.
    – lockstep
    Commented Jan 28, 2014 at 16:24

1 Answer 1

6

Although \newtheorem is, in fact, similar to \newenvironment, they are different: \newtheorem is specifically designed to define a particular kind of environment: theorem-like structures whereas \newenvironment allows you to define arbitrary environments.

A theorem-like structure is one that typically has a head (formed by a name and a number) and a body (the actual contents of the structure). Of course, you could define your theorem-like structures "from scratch" using \newenvironment, but \newtheorem makes a series of provisions so as to easily account for the different formatting elements which characterize such structures. For example, just by using

\newtheorem{theo}{Theorem}

and then

\begin{theo}
Theorem text.
\end{theo}

you'll get a head with automatic numbering in bold-faced font and the body will be typeset using italics. Additionally, the environments defined using \newtheorem have an optional argument which allows you to specify a name (or an annotation) for your theorem. Take a look at the following example:

\documentclass{article}

\newtheorem{theo}{Theorem}

\begin{document}

\begin{theo}
Theorem text.
\end{theo}

\begin{theo}[Fundamental theorem of algebra]
Theorem text.
\end{theo}

\end{document}

enter image description here

There's a number of packages extending the functionality of the kernel's \newthereom command; the most popular ones are:

The answers to Theorem packages: which to use, which conflict? show a nice comparison between those packages.

Regarding the syntactical aspects, in this answer to Understanding the arguments in newtheorem e.g. \newtheorem{theorem}{Theorem}[section], barbara beeton has explained the syntax for \newtheorem; a similar explanation can be found in this other answer to Using \newtheorem; an explanation for the syntax for \newenvironment can be found in this answer to What is the purpose of putting \newenvironment, \newcounter in a document class?.

2
  • There is a typo in the first line ;-) "x similar to x"
    – daleif
    Commented Aug 9, 2014 at 17:25
  • @barbarabeeton I've added a possible link to an answer giving the explanation. Commented Aug 9, 2014 at 18:32

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .