枚举中的数字方程

枚举中的数字方程

我如何才能让 begin{equation} 数字变成 (1.2) 这样的形式,其中 1 是当前枚举项,2 是方程式编号?

M(不)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

在此处输入图片描述

代码:

\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}

如果列表外需要“标准”编号:

\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}

相关内容