I wrote the following piece of code in order to define custom environments for propositions, corollaries, remarks, definitions, examples, lemmas,…etc .
\newcounter{mthm}
\newtheorem{mthmitalic}[mthm]{\mthmname}
\theoremstyle{definition}
\newtheorem{mthmroman}[mthm]{\mthmname}
\newcommand{\mthmname}{}
\newcommand{\varnewtheorem}[3]{%
\newenvironment{#1}[1]{%
\renewcommand{\mthmname}{#2}%
\renewcommand{\themthm}{##1}%
\csname mthm#3\endcsname
}{\csname endmthm#3\endcsname}%
}
\varnewtheorem{theorem}{Theorem}{italic}
\varnewtheorem{corollary}{Corollary}{italic}
\varnewtheorem{definition}{Definition}{roman}
\varnewtheorem{example}{Example}{roman}
\varnewtheorem{examples}{Examples}{roman}
\varnewtheorem{proposition}{Proposition}{italic}
\varnewtheorem{remark}{Remark}{roman}
Every environment (e.g, \begin{corollary}{num} \end{corollary}
) takes another argument for providing the numbering of the corollary or whatever. My questions is: can this piece of code be modified in order to provide a subsequent automatic numbering such that all environments are dependent on each other. This means that if I have a Definition 1 and a theorem after the definition, then the theorem is automatically labeled by 2.
I also want the modification to work properly whether there is a partitioning of the articles into sections and subsection or not.
I hope I revealed what I want to have pretty well.
Thanks in advanceز
Best Answer
That machinery was needed because you asked for manual numbering.
Automatic numbering works out of the box.
If you want the numbering to be independent of the sectios, just remove
[section]
from the first\newtheorem
declaration.