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.

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

  • No, this is not what I want, sorry. I'm going to include a picture of the output I'd like in my question. – Najib Idrissi Mar 6 '14 at 16:05
  • @nik See my updated answer. – Henri Menke Mar 6 '14 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?) – Najib Idrissi Mar 6 '14 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. – Henri Menke Mar 6 '14 at 16:23

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.