2

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?

user11126
  • 629
  • 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
  • 3
    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

2 Answers2

4

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}
Matthew Leingang
  • 44,937
  • 14
  • 131
  • 195
2

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
user11126
  • 629