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 have a numbering system setup for most of my document using:

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

Which produces the obvious:

Theorem 1.1
Lemma 1.2
Theorem 1.3
Corollary 1.4
etc.

But I'm trying to halfway through the document redefine all the above to look at subsection and not just section:

Theorem 2.1.1
Corollary 2.1.2
Theorem 2.1.3
Lemma 2.1.4
Theorem 2.2.1
etc.

I can't seem to find a way to do that. Is it possible? I tried using the ntheorem package, but it seems to conflict with:

\newtheorem*{definition}{Definition}

and my other non-numbered stuff.

share|improve this question
    
At first guess, it seems a simple \renewcommand{\thetheorem}{\thesubsection.\arabic{theorem}} should suffice. –  Werner Dec 9 '13 at 20:54
    
I tried that, but that makes the final item Theorem 2.2.5 instead of Theorem 2.2.1 But I guess I can reset the counter between each section... just seems a hassle, unless that's the only way? –  Aram Papazian Dec 9 '13 at 20:58
    
...aaahh, you need to reset theorem after every subsection (with an \@addtoreset or using chngcntr). –  Werner Dec 9 '13 at 21:17
    
Perfect! Can you add that as an answer so I can accept it? That's exactly what I was looking for =) –  Aram Papazian Dec 9 '13 at 21:50

3 Answers 3

up vote 1 down vote accepted

Issue

\makeatletter
\renewcommand{\thetheorem}{\thesubsection.\arabic{theorem}}% Update counter printing
\@addtoreset{theorem}{subsection}% Reset theorem counter with every new subsection
\makeatother

before starting the new \subsection from where you want to have the renumbering occur.

enter image description here

\documentclass{article}

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

\begin{document}

\section{First}

\subsection{first}

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

\begin{theorem}
$2+2=4$.
\end{theorem}

\makeatletter
\renewcommand{\thetheorem}{\thesubsection.\arabic{theorem}}% Update counter printing
\@addtoreset{theorem}{subsection}% Reset theorem counter with every new subsection
\makeatother

\subsection{second}

\begin{theorem}
$3+2=5$.
\end{theorem}

\end{document}
share|improve this answer

I don't think this is a good idea. I hope you don't want to go back to the first enumeration style.

\documentclass{article}
\usepackage{chngcntr}

\begin{document}

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

\section{First}

\subsection{first}

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

\begin{theorem}
$2+2=4$.
\end{theorem}

\subsection{second}
\counterwithin{theorem}{subsection}
\setcounter{theorem}{0}

\begin{theorem}
$3+2=5$.
\end{theorem}

\end{document}

enter image description here

share|improve this answer

If you don't need continuous numbering of the last part, as in your example, probably a new newtheorem will be the simplest solution.

\documentclass{article}

\begin{document}


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

\section{First}

\subsection{first}

\begin{theorem}
2+2=4.
\end{theorem}

\subsection{second}

\newtheorem{theo}{Theorem}[subsection]

\begin{theo}
2+2=4.
\end{theo}

\end{document}

enter image description here

share|improve this answer
    
Yes, but that would require redefining all of my definitions which rely on my theorem counter. (I only showed 3 for simplicity but I have around 20 and feel like it would be unnecessarily bloaty if it can't be done another way) –  Aram Papazian Dec 9 '13 at 21:03

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.