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* \task $x^2$ \task $y^5$ \task $a^5$ \task $b^5$ \task $c^5$ \task $d^5$ \end{tasks}

\end{document}

rhody
  • 1,020
  • 1
    You could add \stepcounter{task} to the second and following task items. – Cicada May 28 '23 at 05: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}`

    – David Carlisle May 28 '23 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 May 28 '23 at 22:07

3 Answers3

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

egreg
  • 1,121,712
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* \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

rhody
  • 1,020
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}, \task $xx^2$ \task $xy^5$ \task $xa^5$ \task $xb^5$ \task $xc^5$ \task $xd^5$ \end{tasks}

\end{document}

Cicada
  • 10,129