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}

1 Answer 1

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
    Commented Oct 22, 2016 at 11:00

You must log in to answer this question.

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