5

I have declared \newtheorem{thm}{Theorem} \numberwithin{thm}{subsection}. This numbers every theorem in this format [chapter].[section].[subsection].[numberofthm]. Is it possible to have the counter just printing [numberofthm] instead?

  • 2
    You want to be mean to your readers. ;-) Your text will be full of “as we saw in Theorem 3 of subsection 2.9.42“. Just number them by section, uniquely throughout the document. – egreg Oct 31 '13 at 17:00
  • @egreg The OP's document features chapters. ;-) – lockstep Oct 31 '13 at 17:11
  • Haha, its my teachers fault, he does the numbering that way. But it should be Ok, because each subsection is pretty different. – flawr Oct 31 '13 at 18:29
  • I can't check what this does without a MWE, but you could try \renewcommand{\thethm}{\arabic{thm}} (after the two commands you did show us). – Dan Oct 31 '13 at 19:53
8

Use the chngcntr package and its \counterwithin* macro -- the starred version changes the parent counter, but does not add/remove prefixes.

\documentclass{book}

\usepackage{chngcntr}

\newtheorem{thm}{Theorem}
\counterwithin*{thm}{subsection} 

\begin{document}

\chapter{foo}

\section{foobar}

\subsection{foobargnu}

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

\begin{thm}
A second theorem.
\end{thm}

\subsection{foobargnat}

\begin{thm}
A third theorem.
\end{thm}

\end{document}

enter image description here

  • Thank you very much! That was exactly what i was looking for! – flawr Oct 31 '13 at 18:29
  • 2
    \newtheorem{thm}{Theorem}[subsection] and \renewcommand{\thethm}{\arabic{thm}} will do without any external package. – egreg Oct 31 '13 at 21:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.