\environment 带参数的定义

\environment 带参数的定义

我四处寻找,但找不到以下问题的答案:我定义了环境 myroman,但使用失败。我不清楚为什么。%

\documentclass{scrartcl}
   \usepackage{enumitem}
  \newenvironment{myroman}[1][label=\roman*)]%
        {\begin{enumerate}[#1]}
        {\end{enumerate}}
        %
\begin{document}

\begin{myroman}
    \item First
    \item Second
\end{myroman}  

\begin{myroman}[resume*] % not working
   \item Third
   \item etc
\end{myroman}
        %
This is working:
        %
 \begin{enumerate}[label=\roman*)]
     \item one
      \item two
 \end{enumerate}

 \begin{enumerate}[resume*] 
    \item three
     \item four
  end{enumerate}

\结束{文档}

答案1

您应该为此定义一个新列表。

\documentclass{scrartcl}
\usepackage{enumitem}

\newlist{myroman}{enumerate}{1}
\setlist[myroman,1]{label=\roman*)}

\begin{document}

\begin{myroman}
\item First

\item Second
\end{myroman}  

\begin{myroman}[resume*]
\item Third

\item etc
\end{myroman}

\end{document}

在此处输入图片描述

相关内容