4

Is there a way to start with a higher counter within the tasks package.

I tried counter-format = (tsk[c]) but that did not work.

1
  • Welcome to TeX.SX! Please post compilable document examples, not just fragments of code
    – user31729
    Commented Jan 16, 2016 at 12:04

2 Answers 2

4

I don't see how the setting of the counter is possible directly from the tasks package code, but perhaps I've overlooked some feature.

Anyway, tasks does not really use a traditional counter but is applying the expl3 int variable features. The task number is stored in \g__tasks_int, a global variable (but it is actually an internal one, because of the double underscore __ naming convention), which can be set using \int_gset:Nn.

However, this requres switching to \ExplSyntaxOn...\ExplSyntaxOff and defining a new command, say \SetTaskNumber, which can be used right after the \task command that should get the new number.

Setting outside of \begin{tasks} is not possible, since tasks resets the task number.

Be aware, that tasks have a resume feature -- this might break with this setting.

\documentclass{article}
\usepackage{tasks}

\ExplSyntaxOn
\newcommand{\ShowTaskNumber}{
  \int_use:N \g__tasks_int
}
\newcommand{\SetTaskNumber}[1]{
  \int_gset:Nn \g__tasks_int {#1}
}
\ExplSyntaxOff

\begin{document}
\begin{tasks}(2)
  \task\SetTaskNumber{5} Foo \ShowTaskNumber
  \task Bar \ShowTaskNumber
\end{tasks}
\end{document}

enter image description here

2
  • @clemens: Yes, that's true -- it's internal. But I suggest to provide an interface to access the 'counter' value ;-), something like enumitem package's start=...
    – user31729
    Commented Jan 16, 2016 at 13:02
  • This answer is not working anymore. See the other answer instead.
    – Watson
    Commented Apr 27 at 18:14
2

Since v1.0 (2019/10/04) tasks uses a standard counter named task:

\documentclass{article}
\usepackage{tasks}[2019/10/04]% v1.0 or newer
\begin{document}

\setcounter{task}{17}
\begin{tasks}[resume](3)
  \task foo \task bar \task baz
\end{tasks}

\end{document}

enter image description here


Version 1.1 will also support an option called start in order to set the value directly:

\documentclass{article}
\usepackage{tasks}[2019/11/03]% v1.1 or newer
\begin{document}

\begin{tasks}[start=18](3)
  \task foo \task bar \task baz
\end{tasks}

\end{document}

with the same output as above.

You must log in to answer this question.

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