[Tex/LaTex] Numbering align-environments

alignnumberingsectioning

I'm writing in the article class. The align-environments are being numbered continuously, but I want them to be numbered like "section.number in this section". How can I do that? ๐Ÿ™‚

Best Answer

Either use \numberwithin{equation}{section} from amsmath or mathtools or the chngcntr package (if more than this is needed, e.g. \counterwithout or the starred versions \counterwithin* etc.)

\documentclass{article}

\usepackage{chngcntr}

\usepackage{mathtools}
\counterwithin{equation}{section}


\begin{document}
\section{A section}
\begin{align}
  E &= mc^{2} \\
  E^2 &= p^{2}c^{2} + m^{2}c^{4}
\end{align}


\section{Another section}

\begin{align}
  E &= mc^{2} \\
  E^2 &= p^{2}c^{2} + m^{2}c^{4}
\end{align}

\counterwithout{equation}{section} % Remove the resetting by `section`

\section{Yet another section}

\begin{align}
  E &= mc^{2} \\
  E^2 &= p^{2}c^{2} + m^{2}c^{4}
\end{align}

\end{document}

enter image description here