1

I am using the tasks package to layout answers to exercises. However the exercises are numbered 1, 3, 5, 7, etc. Of course tasks wants to increment by 1 to get 1, 2, 3, 4, etc. Is there anyway to set a increment value for tasks?

\documentclass{article}

\usepackage{tasks}

\begin{document}

 \begin{tasks}[label=\arabic*](3)
   \task $x^2$
   \task $y^5$
   \task $a^5$
   \task $b^5$
   \task $c^5$
   \task $d^5$
   \end{tasks}

\end{document}
3
  • 1
    You could add \stepcounter{task} to the second and following task items.
    – Cicada
    Commented May 28, 2023 at 5:44
  • please always provide an example. You say "Of course tasks wants to increment by 1 to get 1,2,3,4, etc" but I did not get 1,2,3 from \documentclass{article} \usepackage{tasks} \begin{document} \begin{tasks}(3) \task $x^2$ \task $y^5$ \task $a^5$ \task $b^5$ \task $c^5$ \task $d^5$ \end{tasks} \end{document} Commented May 28, 2023 at 12:33
  • You're absolutely right, by default it goes, a), b), c) etc. I updated the code to give a compete example that uses arabic instead.
    – rhody
    Commented May 28, 2023 at 22:07

3 Answers 3

3

When the value for label has the form \foo*, tasks will apply \foo to the default counter. Define a command that does simple arithmetic with the counter's value.

\documentclass{article}
\usepackage{tasks}

\NewExpandableDocumentCommand{\makeodd}{m}{%
  \inteval{2*\value{#1}-1}%
}

\begin{document}

\begin{tasks}[label=\makeodd*](3)
  \task $x^2$
  \task $y^5$
  \task $a^5$
  \task $b^5$
  \task $c^5$
  \task $d^5$
\end{tasks}

\end{document}

enter image description here

0

Using the stepcounter idea by Circada in their comment we get what we're looking for. Better than adding the numbers manually using \task[number]. It's easier to add new entries without manually renumbering everything.

\documentclass{article}

\usepackage{tasks}

\begin{document}

\begin{tasks}[label=\arabic*](3)
  \task $x^2$ 
  \task $y^5$ \stepcounter{task}
  \task $a^5$ \stepcounter{task}
  \task $b^5$ \stepcounter{task}
  \task $c^5$ \stepcounter{task}
  \task $d^5$ \stepcounter{task}
\end{tasks}

\end{document}

enter image description here

1
  • Use \refstepcounter{task} if you need to make a cross-reference to an item with label/ref.
    – Cicada
    Commented May 29, 2023 at 1:53
0

Musing arithmetically,

odd numbers

MWE

\documentclass{article}
\usepackage{tasks}


\ExplSyntaxOn
\NewDocumentCommand { \makeodd } { m } {
    \int_set:Nn \l_tmpa_int { \value{#1} }
    \int_eval:n {
      \l_tmpa_int + \l_tmpa_int -1
    }
}
\ExplSyntaxOff



\begin{document}
Since the set of natual numbers is infinite, and the set of odd numbers is also infinite, one can be mapped to the other (in this case, via $n*2-1$) to display odd-numbered labels in the `enumerate`-style task list without needing to change the actual task number.

For the case where the start value for the list numbering is `1`, the calculation \texttt{\textbackslash makeodd}, in expl3 syntax

\begin{quotation}\noindent
\begin{verbatim}
\NewDocumentCommand { \makeodd } { m } {
    \int_set:Nn \l_tmpa_int { \value{#1} }
    \int_eval:n {
      \l_tmpa_int + \l_tmpa_int -1
    }
}
\end{verbatim}
\end{quotation}

and called via the \verb|tasks| environment's \verb|label=| option, 

\begin{quotation}\noindent
\verb|label={(\makeodd*)},|
\end{quotation}

gives:

  \begin{tasks}[%
                    style=enumerate,
       label={(\makeodd*)},
       label-width=4ex,
%       start = {20},
       ](3)
  \task $xx^2$ 
  \task $xy^5$ 
  \task $xa^5$ 
  \task $xb^5$ 
  \task $xc^5$ 
  \task $xd^5$ 
\end{tasks}

\end{document}

You must log in to answer this question.

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