1

I use scrartcl and overlays for creating presentation. \alert command given in overlays does not change item label color.

1.How to change label color into red in the below MWE?

2.Is there any other better way to achieve it?

\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}
0
1

One possibility is to set a label color for the tasks environment, and modify the color definition from within \alert. To do this you can redefine the \alert command, i.e., copy the original definition from the overlays package and add the color commands.

The idea is to add a command that does two things: first, set the color, and second, redefines itself in such a way that the next time it is called (by the next \task command) the color will be switched back.

MWE:

\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}

Result:

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.