# How to number equations as (item-num.number-in-item)

I would like to number equations in items in this form: (item-num.number-in-item) where item-num is the item number (first item is 1, second item is 2) and number-in-item is the number within an item. When entering a new item, the number-in-item is automatically reset to 0. For example, for latex code:

\begin{itemize}
\item[\bf 1.] This is item 1. This is item 1.
$$a=b+c$$
This is item 1. This is item 1.This is item 1. This is item 1.This is item 1. This is item 1.This is item 1. This is item 1.This is item 1. This is item 1.
$$d=e+f$$
This is item 1. This is item 1

\item[\bf 2.] This is item 2. This is item 2.This is item 2.
$$g=h+i$$
This is item 2. This is item 2
\end{itemize}


, the output should be:

1. This is item 1. This is item 1.

         a=b+c            (1.1)


This is item 1. This is item 1.This is item 1. This is item 1.This is item 1. This is item 1.This is item 1. This is item 1.This is item 1. This is item 1.

         d=e+f            (1.2)


2. This is item 2. This is item 2.This is item 2.

         g=h+i            (2.1)


This is item 2. This is item 2

How to write latex to realize such a numbering? Thank you.

• Normally the item number is \thenumi, but that depends on which packages you add. One can reset the equation number using \@addtoreset{equation}{enumi} and redefine \theequation or just use \tag. – John Kormylo Feb 13 at 4:23
• @John Kormylo: I was told "! Undefined control sequence." Which package is \thenumi in? – user5280911 Feb 13 at 4:31
• itemize doesn't assign item numbers; enumerate does assign numbers. This would likely be easier with the enumitem package. – barbara beeton Feb 13 at 4:52
• @barbara beeton: I changed to enumerate and added \usepackage{enumitem} and \renewcommand{\theequation}{\theenumi.\arabic{equation}}, but it does not work. – user5280911 Feb 13 at 5:05

You can use the \numberwithin command from amsmath to number the equation counter within the enumi counter, which is the counter from the items in the enumerate environment. For example,

\documentclass{article}
\usepackage{amsmath}
\usepackage{enumitem}
\numberwithin{equation}{enumi}
\begin{document}
\begin{enumerate}[label={\bfseries\arabic*.}, ref=\arabic*]
\item This is item 1. This is item 1.
$$a=b+c$$
This is item 1. This is item 1.This is item 1. This is item 1.This is item 1. This is item 1.This is item 1. This is item 1.This is item 1. This is item 1.
$$d=e+f$$
This is item 1. This is item 1
\item This is item 2. This is item 2.This is item 2.
$$g=h+i$$
This is item 2. This is item 2
\end{enumerate}
\end{document}


• Thank you, Vincent. I noticed that you removed [\bf 1.], [\bf 2.]. Is there any way to make the item number bold (but the item-num in equation number is not bold)? – user5280911 Feb 13 at 5:45
• Yes of course! It can be done using the great enumitem package. Sorry, I wanted to include that at first, but I guess I forgot. – Vincent Feb 13 at 6:15
• Thank you so much! – user5280911 Feb 13 at 6:28

Except for itemize not being numbered, everything worked fine. No packages needed.

\documentclass{article}
\makeatletter
\makeatother
\renewcommand{\theequation}{\theenumi.\arabic{equation}}

\begin{document}
\begin{enumerate}
\item test
$$x=a$$
$$x=b$$
\item test
$$x=c$$
$$x=d$$
\end{enumerate}
\end{document}