3

I would like for equations to share the same counter as subsections. For example if my document is:

\documentclass{article}
\begin{document}
\section{A}
\begin{equation} 1+1=2 \end{equation}
\subsection{X}
\begin{equation} 1+1=2 \end{equation}
\begin{equation} 1+1=2 \end{equation}
\subsection{Y}
\begin{equation} 1+1=2 \end{equation}
\end{document}

I would like this output (produced here through a sneaky use of \tag): enter image description here

Something similar to how theorems of amsthm can be "siblings" with another counter. I am aware of the \numberwithin command of amsmath, but this is not what I want. I am also aware of the aliascnt package, but since "equation" is an existing counter, it doesn't work.

1 Answer 1

7

I hope, this is what you want:

\documentclass{article}
\pagestyle{empty}% for cropping
\makeatletter
\let\c@equation=\c@subsection
\let\theequation=\thesubsection
\makeatother
\begin{document}
\section{A}
\begin{equation}
    1+1=2
\end{equation}
\subsection{X}
\begin{equation}
    1+1=2
\end{equation}
\begin{equation}
    1+1=2
\end{equation}
\subsection{Y}
\begin{equation}
    1+1=2
\end{equation}
\end{document}

enter image description here

4
  • No, this is not what I want, sorry. I'm going to include a picture of the output I'd like in my question. Mar 6, 2014 at 16:05
  • @nik See my updated answer. Mar 6, 2014 at 16:18
  • That's perfect, thank you. (Do you have a reference on how this works? I guess \stepcounter and the like work internally on \c@counter?) Mar 6, 2014 at 16:20
  • @nik Your explanation is already pretty accurate. \c@counter is the TeX count register the value of the counter is stored in, \thecounter just outputs the value of that count register. Mar 6, 2014 at 16:23

You must log in to answer this question.

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