0

I am using a custom counter to generate the labels in a \NewTasksEnvironment (package tasks v.1.1a). This is the approach I had chosen since I use this counter elsewhere (I need to increment and decrement its value for other purposes).

I honestly wouldn't mind using the built-in tasks counter, but I actually don't know its name and I'm not sure if fiddling around with it in the rest of the code would cause issues, at this point.

Question 1 What is the name of the built-in counter used in \NewTasksEnvironment if I use the default label=\alph*)?

Question 2 See MWE code below. I use \refstepcounter in the label= option of \NewTasksEnvironment which seems to cause the counter to be incremented twice at every label (see output below, after code). Adding a 14th item causes a Counter too large error since it exceeds the 26 alphabetical values available. If I remove the \refstepcounter, the counter's value always remains at 0, so it appears as though the label=(...) code is being "called" twice. How can I fix this behaviour to ensure the counter is only incremented once?

By the way, this (code below) used to work with the tasks package v0.9 (so before last year's v1.0 update).

Code:

\documentclass{article}

\usepackage{tasks}

\newcounter{subquest}
\setcounter{subquest}{0}
\renewcommand{\thesubquest}{\alph{subquest})}

\NewTasksEnvironment%
  [%
      label = \refstepcounter{subquest}\thesubquest,%
  ]%
  {lsubquestions}[\squest](1)

\begin{document}

\begin{lsubquestions}
  \squest Subquestion 1
  \squest Subquestion 2
  \squest Subquestion 3
  \squest Subquestion 4
  \squest Subquestion 5
  \squest Subquestion 6
  \squest Subquestion 7
  \squest Subquestion 8
  \squest Subquestion 9
  \squest Subquestion 10
  \squest Subquestion 11
  \squest Subquestion 12
  \squest Subquestion 13
  %\squest Subquestion 14
\end{lsubquestions}

\end{document}

Output:

b) Subquestion 1
d) Subquestion 2
f) Subquestion 3
h) Subquestion 4
j) Subquestion 5
l) Subquestion 6
n) Subquestion 7
p) Subquestion 8
r) Subquestion 9
t) Subquestion 10
v) Subquestion 11
x) Subquestion 12
z) Subquestion 13
3
  • Why can't you simply use label=\alph*) with your environment? – Bernard Jan 28 '20 at 19:01
  • I either need to use label=\alph*), in which case I must know the internal counter's name because I use this value elsewhere (and I don't know if it'll work), or I can use a custom counter as mentioned in the question, which is the easiest option for me since the rest of the code is already written using this approach. – feculededentier Jan 28 '20 at 19:53
  • tasks.sty defines only a single counter: \newcounter {task}. (See github.com/cgnieder/tasks/blob/master/tasks.sty) There are various expl3 integers running around, but I think that's the main counter within the environment. – Scott H. Jan 28 '20 at 20:40
0

My gut feeling tells me that this might be an XY problem but I am going to answer anyway.


With v1.2 there are two ways how a different counter than the default one can be used:

\documentclass{article}

\usepackage{tasks}[2020/03/21]
\usepackage{multicol}
\newcounter{test}

% first version:
\NewTasksEnvironment[
  label = \tasksifmeasuringF{\refstepcounter{test}}A\thetest ,
  label-width = 13pt
]{testa}

% second version:
\NewTasksEnvironment[
  counter = test ,
  label = B\arabic* ,
  label-width = 13pt
]{testb}

\begin{document}

\begin{multicols}{2}
\begin{testa}
  \task one
  \task two\label{testa}
  \task three
  \task four
\end{testa}

\begin{testb}
  \task one
  \task two
  \task three\label{testb}
  \task four
\end{testb}
\end{multicols}

See \ref{testa} and \ref{testb}

\end{document}

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.