# How can I make the enumi counter follow another counter?

For example, in the MWE below, how can I label the items with the theorem counter?

\documentclass{article}

\usepackage{amsthm,thmtools,lipsum}

\declaretheorem[name=Theorem, numberwithin=section]{theorem}

\begin{document}

\section{First section}

\begin{theorem}
This is a theorem.
\end{theorem}
\lipsum[1]
\begin{enumerate}
\item The label of this item should be 1.2.
\item The label of this item should be 1.3.
\end{enumerate}

\end{document}

• Always? Or just for a specific enumerate? – Werner Jun 10 '15 at 18:15

You have to set the counter enumi to the value of theorem at the start and set theorem to the value of enumi at the end.

\documentclass{article}

\usepackage{amsthm,thmtools,enumitem,lipsum}

\declaretheorem[name=Theorem, numberwithin=section]{theorem}
{\enumerate[
label=\thesection.\arabic*,
before=\setcounter{enumi}{\value{theorem}},
after=\setcounter{theorem}{\value{enumi}},
]}
{\endenumerate}

\begin{document}

\section{First section}

\begin{theorem}
This is a theorem.
\end{theorem}
\lipsum[1]
\item The label of this item should be 1.2.
\item The label of this item should be 1.3.

\begin{theorem}
This is a theorem.
\end{theorem}
\lipsum[1]
\item The label of this item should be 1.5.
\item The label of this item should be 1.6.

\end{document}


You may want to change the formatting of the label so as to be consistent with that of theorems.

\documentclass{article}

\usepackage{amsthm,thmtools,enumitem,lipsum}

\declaretheorem[name=Theorem, numberwithin=section]{theorem}
{\enumerate[
leftmargin=*,
label=\bfseries\thesection.\arabic*.,
ref=\thesection.\arabic*,
before=\setcounter{enumi}{\value{theorem}},
after=\setcounter{theorem}{\value{enumi}},
]}
{\endenumerate}

\begin{document}

\section{First section}

\begin{theorem}
This is a theorem.
\end{theorem}
\lipsum[1]
\item The label of this item should be 1.2.
\item The label of this item should be 1.3.

\begin{theorem}
This is a theorem.
\end{theorem}
\lipsum[1]
\item The label of this item should be 1.5.
\item The label of this item should be 1.6.

\end{document}


• might it not be possible to define an environment that overrides or outmaneuvers the definition of \usecounter to not reset the counter to 0 at \begin? (would probably have to use a new counter, say \enumj.) or is that just too much trouble? – barbara beeton Jun 10 '15 at 18:28
• @barbarabeeton: Well, one could say, e.g., \enumerate[label=\thetheorem, before=\def\@listctr{theorem}] (which also works); but egreg’s solution is so straightforward… – GuM Jun 10 '15 at 19:08

Well, after all, I think I could give this code a chance:

\documentclass{article}

\usepackage{amsthm,thmtools,enumitem,lipsum}

\declaretheorem[name=Theorem, numberwithin=section]{theorem}
\makeatletter
{\enumerate[
label=\thetheorem,
before=\def\@listctr{theorem}
]}
{\endenumerate}
\makeatother

\begin{document}

\section{First section}

\begin{theorem}
This is a theorem.
\end{theorem}
\lipsum[1]
\item The label of this item should be 1.2.
\item The label of this item should be 1.3.

\begin{theorem}
This is a theorem.
\end{theorem}
\lipsum[1]