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.

I just noticed something weird of the \theoremstyle command. Here is the code of a sample document:

\documentclass{article}
\usepackage{amsthm}
\theoremstyle{plain}
\newtheorem{thm}{Theorem}[section]
\theoremstyle{definition}
\newtheorem{defn}{Definition}[section]
\theoremstyle{remark}
\newtheorem{case}{Case}
\begin{document}
\thm 1
\defn 2
\case 3
\thm 4
\end{document}

I expected the theorem after "Case" to behave like the first theorem, however the out put looks like this:

Output

Any explanation or solution? Am I using amsthm wrong?

share|improve this question
2  
The correct way to invoke a theorem is \begin{thm}...\end{thm}, not \thm. I don't know what specifications there are for using \thm as you did. –  Ari Brodsky Feb 10 '13 at 6:48
    
Thanks. I figured out the same thing. I wish there is some package that automatically make \thm as \begin{thm}#1\end{thm}. –  hyh Feb 10 '13 at 6:52
1  
Where should it put the \end{thm}, if you have no way to show where the theorem ends? –  Federico Poloni Feb 10 '13 at 8:46
1  
I think we can close this question, as it's just a small mistake of using environments as commands. –  Stefan Kottwitz Feb 10 '13 at 9:30
    
@FedericoPoloni I mean, something automatically provides \newcommand{\thm}[1]{\begin{thm}#1\end{thm}} when thm is defined as a newtheorem. –  hyh Feb 10 '13 at 17:27
add comment

1 Answer

up vote 5 down vote accepted

With \newtheorem{thm}{Theorem}[section] you are defining a thm environment that requires to be used as

\begin{thm}
A statement.
\end{thm}

The fact that \thm doesn't give errors is just because of the internal implementation of the \begin and \end commands, which shouldn't really be relied upon.

The \theoremstyle declaration uses the property of environments of being a group in the TeXnical sense: declarations inside them end their scope at the corresponding \end command.

When you do

\theoremstyle{remark}
\newtheorem{case}{Case}

in the preamble and have \begin{case} in your document, LaTeX performs some assignments such as stating that the "Case" label is typeset in italics. This is made by the internal \case macro (which you shouldn't be using). In this case no "end of scope" is seen and so the next instance of thm will inherit the font attributes of case for the label: being in the default plain style, \thm doesn't issue font declarations.

The \begin\end syntax is also much clearer, in my opinion: it gives visual clues in your input for finding things more easily. It's just a question of training and, maybe, of having a good text editor that inserts the \begin and \end tags with just a keystroke.

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