4

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

1 Answer 1

4

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.

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .