使用枚举中的键值到另一个键值

使用枚举中的键值到另一个键值

这是Enumitem \SetEnumitemKey 与前后多个键之间发生冲突

我想在另一个列表的定义中使用列表中的键值。这里我使用了 \Pointilles 的更好定义,它允许第二个参数,即点之间的垂直空间。

因此我用此代码代替旧代码:

\usepackage{xargs}  
\newcommand{\auxpts}[1]{\makebox[\linewidth]{\dotfill} #1}
% Pointilles
\newcommandx{\Pointilles}[2][1=1,2=\bigbreak]{%
    \vspace*{-\medskipamount}
    \multido{\i=1+1}{#1}{%
        \auxpts{#2}
    }
}

并将每次出现的 替换\Pointilles{#1}\Pointilles[#1],并将替换\Pointilles{2}\Pointilles[2]

最终代码如下:

\documentclass[twocolumn]{article}
\usepackage[a4paper, top=0.5cm, bottom=1.6cm, left=0.7cm , right=0.7cm]{geometry}
\parindent0cm
\usepackage{multido}
\usepackage{enumitem}
\usepackage{multicol}
\usepackage{xargs}

\newcommand{\auxpts}[1]{\makebox[\linewidth]{\dotfill} #1}
% Pointilles
\newcommandx{\Pointilles}[2][1=1,2=\bigbreak]{%
    \vspace*{-\medskipamount}
    \multido{\i=1+1}{#1}{%
        \auxpts{#2}
    }
}

\newlist{innanswers}{enumerate}{1}
\setlist[innanswers]{
  label=\arabic*.,
  before=\maybemulticols\maybedots,
  after=\maybefinaldots\maybeendmulticols
}
\newenvironment{answers}[1][]
 {\setkeys{m45}{#1}\innanswers}
 {\endinnanswers}

\let\maybemulticols=\relax
\let\maybeendmulticols=\relax
\let\maybedots=\relax
\let\maybefinaldots=\relax
\def\doitemdots#1{%
  \let\olditem\item% save the standard definition of \item in a macro, \olditem
  \firstItemtrue% set the toggle for first item in the list to true
  \def\item{%
    \iffirstItem
      \olditem\firstItemfalse
    \else
      \newline\Pointilles[#1][\bigbreak]\mbox{}\olditem %TODO here need to replace \bigbreak by the value of a parameter
   \fi
  }% new, temporary defition of \item
}
\def\dofinaldots#1{%
  \ \newline \Pointilles[#1][\bigbreak]\mbox{} %TODO here need to replace \bigbreak by the value of a parameter
}

\makeatletter
\define@key{m45}{cols}{%
  \def\maybemulticols{\begin{multicols}{#1}}%
  \def\maybeendmulticols{\end{multicols}}%
}
\newif\iffirstItem\firstItemfalse

\define@key{m45}{dots}{%
  \def\maybedots{\doitemdots{#1}}
  \def\maybefinaldots{\dofinaldots{#1}}
}
\makeatother
%==========================================
\begin{document}

\Pointilles[2]
\hrule
\begin{answers}[cols=4]
    \item first
    \item second
    \item third
    \item fourth
\end{answers}
\hrule
\begin{answers}[dots=2]
    \item first
    \item second
    \item third
    \item fourth
\end{answers}
\hrule
\begin{answers}[cols=2, dots=2]
    \item first
    \item second
    \item third
    \item fourth
\end{answers}
\hrule
\begin{answers}[dots=2, cols=2]
    \item first
    \item second
    \item third
    \item fourth
\end{answers}
\hrule
\end{document}

所以问题是:我该如何在列表中传递一个新的键值而不是默认值\bigbreak(两行匹配的值有一个%TODO)?

相关内容