[Tex/LaTex] No “theorem” counter defined in ntheorem

countersntheoremtheorems

Here is my MWE:

\documentclass[12pt,a4paper,oneside]{report}
\usepackage[left=2.00cm,right=2.00cm,top=2.45cm,bottom=2.5cm]{geometry}
\usepackage{amsmath,amssymb,amscd,color,enumitem}
\usepackage{fancyhdr,framed,latexsym,multicol,pstricks,slashed,xcolor}
\usepackage[amsmath,framed,thmmarks]{ntheorem}
\pagestyle{fancy}

\renewcommand{\chaptermark}[1]{\markboth{#1}{}}
\renewcommand{\sectionmark}[1]{\markright{#1}{}}
\lhead{\leftmark}
\rhead{\rightmark}
\cfoot{\thepage}
\renewcommand{\qed}{\qedsymbol{\blacksquare}}

\theoremstyle{marginbreak}
\theoremheaderfont{\normalfont\bfseries}\theorembodyfont{\slshape}
\theoremsymbol{\ensuremath{\diamondsuit}}
\theoremseparator{:}
\newtheorem{thm}{Theorem}[Theorem]

\theoremstyle{changebreak}
\theoremsymbol{\ensuremath{\heartsuit}}
\theoremindent0.5cm
\theoremnumbering{greek}
\newtheorem{lem}{Lemma}

\theoremindent0cm
\theoremsymbol{\ensuremath{\spadesuit}}
\theoremnumbering{arabic}
\newtheorem{cor}[thm]{Corollary}

\theoremstyle{change}
\theorembodyfont{\upshape}
\theoremsymbol{\ensuremath{\ast}}
\theoremseparator{}
\newtheorem{exm}{Example}

\theoremstyle{plain}
\theoremsymbol{\ensuremath{\clubsuit}}
\theoremseparator{.}
\theoremprework{\bigskip\hrule}
\theorempostwork{\hrule\bigskip}
\newtheorem{defn}{Definition}

\theoremheaderfont{\sc}\theorembodyfont{\upshape}
\theoremstyle{nonumberplain}
\theoremseparator{}
\theoremsymbol{\rule{1ex}{1ex}}
\newtheorem{proof}{Proof}

\theoremstyle{change}
\theorembodyfont{\upshape}
\theoremsymbol{\ensuremath{\ast}}
\theoremseparator{}
\newtheorem{rem}{Remark}

\theoremclass{Theorem}
\theoremstyle{break}
\theoreminframepreskip{0pt}
\theoreminframepostskip{0pt}
\theoremframepreskip{1cm}
\theoremframepostskip{1cm}
\theoremstyle{break}
\def\theoremframecommand{%
\psshadowbox[fillstyle=solid,fillcolor=blue,linecolor=black]}
\newshadedtheorem{sthm}[Theorem]{Theorem}

\theoremclass{Proof}
\theoremstyle{nonumberbreak}
\shadecolor{red}
\def\theoremframecommand{%
\psshadowbox[fillstyle=solid,fillcolor=red,linecolor=black]}
\theoremsymbol{\rule{1ex}{1ex}}
\newshadedtheorem{sproof}{Proof}

\title{Calculus Notes}
\author{}
\date{\today}
\begin{document}
\maketitle

chapter{Limits}
\begin{sthm}[Basic Limits]
    Let $b$ and $k \in \mathbb{R}$ and let $n$ be a positive integer. Then:
        \begin{enumerate}
            \item $\lim\limits_{x\to c}k=c$
            \item $\lim\limits_{x\to c}x=c$
            \item $\lim\limits_{x\to c}x^n=c^n$
        \end{enumerate}
\end{sthm}
\end{document}

For the thm and sthm I keep getting the error:

No counter "theorem" defined. 

If I try and add exam, defn, proof, arem, and sproof so far they are fine. But for thm and sthm I keep getting that error. I have tried adding the following line above my definition of theorem:

\newtheorem{Theorem}{Thm}

which results in a full compile without any errors, but without the theorem environment and no shading whatsoever. Any help would be appreciated. Thanks!

Best Answer

The syntax for \newtheorem has three forms

\newtheorem{<envname>}{<tag>}

\newtheorem{<envname>}{<tag>}[<within>]

\newtheorem{<envname>}[<share>]{<tag>}

With \newtheorem{foo}{Bar} you're defining an environment that is numbered independently of anything else. With

\newtheorem{foo}{Bar}[section]

you define an environment that's numbered like 1.1, 1.2, 2.1 and so on, where the first number is the section number and the second pertains to the specific foo environment; the <within> part should be the name of an existing counter. With

\newtheorem{foo}[baz]{Bar}

the environment will share the numbering with the already defined baz environment (which should have been defined in one of the previous ways). The \newshadedtheorem command has the same properties.

In your code you're using [Theorem] that corresponds to no previously defined environment or counter.

The following code fixes the obvious errors, but you should rethink the numbering system (it's not clear why corollaries share the thm counter, but lemmas don't, for instance).

Of course, due to pstricks, the document has to be compiled with the latex+dvips+ps2pdf route, which I do with arara.

% arara: latex
% arara: dvips
% arara: ps2pdf

\documentclass[12pt,a4paper,oneside]{report}
\usepackage[left=2.00cm,right=2.00cm,top=2.45cm,bottom=2.5cm]{geometry}
\usepackage{amsmath,amssymb,amscd,color,enumitem}
\usepackage{fancyhdr,framed,latexsym,multicol,pstricks,slashed,xcolor}
\usepackage[amsmath,framed,thmmarks]{ntheorem}
\pagestyle{fancy}

\renewcommand{\chaptermark}[1]{\markboth{#1}{}}
\renewcommand{\sectionmark}[1]{\markright{#1}{}}
\lhead{\leftmark}
\rhead{\rightmark}
\cfoot{\thepage}
\renewcommand{\qed}{\qedsymbol{\blacksquare}}

\theoremstyle{marginbreak}
\theoremheaderfont{\normalfont\bfseries}\theorembodyfont{\slshape}
\theoremsymbol{\ensuremath{\diamondsuit}}
\theoremseparator{:}
\newtheorem{thm}{Theorem}

\theoremstyle{changebreak}
\theoremsymbol{\ensuremath{\heartsuit}}
\theoremindent0.5cm
\theoremnumbering{greek}
\newtheorem{lem}{Lemma}

\theoremindent0cm
\theoremsymbol{\ensuremath{\spadesuit}}
\theoremnumbering{arabic}
\newtheorem{cor}[thm]{Corollary}

\theoremstyle{change}
\theorembodyfont{\upshape}
\theoremsymbol{\ensuremath{\ast}}
\theoremseparator{}
\newtheorem{exm}{Example}

\theoremstyle{plain}
\theoremsymbol{\ensuremath{\clubsuit}}
\theoremseparator{.}
\theoremprework{\bigskip\hrule}
\theorempostwork{\hrule\bigskip}
\newtheorem{defn}{Definition}

\theoremheaderfont{\sc}\theorembodyfont{\upshape}
\theoremstyle{nonumberplain}
\theoremseparator{}
\theoremsymbol{\rule{1ex}{1ex}}
\newtheorem{proof}{Proof}

\theoremstyle{change}
\theorembodyfont{\upshape}
\theoremsymbol{\ensuremath{\ast}}
\theoremseparator{}
\newtheorem{rem}{Remark}

\theoremclass{Theorem}
\theoremstyle{break}
\theoreminframepreskip{0pt}
\theoreminframepostskip{0pt}
\theoremframepreskip{1cm}
\theoremframepostskip{1cm}
\theoremstyle{break}
\def\theoremframecommand{%
\psshadowbox[fillstyle=solid,fillcolor=blue,linecolor=black]}
\newshadedtheorem{sthm}[thm]{Theorem}

\theoremclass{Proof}
\theoremstyle{nonumberbreak}
\shadecolor{red}
\def\theoremframecommand{%
\psshadowbox[fillstyle=solid,fillcolor=red,linecolor=black]}
\theoremsymbol{\rule{1ex}{1ex}}
\newshadedtheorem{sproof}{Proof}

\title{Calculus Notes}
\author{}
\date{\today}
\begin{document}
\maketitle

\chapter{Limits}
\begin{sthm}[Basic Limits]
    Let $b$ and $k \in \mathbb{R}$ and let $n$ be a positive integer. Then:
        \begin{enumerate}
            \item $\lim\limits_{x\to c}k=c$
            \item $\lim\limits_{x\to c}x=c$
            \item $\lim\limits_{x\to c}x^n=c^n$
        \end{enumerate}
\end{sthm}
\end{document}

enter image description here

Related Question