为什么 enumitem 包的 resume 键不起作用

为什么 enumitem 包的 resume 键不起作用

resume当我的enumerated 列表包含在单独的环境中时,如何使密钥起作用multicol

这是不起作用的代码:

\documentclass{article}
\usepackage{multicol}
\usepackage{enumitem}
\newlist{problem}{enumerate}{1}
\setlist[problem,1]{label={\bfseries\arabic{problemi}.},leftmargin=*,resume}
\def\remembered[#1]{\typeout{Call #1:\arabic{problemi}}}
\pagestyle{empty}
\begin{document}

Random content
\begin{multicols}{2}
\begin{problem}
\item something
\end{problem}
\end{multicols}
\remembered[First]

more content
\begin{multicols}{3}
\remembered[Inside 2nd]
\begin{problem}
\item something
\item something
\item something
\item something
\item something
\item something
\item something
\item something
\item something
\end{problem}
\end{multicols}
\remembered[Outside second]

more content
\begin{multicols}{3}
\remembered[Inside 3rd]
\begin{problem}
\item something
\item something
\item something
\item something
\item something
\end{problem}
\end{multicols}
\remembered[Outside 4th]

\end{document}

\remember命令似乎表明计数器的值未被环境本地化multicols。那么,为什么找不到resume正确的值来恢复呢?

没有multicols环境一切都按预期进行:

\documentclass{article}
\usepackage{multicol}
\usepackage{enumitem}
\newlist{problem}{enumerate}{1}
\setlist[problem,1]{label={\bfseries\arabic{problemi}.},leftmargin=*,resume}
\def\remembered{\typeout{\arabic{problemi}}\par I remember: \arabic{problemi}}
\pagestyle{empty}
\begin{document}

Random content
\begin{problem}
\item something
\end{problem}
\remembered[First]

more content
\remembered[Inside 2nd]
\begin{problem}
\item something
\item something
\item something
\item something
\item something
\item something
\item something
\item something
\item something
\end{problem}
\remembered[Outside second]

more content
\remembered[Inside 3rd]
\begin{problem}
\item something
\item something
\item something
\item something
\item something
\end{problem}
\remembered[Outside 4th]

\end{document}

答案1

resume它在局部起作用,因此它无法在类似群组multicols或任何其他环境中存活。您需要使用series来保持全局效果:

\documentclass{article}
\usepackage{multicol}
\usepackage{enumitem}
\newlist{problem}{enumerate}{1}
\setlist[problem,1]{label={\bfseries\arabic{problemi}.},leftmargin=*,resume=problem}
\def\remembered[#1]{\typeout{Call #1:\arabic{problemi}}}
\pagestyle{empty}
\begin{document}

Random content
\begin{multicols}{2}
\begin{problem}
\item something
\end{problem}
\end{multicols}
\remembered[First]

more content
\begin{multicols}{3}
\remembered[Inside 2nd]
\begin{problem}
\item something
\item something
\item something
\item something
\item something
\item something
\item something
\item something
\item something
\end{problem}
\end{multicols}
\remembered[Outside second]

more content
\begin{multicols}{3}
\remembered[Inside 3rd]
\begin{problem}
\item something
\item something
\item something
\item something
\item something
\end{problem}
\end{multicols}
\remembered[Outside 4th]

\end{document}

在此处输入图片描述

相关内容