
我在網路上搜尋了一段時間,但沒有完全得到我想要的東西。我想用相同的計數器對不同的定理進行編號,這取決於章節和章節。例如引理 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