我用scrartcl和覆盖用于创建演示文稿。覆盖中给出的 \alert 命令不会改变项目标签颜色。
1.如何将下面的MWE中的标签颜色改为红色?
2.还有其他更好的方法来实现吗?
\documentclass[fontsize=9pt,landscape,parskip=half]{scrartcl}
\usepackage{scrlayer-scrpage}
\usepackage[paperwidth=128mm, paperheight=96mm, margin=8mm, footskip=6mm] {geometry}
\usepackage{tasks}
\usepackage{overlays}
\begin{document}
\begin{overlays}{2}
Given four choices, select the correct choice
\begin{tasks}(2)
\task choice one
\task choice two
\task \alert{2}{choice three}
\task choice four
\end{tasks}
\end{overlays}
\clearpage
\end{document}
答案1
一种可能性是为环境设置标签颜色tasks
,并从内部修改颜色定义\alert
。为此,您可以重新定义命令\alert
,即从overlays
包中复制原始定义并添加颜色命令。
这个想法是添加一个执行两项操作的命令:首先,设置颜色;其次,以这样一种方式重新定义自身,以便下次调用它(通过下一个\task
命令)时,颜色将切换回来。
梅威瑟:
\documentclass[fontsize=9pt,landscape,parskip=half]{scrartcl}
\usepackage{scrlayer-scrpage}
\usepackage[paperwidth=128mm, paperheight=96mm, margin=8mm, footskip=6mm] {geometry}
\usepackage{tasks}
\usepackage{overlays}
% makeatletter/makeatother needed because the definition of \alert uses the @ (at) symbol
\makeatletter
% original definition copied from overlays.sty
\renewcommand{\alert}[2]{\overl@y{#1}{%
{\color{alert}%
% added color command below
% set to red, then redefine the command to set to black
\gdef\tasklabelcolor{\color{red}\gdef\tasklabelcolor{\color{black}}}%
% rest of original definition below
\psset@lertcolor
{#2}%
\ifvmode
\unskip % undo spurious space introduced by \color
\fi}}{#2}}
\makeatother
\begin{document}
% set initial task label color at the start of the document
\def\tasklabelcolor{\color{black}}
\begin{overlays}{2}
Given four choices, select the correct choice
% use color in label definition
\begin{tasks}[label-format=\tasklabelcolor](2)
\task choice one
\task choice two
\task \alert{2}{choice three}
\task choice four
\end{tasks}
\end{overlays}
\clearpage
\end{document}
结果: