我的问题如下。我想使用 tcolorbox 创建练习(不使用包练习)。问题是我希望能够根据以下条件对这些练习进行索引:-它们的难度级别(比如:基础、中级和困难)-练习中涉及的主题(例如:积分、复数、序列......)
然后,我希望能够创建一个包含所有基本练习的列表,以及一个包含所有困难练习的列表,...然后创建一个包含所有处理复数的练习的列表,然后创建一个包含所有困难和处理积分的练习的列表,等等。
到目前为止,我所拥有的最佳 MWE 是:
\documentclass[11pt]{article}
\usepackage{lipsum}
\usepackage{xcolor}
\usepackage[many]{tcolorbox}
\usepackage{xparse}
\newtcolorbox[auto counter,list inside=infobox]{infobox}[2][]{
breakable,
enhanced jigsaw,
before=\vskip25pt,
after=\vskip25pt,
colback=white,
colbacktitle=white,
coltitle=black,
fonttitle=\bfseries,
arc=0pt,
outer arc=0pt,
boxsep=0pt,
toptitle=5pt,
bottomtitle=5pt,
left=10pt,
right=10pt,
enlarge left by=10pt,
enlarge right by=10pt,
width=\textwidth-20pt,
boxrule=0.4pt,
% title={\strut Box~\thetcbcounter\ #1\strut},
title={\strut Exercise \#~\thetcbcounter\ #1\strut},
label={#2}
}
\newcommand\listboxname{List of Basic Exercises}
%%%%%%%%%%
\newtcolorbox[auto counter,list inside=infoboxmedium]{infoboxmedium}[2][]{
breakable,
enhanced jigsaw,
before=\vskip25pt,
after=\vskip25pt,
colback=white,
colbacktitle=white,
coltitle=black,
fonttitle=\bfseries,
arc=0pt,
outer arc=0pt,
boxsep=0pt,
toptitle=5pt,
bottomtitle=5pt,
left=10pt,
right=10pt,
enlarge left by=10pt,
enlarge right by=10pt,
width=\textwidth-20pt,
boxrule=0.4pt,
%title={\strut Medium Level Exercise \#~\thetcbcounter\ #1\strut},
title={\strut Exercise \#~\thetcbcounter\ #1\strut},
label={#2}
}
\newcommand\listboxemediumname{List of Medium Level Exercises}
%%%%%%%%%%
\begin{document}
\tableofcontents
\tcblistof[\section*]{infobox}{\listboxname}
\tcblistof[\section*]{infoboxmedium}{\listboxemediumname}
\section{Heading}
\begin{infoboxmedium}[Title of the first test box]{orgspecialblock1infoboxmedium}
\lipsum[2]
\end{infoboxmedium}
\lipsum[4]
\begin{infobox}[Title of the first Exercise]{orgspecialblock1}
\lipsum[4]
\end{infobox}
\begin{infobox}[Title of the second Exercise]{orgspecialblock2}
\lipsum[4]
\end{infobox}
\section{Remainder}
\end{document}
它工作得很好,但只区分了基础、中级和困难练习。此外,由于它要求每个类别都有不同的结构,因此不可能将其扩展到所有主题(积分、复数......)
感谢您的帮助