여러 정리에 대한 하나의 카운터?

여러 정리에 대한 하나의 카운터?

나는 한동안 인터넷을 검색했지만 내가 원하는 것을 얻지 못했습니다. 나는 장과 섹션에 따라 동일한 카운터를 사용하여 여러 가지 정리를 원합니다. 예: Lemma 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이라는 새 카운터를 설정한 다음 환경 이름 바로 뒤에 선택적 인수 로 생성된 모든 후속 환경에서 공유됩니다 .lemsectionlem

관련 정보