0

I use the tasks package extensively and it's become necessary for me to obtain the current task number/letter at any point. There doesn't seem to be a built in \theenumi like in the enumitem package, so I'm trying to define my own environment based on the tasks package. Basically, here's a brute force version of what I want:

\documentclass{article}

\usepackage{tasks}  % Make horizontal lists.
    \settasks{label={(\alph*)}, 
        label-align=left, 
        label-offset={0mm}, 
        label-width=25pt, 
        item-indent=25pt, 
        label-format={\bfseries}, 
        after-item-skip=2mm, 
        after-skip={3mm}}
    
    \newcounter{tasksCounter} % Counter is initialized and set to 0
    
\begin{document}
    \begin{tasks}
        \task \setcounter{tasksCounter}{1}Let's display the current task: (\alph{tasksCounter}) \stepcounter{tasksCounter}
        \task Let's display the current task: (\alph{tasksCounter}) \stepcounter{tasksCounter}
    \end{tasks}
    
\end{document}

enter image description here

I want to make a custom environment that sets the tasksCounter to 1 at the start of the first task and increments it by 1 for every subsequent task (like the code does above).

1 Answer 1

2

If I understood correctly what you mean, you seem to be looking for \thetask.

\documentclass{article}

\usepackage{tasks}  % Make horizontal lists.
    \settasks{label={(\alph*)}, 
        label-align=left, 
        label-offset={0mm}, 
        label-width=25pt, 
        item-indent=25pt, 
        label-format={\bfseries}, 
        after-item-skip=2mm, 
        after-skip={3mm}}
    
\begin{document}
    \begin{tasks}
        \task Let's display the current task: \thetask
        \task Let's display the current task: \thetask
    \end{tasks}
    
\end{document}
1
  • On top of that, when requiring the value in a \newcommand I used \value{task} and when needing to display the letter in a \newcommand I used \thetask. Thanks!
    – Dan P.
    May 25 at 1:27

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .