Text Formattingamsthm | Theorem Counter Problem with Subsection

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
Post Reply
bkarpuz
Posts: 124
Joined: Thu Dec 18, 2008 4:53 pm

amsthm | Theorem Counter Problem with Subsection

Post by bkarpuz »

Dear LC members,

See my problem below.
I guess the last theorem should have the label Theorem 2.0.1 but it is not. How can I fix it?

Code: Select all

\documentclass[12pt]{article}
\usepackage{amsthm}

\theoremstyle{definition}
\newtheorem{theorem}{Theorem}[subsection]

\begin{document}
\section{Section}
\subsection{Subsection}
\begin{theorem}
--
\end{theorem}
\begin{theorem}
--
\end{theorem}
\subsection{Subsection}
\begin{theorem}
--
\end{theorem}
\begin{theorem}
--
\end{theorem}
\begin{theorem}
--
\end{theorem}
\begin{theorem}
--
\end{theorem}
\section{Section}
\begin{theorem}
{\Large Why not 2.0.1?}
\end{theorem}
\end{document}
I also have another question.
Is it possible to enumerate theorems as Theorem 1.1.1, Theorem 1.1.2 and so on in subsubsections but as Theorem 2.1 in section?


Thank you.
bkarpuz

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org
LaTeX Beginner's Guide LaTeX Cookbook LaTeX TikZ graphics TikZによるLaTeXグラフィックス
User avatar
justdeath
Posts: 69
Joined: Mon Sep 05, 2011 10:27 am

amsthm | Theorem Counter Problem with Subsection

Post by justdeath »

Because you have to reset the counter: \setcounter{theorem}{0}.

Code: Select all

\documentclass[12pt]{article}
\usepackage{amsthm}

\theoremstyle{definition}
\newtheorem{theorem}{Theorem}[subsection]

\begin{document}
\section{Section}
\subsection{Subsection}
\begin{theorem}
--
\end{theorem}
\section{Section}
\setcounter{theorem}{0}
\begin{theorem}
{\Large Why not 2.0.1?}
\end{theorem}

\end{document}
Nikolay
bkarpuz
Posts: 124
Joined: Thu Dec 18, 2008 4:53 pm

amsthm | Theorem Counter Problem with Subsection

Post by bkarpuz »

justdeath wrote:Because you have to reset the counter: \setcounter{theorem}{0}.

Code: Select all

\documentclass[12pt]{article}
\usepackage{amsthm}

\theoremstyle{definition}
\newtheorem{theorem}{Theorem}[subsection]

\begin{document}
\section{Section}
\subsection{Subsection}
\begin{theorem}
--
\end{theorem}
\section{Section}
\setcounter{theorem}{0}
\begin{theorem}
{\Large Why not 2.0.1?}
\end{theorem}

\end{document}
Nikolay
Thank you Nikolay for your answer.

I know it works when I reset it manually but it seems to be a problem of the package. I was asking for a general solution, which could be introduced in the preambles.

Thank you.
bkarpuz
User avatar
justdeath
Posts: 69
Joined: Mon Sep 05, 2011 10:27 am

amsthm | Theorem Counter Problem with Subsection

Post by justdeath »

Nope, not possible. Because the counter depends on subsections, meaining sections have no effect on it.

You can use this:

Code: Select all

\newtheorem{theorem}{Theorem}[section]
but it will not honour subsections.

Nikolay
Post Reply