單一項目使用多個數字(以逗號分隔)進行枚舉

單一項目使用多個數字(以逗號分隔)進行枚舉

我想要一個看起來像這樣的清單:

1. Text addressing #1.

2,3. Text addressing #2 and #3 together.

4. Text addressing #4.

動機是列表項引用先前的列表。關於如何透過枚舉輕鬆做到這一點有什麼想法嗎? (或其他一些看起來與枚舉環境一致的方法,即如果我在其上方有一個枚舉列表,那麼除了 2,3 部分之外,兩者的格式似乎相同......)

答案1

如果您不需要更大的通用性,這可能會起作用:

\documentclass{article}
\newcommand{\doubleitem}{%
  \begingroup
  \stepcounter{enumi}%
  \edef\tmp{\theenumi, }%
  \stepcounter{enumi}
  \edef\tmp{\endgroup\noexpand\item[\tmp\labelenumi]}%
  \tmp}

\begin{document}
\begin{enumerate}
\item A
\item B
\item C
\item D
\end{enumerate}
Another
\begin{enumerate}
\item about A
\doubleitem about B and C
\item D
\end{enumerate}
\end{document}

在此輸入影像描述

相關內容