I wrote the following piece of code in order to define custom environments for propositions, corollaries, remarks, definitions, examples, lemmas,...etc .


\csname mthm#3\endcsname
 }{\csname endmthm#3\endcsname}%


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ز

  • 1
    Well, you just don't need that apparatus, which was devised because you wanted to do manual numbering.
    – egreg
    Feb 21, 2022 at 23:09

1 Answer 1


That machinery was needed because you asked for manual numbering.

Automatic numbering works out of the box.


% declare here other similar environments with text in italic

% from now on the defined environments will have the text in upright type




This is a definition of $X\ds Y$.

Let $M_R$ be a $C3$-module. If $M=X\s Y$ and $f:X\to Y$ is a homomorphism with 
$\ker f \ds X$, then $\im f \ds Y$.

An immediate consequence of Theorem \ref{theoremC3} is the following corollary.

Corollaries are easy.

And we can even give examples.

This is an example related to Corollary~\ref{corollaryeasy}


enter image description here

If you want the numbering to be independent of the sectios, just remove [section] from the first \newtheorem declaration.

  • There is a one single problem: How can I make the propositions and lemmas in italic? Feb 22, 2022 at 19:38
  • @HusseinEid The environments you declare before \theoremstyle{definition} will have the text in italics.
    – egreg
    Feb 22, 2022 at 22:33

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .