5

How can I get begin{equation} numbers to be of the form (1.2), where 1 is the current enumerate item, and 2 is the equation number?

M(not)WE:

\documentclass[]{article}
\usepackage{amsmath}
\usepackage{enumitem}
\begin{document}

\begin{enumerate}
    \item Label these (1.1), (1.2)
    \begin{equation}
        x = 3
    \end{equation}

    \begin{equation}
        y = 4
    \end{equation}

    \item These should be labelled (2.1), (2.2)
    \begin{equation}
        x = 3
    \end{equation}

    \begin{equation}
        y = 4
    \end{equation}
\end{enumerate}

\end{document}
7

enter image description here

The code:

\documentclass[]{article}
\usepackage{amsmath}
\usepackage{chngcntr}
\usepackage{enumitem}

\setlist[enumerate,1]{before=\renewcommand\theequation{\theenumi.\arabic{equation}}
}

\counterwithin{equation}{enumi}

\begin{document}

\begin{enumerate}
    \item Label these (1.1), (1.2)
    \begin{equation}
        x = 3
    \end{equation}

    \begin{equation}
        y = 4
    \end{equation}

    \item These should be labelled (2.1), (2.2)
    \begin{equation}
        x = 3
    \end{equation}

    \begin{equation}
        y = 4
    \end{equation}
\end{enumerate}

\end{document}

If "standard" numbering is required outside the list:

\documentclass[]{article}
\usepackage{amsmath}
\usepackage{chngcntr}
\usepackage{enumitem}
\usepackage{etoolbox}

\let\oldtheequation\theequation
\setlist[enumerate,1]{before=\renewcommand\theequation{\theenumi.\arabic{equation}}}
\AfterEndEnvironment{enumerate}{\renewcommand\theequation{\oldtheequation}}

\counterwithin{equation}{enumi}

\begin{document}

\begin{enumerate}
    \item Label these (1.1), (1.2)
    \begin{equation}
        x = 3
    \end{equation}

    \begin{equation}
        y = 4
    \end{equation}

    \item These should be labelled (2.1), (2.2)
    \begin{equation}
        x = 3
    \end{equation}

    \begin{equation}
        y = 4
    \end{equation}
\end{enumerate}

   \begin{equation}
        x = 3
    \end{equation}

\end{document}
1
  • Could that be done to nested enumerate environments?
    – jfernandz
    Oct 22 '16 at 11:00

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.