MyList is an always resumed enumitem list:
\newlist{MyList}{enumerate}{2}
\setlist[MyList,1]{label={\arabic*.}, resume}% ALWAYS resumed
but seems to break if the first use of MyList is from within another environment (orange text). In the MWE, this environemnt adds a color to the list and then envokes \begin{MyList}:
\newenvironment{MyColoredList}[2][]{%
\color{#2}%
\begin{MyList}[#1]
}{%
\end{MyList}%
}%
But, the same environment used after the direct use of MyList seems fine (blue text):
Notes:
- The second level is not resumed and there is no issue with it. Thus I removed the code that was testing that part.
- My question is not how to color a list, but how to have it
resumenumbering when it is invoked from within an environment.
References:
Code:
\documentclass{article}
\usepackage{enumitem}
\usepackage{xcolor}
\newlist{MyList}{enumerate}{2}
\setlist[MyList,1]{label={\arabic.}, resume}% ALWAYS resumed
\setlist[MyList,2]{label={\alph)}}% NOT resumed
\newenvironment{MyColoredList}[2][]{%
\color{#2}%
\begin{MyList}[#1]
}{%
\end{MyList}%
}%
\begin{document}
\begin{MyColoredList}{red}
\item First Item
\end{MyColoredList}
Some text
\begin{MyColoredList}{orange}% <--- This should be number 2
\item First Item
\end{MyColoredList}
Some text
\begin{MyList}% <--- This should be number 3
\item Second Item
\end{MyList}
Some text
\begin{MyList}
\item Third Item
\end{MyList}
Some text
\begin{MyColoredList}{blue}
\item Fourth Item (this works!!)
\end{MyColoredList}
\end{document}




resumeoption is local only, for global resume (i.e. settings that survive groups) you should theresume*option or even theserieskey – Apr 23 '17 at 08:27