答案1
也许像这样?我用 定义了一个新的列表环境(称为problems
)enumitem
。然后我定义了命令\easy
、\medium
和 ,\hard
它们\vhard
的行为基本上应该像\item
,但它们在项目的标签周围添加了一个框。
\documentclass{article}
\usepackage{enumitem}
\usepackage{tikz}
\usetikzlibrary{shapes.geometric}
\newlist{problems}{enumerate}{1}
\setlist[problems]{
label=\alph*,
}
\newcommand*{\easybox}[1]{%
\begin{tikzpicture}[anchor=base, baseline]
\node[circle, fill=black, text=white, font=\bfseries, inner sep=2pt] at (0,0) {#1};
\end{tikzpicture}%
}
\newcommand*{\mediumbox}[1]{%
\begin{tikzpicture}[anchor=base, baseline]
\node[fill=black, text=white, font=\bfseries, inner sep=3pt] at (0,0) {#1};
\end{tikzpicture}%
}
\newcommand*{\hardbox}[1]{%
\begin{tikzpicture}[anchor=base, baseline]
\node[diamond, fill=black, text=white, font=\bfseries, inner sep=1.5pt] at (0,0) {#1};
\end{tikzpicture}%
}
\newcommand*{\vhardbox}[1]{%
\begin{tikzpicture}[anchor=base, baseline]
\node[fill=black, font=\bfseries, inner sep=3pt] at (0,0) {\phantom{#1}};
\node[diamond, fill=black, text=white, font=\bfseries, inner sep=1.5pt] at (0,0) {#1};
\end{tikzpicture}%
}
\newcommand*{\makeproblemcommand}[1]{%
\expandafter\NewDocumentCommand\expandafter{\csname #1\endcsname}{o}{%
\IfNoValueTF{##1}{%
\refstepcounter{problemsi}
\item[\csname #1box\endcsname{\theproblemsi}]
}{%
\item[\csname #1box\endcsname{##1}]
}%
}%
}
\makeproblemcommand{easy}
\makeproblemcommand{medium}
\makeproblemcommand{hard}
\makeproblemcommand{vhard}
\begin{document}
\begin{problems}
\easy An easy problem
\medium A problem
\hard A challenging problem
\vhard A very challenging problem
\easy Another easy problem
\hard Another hard problem
\vhard[X] A problem with a different label
\end{problems}
\end{document}