[Tex/LaTex] Difference between \begin{theorem}…\end{theorem} and {\theorem …}

environmentstheorems

I see that both attempts to display a theorem in the following code generates similar output.

\documentclass{article}
\usepackage{amsthm}
\newtheorem{theorem}{Theorem}
\begin{document}

\begin{theorem}
\( (a + b)^2 = a^2 + 2ab + b^2 \)
\end{theorem}

{
\theorem
\( (a + b)^2 = a^2 + 2ab + b^2 \)
}
\end{document}

I want to know what the difference between \begin{theorem}...\end{theorem} and {\theorem ...} is.

Best Answer

Assume foo is some environment; with

\begin{foo}

LaTeX does some bookkeping, opens a group and expands the macro

\foo

With

\end{foo}

some check are performed, \endfoo is expanded and the group is closed.

In the case of theorem, we can test

\show\theorem
\show\endtheorem

which gives

> \theorem=macro:
->\@thm {\let \thm@swap \@gobble \th@plain }{theorem}{Theorem}.

> \endtheorem=macro:
->\endtrivlist \@endpefalse .

It may seem that \endtheorem is no big deal; but let's see what \endtrivlist means:

> \endtrivlist=macro:
->\if@inlabel \leavevmode \global \@inlabelfalse \fi \if@newlist
\@noitemerr \global \@newlistfalse \fi \ifhmode \unskip \par \else 
\@inmatherr {\end {\@currenvir }}\fi \if@noparlist \else \ifdim
\lastskip >\z@ \@tempskipa \lastskip \vskip -\lastskip \advance
\@tempskipa \parskip \advance \@tempskipa -\@outerparskip \vskip
\@tempskipa \fi \@endparenv \fi .

So you're missing several things if you omit \end{theorem}.

Perhaps, in the case of theorem not much is missed, but only getting "similar" output doesn't guarantee that, maybe some pages later, something goes awry. The most striking aspect in the particular case is that the vertical spacing after the statement will be wrong, even if you leave an empty line after the closing brace.

This practice is definitely not recommendable: some environments do the bulk of their work exactly at \end...; others do almost nothing at that stage. One should know in depth what every environment does.

Finally, the {\theorem ...} syntax is clumsy.