3

I searched the internet for a while now but didn't quite get what i wanted. I want number different theorems with the same counter, which depends on chapter and section. eg Lemma 1.1.1 Example 1.1.2 Proof 1.1.3... I tried to define a counter like this but i get an error which says missing \begin{document} for the setcounter command but when i put it inside the document it doesn't work neither.

\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
    Use \newtheorem{lem}{Lemma}[section] and then for the others \newtheorem{theo}[lem]{Theorem} so they follow the counter lem. – Sigur May 1 '15 at 10:01
  • For proofs, you can use \begin{proof}\end{proof} from amsmath package. – Sigur May 1 '15 at 10:04
3

There's no need to define a new counter:

\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}

The first \newtheorem sets up a new counter called lem (tied to section) that then is shared by all subsequent environments created with lem as optional argument just after the environment's name.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.