1

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.
\begin{equation} a=b+c \end{equation}
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.
\begin{equation} d=e+f \end{equation}
This is item 1. This is item 1

\item[\bf 2.] This is item 2. This is item 2.This is item 2.
\begin{equation} g=h+i \end{equation}
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
  • 1
    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
4

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.
\begin{equation} a=b+c \end{equation}
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.
\begin{equation} d=e+f \end{equation}
This is item 1. This is item 1
\item This is item 2. This is item 2.This is item 2.
\begin{equation} g=h+i \end{equation}
This is item 2. This is item 2
\end{enumerate}
\end{document}

| improve this answer | |
  • 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
1

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

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

\begin{document}
\begin{enumerate}
\item test
\begin{equation} x=a \end{equation}
\begin{equation} x=b \end{equation}
\item test
\begin{equation} x=c \end{equation}
\begin{equation} x=d \end{equation}
\end{enumerate}
\end{document}
| improve this answer | |

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.