I want the numbering of definition, lemma and theorem has the form x.y,where x is the chapter and y represents the natural order 1,2,3...I use a counter for the value of y.Here is my code, but something undesired happened. The counter start from 0 at each chapter automatically, however I want it starts from 1. What should I do to deal with this problem? Thanks!
\documentclass{book}
\newcounter{moon}[chapter]
\newtheorem{mydef}{Definition}
\renewcommand{\themydef}{\thechapter.\arabic{moon}}
\def\endmydef{\stepcounter{moon}}
\newtheorem{mylem}{Lemma}
\renewcommand{\themylem}{\thechapter.\arabic{moon}}
\def\endmylem{\stepcounter{moon}}
\newtheorem{mythm}{Theorem}
\renewcommand{\themythm}{\thechapter.\arabic{moon}}
\def\endmythm{\stepcounter{moon}}
\begin{document}
\chapter{AlaAla...}
\begin{mydef}
something
\end{mydef}
\begin{mylem}
something
\end{mylem}
\begin{mythm}
something
\end{mythm}
\chapter{BlaBla...}
\begin{mydef}
something
\end{mydef}
\begin{mylem}
something
\end{mylem}
\begin{mythm}
something
\end{mythm}
\end{document}



amsthmpackage and then this answer. – May 09 '18 at 00:53