複数の定理に対して 1 つのカウンタですか?

複数の定理に対して 1 つのカウンタですか?

しばらくインターネットで検索しましたが、欲しいものがなかなか見つかりません。章や節によって異なる、同じカウンターを持つ異なる定理の数が欲しいのです。例えば、補題 1.1.1 例 1.1.2 証明 1.1.3... このようなカウンターを定義しようとしましたが、setcounter コマンドの \begin{document} が見つからないというエラーが表示されますが、ドキュメント内に入れても機能しません。

\documentclass[12pt]{report}

\newcounter{cnt}[section]
\newcounter{thmcount}    
\setcounter{thmcount}{\thechapter.\thesection.\thecnt}

\newtheorem{lem}{Lemma}[thmcount]
\newtheorem{eg}{Example}[thmcount]
\newtheorem{pro}{Proof}[thmcount]

\begin{document}

\chapter{abc}
\section{xyz}

\begin{lem}
asdf
\end{lem}

\begin{eg}
fdsa
\end{eg}

\begin{pro}
sdaf
\end{pro}

\end{document}

答え1

新しいカウンターを定義する必要はありません。

\documentclass[12pt]{report}

\newtheorem{lem}{Lemma}[section]
\newtheorem{eg}[lem]{Example}
\newtheorem{pro}[lem]{Proof}

\begin{document}

\chapter{abc}
\section{xyz}

\begin{lem}
asdf
\end{lem}

\begin{eg}
fdsa
\end{eg}

\begin{pro}
sdaf
\end{pro}

\end{document}

最初は\newtheoremと呼ばれる新しいカウンターlem( に関連付けられている) を設定し、その後、環境名の直後にオプションの引数としてsectionで作成された後続のすべての環境で共有されます。lem

関連情報