隐藏特定 \item

隐藏特定 \item

我有数千个数学任务,有时由几个子问题组成。子任务在\enumerate带有 的环境中分开\item。我希望能够使用\item以下宏隐藏单个子任务

\long\def\itema#1\itemb{%
    \ifthenelse{\boolean{Aufgabea}}{\item#1\itemb}{\itemb}}

\long\def\itemb#1\itemc{%
\ifthenelse{\boolean{Aufgabeb}}{\item#1\itemc}{\itemc}}

\long\def\itemc#1\end{%
    \ifthenelse{\boolean{Aufgabec}}{\item#1\end}{\end}}

示例代码:

\documentclass{article}


\usepackage{ifthen}
\newboolean{Taska}
\setboolean{Taska}{false}
\newboolean{Taskb}
\setboolean{Taskb}{true}
\newboolean{Taskc}
\setboolean{Taskc}{false}

\long\def\itema#1\itemb{%
    \ifthenelse{\boolean{Taska}}{\item#1\itemb}{\itemb}}

\long\def\itemb#1\itemc{%
\ifthenelse{\boolean{Taskb}}{\item#1\itemc}{\itemc}}

\long\def\itemc#1\end{%
    \ifthenelse{\boolean{Taskc}}{\item#1\end}{\end}}

\begin{document}
    
    \begin{enumerate}
        \itema itema 
        \itemb itemb
        \itemc itemc
        
    \end{enumerate}

    
\end{document}

我的问题是,如果一个任务仅包含两个\item命令(\itema\itemb),它就不起作用。我必须以某种方式添加到\itema, \itemb ..宏中,使它们可以以下一个命令\item或以结束,\end但我不知道该怎么做。如果宏保持这种风格就好了。

答案1

我不确定我是否明白你想要什么。尝试打包dbshow以使用标签过滤问题。

在此处输入图片描述

\documentclass{article}
\usepackage{dbshow}

\dbNewDatabase{math}{labels=clist, ques=tl}
\begin{dbFilters}{math}
  \dbNewConditional{select}{labels}{label-a, label-b}
\end{dbFilters}
\dbNewStyle{base}{math}{
  before-code = {\dbIfEmptyF{\begin{enumerate}}},
  after-code = {\dbIfEmptyF{\end{enumerate}}},
  item-code = {\item\dbuse{ques}},
}
\dbNewStyle[base]{filter}{math}{raw-filter = {!select}}
\NewDocumentCommand \savemath { O{} m } {%
  \begin{dbitem}{math}[labels={#1}, ques=#2]%
  \end{dbitem}%
}

\begin{document}
\savemath[label-a]{Question 1 with label a.}
\savemath[label-b]{Question 2 with label b.}
\savemath[label-c]{Question 3 with label c.}
\savemath[label-b]{Question 4 with label b.}
\savemath[label-d]{Question 5 with label d.}

\section{Original}
\dbshow{base}{math}
\section{Hide question with label a and b}
\dbshow{filter}{math}
\end{document}

相关内容