2

I am writing an answer key to a (math) problem set which contains, suppose, 10 problems. To generate a sequence of numbers I am using task environment with global settings \NewTasks[label = {\bf \arabic*.},label-width=4ex]{answers}[\a].

For example, suppose the problem number 5, 6, 7 are 'prove that' type problems. It means that I don't need to show their answers in the answer key. So, I want to generate a sequence from 1 to 4 and then from 8 to 10.

I don't know how to skip these three particular numbers. I am using TexShop 4.58.

My code is

\usepackage{tasks}
\usepackage{amsmath, amsthm, amssymb, amsfonts}
\NewTasks[label = {\bf \arabic*.},label-width=4ex]{answers}[\a]
\begin{document}
\begin{answers}(5)
\a (C)
\a (D)
\a (D)
\a (C)
\a (D)
\a (A)
\a (C)
\a (C)
\a (A)
\a (B)
\end{answers}
\end{document}

It produces

output

Please tell me what changes should I do to get desired output?

Thanks

  • 1
    You know the drill: Please provide a self-contained, compilable example document that sets up your overall document properties. Without it, any answer will require so much guesswork as having little chance of being of value to you. – Mico Jan 09 '21 at 08:22

1 Answers1

2

You can do \addtocounter{task}{...} where you need it:

\documentclass{article}
\usepackage{tasks}

\NewTasksEnvironment[label=\arabic*.,label-format=\bfseries,label-width=4ex]{answers}[\a]

\begin{document}

\begin{answers}(4) \a (A) \a (C) \a (D) \addtocounter{task}{3} \a (C) \end{answers}

\end{document}

If you want to directly type in the number you want to step up to: that can be done with a little bit of simple math:

\newcommand\gototask[1]{\addtocounter{task}{\numexpr#1-\value{task}\relax}}

\documentclass{article} \usepackage{tasks}

\NewTasksEnvironment[label=\arabic*.,label-format=\bfseries,label-width=4ex]{answers}[\a]

\newcommand\gototask[1]{\addtocounter{task}{\numexpr#1-\value{task}\relax}}

\begin{document}

\begin{answers}(4) \a (A) \a (C) \a (D) \gototask{6} \a (C) \end{answers}

\end{document}

Both examples give

enter image description here


BTW: in your log you should be getting

Package tasks Warning: You've tried setting command `\NewTasks ' on line 6.
(tasks)                However, command `\NewTasks ' is deprecated. Please use
(tasks)                command `\NewTasksEnvironment ' instead. Refer to the
(tasks)                manual for details.

Maybe also have a look at Does it matter if I use \textit or \it, \bfseries or \bf, etc.

cgnieder
  • 66,645
  • It is a great solution. Thanks! It will be more convenient if I could plug-in the required counter number instead of the number added. In your example, if somehow I could write 6 instead of 3 to go to the counter number 6, then it would be more convenient. – prashant sharma Jan 09 '21 at 09:43
  • I don't know much LaTeX, so I could not find this elegant way to get desired result. Thanks, you solved my problem. – prashant sharma Jan 09 '21 at 09:54
  • @prashantsharma you're welcome – cgnieder Jan 09 '21 at 09:57