3

Can someone please help me reset the counter(?) in the code below. The Answer section should start with #1. I do need

\RenewTasks[resume, style=custom,label-align=right]{tasks}(2)

in the preamble.

Thank you.

\documentclass{book}
\usepackage[a4paper, top=2cm, bottom=2cm]{geometry}
\usepackage{multicol, paralist, multirow, amsmath, amsthm, amssymb, amsfonts, ulem}
\usepackage{tasks}[2014/07/20]

\DeclareInstance{tasks}{custom}{default}{
  counter-format  = tsk. ,
  label-format    =  \bfseries ,
  label-width     = 2em ,
  label-offset    = .3333em ,
  after-item-skip = 5pt
}
\RenewTasks[resume, style=custom,label-align=right]{tasks}(2)

\begin{document}
%
% 
In Exercises 1-8, factor the common factor in the polynomials. 
\begin{tasks}(3)
\task
$3x^3 - 21x$
\task
$5x^6 + 15x^4$
\task
$4x^3 + 10x^2 - 2x$
\end{tasks}
%
%
\begin{tasks}(1)
\task
This is a long word problem, more than one line. I can't seem to use rlap for this. I have to use another begin{tasks} section here. 
\end{tasks}

In Exercises 8-13, solve the polynomial equations. 
\begin{tasks}(2)
\task
$x(x+12) = 0$
\task
$(2x+1)(2x-1) = 0$
\end{tasks}
%

\vspace{1in}
%%%%%%%

Answers:
\begin{tasks}(2)
\task
$3x(x^2-7)$
\task
$5x^4(x^2+3)$
\task
$2x(2x^2+5x-1)$
%
\task
answer to the word problem
\task
$x=0, \, x = -12$
\task
$x = - \, \dfrac 12, \, x = \, \dfrac 12$
\end{tasks}

\end{document}

output

Mensch
  • 65,388
Sean N
  • 183
  • Welcome to TeX.SX! Please add your code in the question window, not as a screen shot. The counter is probably called task, so a \setcounter{task}{0} before the answers start should do, but I have never used this package at all –  Sep 28 '14 at 05:02
  • Hi Christian. Thanks for the reply. I tried that but it didn't work. – Sean N Sep 28 '14 at 08:07
  • Sean N, I wrote a short message to the maintainer of task, he is also a user here (cgnieder!) –  Sep 28 '14 at 09:10

1 Answers1

2

Two things:

To accomodate a long item, you don't need to start a new environment. Just use \task*

\task*
This is a long word problem, more than one line. I can't seem to use rlap for this. I have to use another begin{tasks} section here.

Second, you can pass the option [resume=false] locally, when you type answers

Answers:
\begin{tasks}[resume=false](2)

Full code:

\documentclass{book}
\usepackage[a4paper, top=2cm, bottom=2cm]{geometry}
\usepackage{multicol, paralist, multirow, amsmath, amsthm, amssymb, amsfonts, ulem}
\usepackage{tasks}

\DeclareInstance{tasks}{custom}{default}{
  counter-format  = tsk. ,
  label-format    =  \bfseries ,
  label-width     = 2em ,
  label-offset    = .3333em ,
  after-item-skip = 5pt
}
\RenewTasks[resume, style=custom,label-align=right]{tasks}(2)

\begin{document}
%
%
In Exercises 1-8, factor the common factor in the polynomials.
\begin{tasks}(3)
\task
$3x^3 - 21x$
\task
$5x^6 + 15x^4$
\task
$4x^3 + 10x^2 - 2x$
%\end{tasks}
%%
%%
%\begin{tasks}(1)
\task*
This is a long word problem, more than one line. I can't seem to use rlap for this. I have to use another begin{tasks} section here.
\end{tasks}

In Exercises 8-13, solve the polynomial equations.
\begin{tasks}(2)
\task
$x(x+12) = 0$
\task
$(2x+1)(2x-1) = 0$
\end{tasks}
%

\vspace{1in}
%%%%%%%

Answers:
\begin{tasks}[resume=false](2)
\task
$3x(x^2-7)$
\task
$5x^4(x^2+3)$
\task
$2x(2x^2+5x-1)$
%
\task
answer to the word problem
\task
$x=0, \, x = -12$
\task
$x = - \, \dfrac 12, \, x = \, \dfrac 12$
\end{tasks}

\end{document}

enter image description here

As an aside, instead of hard coding question ranges, you can label the questions and use \ref

As an alternative, you may define these:

\NewTasks[resume, style=custom,label-align=right]{questions}(2)
\NewTasks[style=custom,label-align=right]{answers}

and use them like

\begin{questions}(3)
\task
$3x^3 - 21x$
\end{questions}

\begin{answers}(2)
\task
$3x^3 - 21x$
\end{answers}

so that code is more readable. You may change the separator \task too, if you wish. For details refer to the manual.

  • @SeanN: Traditional way of thanking in this site is to upvote the answer. You can accept the more useful answer by clicking the green check mark below vote count so that future visitors will know it easily. For details, please see How do you accept an answer –  Sep 29 '14 at 00:03