# How to identify the counter of Equation, Theorem, and Section

I asked before how to identify the counter of Equation and Theorem. A simple answer suggested there is

\newtheorem{thm}[equation]{Theorem}


A simple variation allows me to identify the Theorem and Section counter:

\newtheorem{thm}[section]{Theorem}


Is there a way to identify all three counters, Equation, Theorem, and Section?

• At the moment I find this question difficult to understand without a similar example to the referenced question. Do you want the Theorem to be number consecutively with the equation and section numbers? As in (say) Sec1, Eq2, Thm3, Thm4, Sec5, Thm6, Eq7, ...? I guess I'm not sure what "identifying a counter" means. – Werner Jan 16 '12 at 20:36
• You probably want to take a look at \numberwithin (GIYF) – kahen Jan 16 '12 at 20:39
• While the idea of equations and theorems sharing one counter is at least debatable, making these structures share one counter with sectioning elements is bound to confuse the reader. Don't do it. – lockstep Jan 16 '12 at 20:43

The TeX primitive \let allows you to identify control sequences. LaTeX counters are implemented by TeX count registers; the LaTeX command \newcounter{foo} creates a TeX counter \c@foo.

So you just need to make sure that the count registers for equation, section, and theorem are the same! LaTeX's \newtheorem command provides the functionality to make the theorem counter identical to the section counter. Use a \let to let the equation and section counters be the same.

\documentclass{article}
\newtheorem{thm}[section]{Theorem}
\makeatletter
\let\c@equation\c@section
\makeatother
\begin{document}

\section{First Section}

\begin{equation}
e = q^{uation}
\end{equation}

\begin{thm}
Ceci n'est pas une th\'eorem.
\end{thm}

\section{Second Section}

\end{document}

• Your solution doesn't require amsmath. – lockstep Jan 16 '12 at 20:45
• @lockstep: I'll be darned, you are correct. For some reason I thought \newtheorem was part of the AMS bundle of packages. – Matthew Leingang Jan 17 '12 at 17:56

I found an elegant solution for this problem. It is a variation of the answer to a similar question. Put the following in the preamble:

\newtheorem{thm}[section]{Theorem}
\makeatletter
\let\c@equation\c@section
\makeatother