2

I'm using tasks (as a subset of exsheets) to create environments exer2 and exer3 which organize exercise sets in a calculus workbook into rows and columnns. I am also using the exsheets environments question and solution to keep track of the solutions and print them up in an orderly fashion.

I know that the name of the first level {enumerate} counter is enumi as shown in line 9 of the preamble. What I do not know is the name of the counter in the environments created by tasks. When I use the syntax suggested in section 7.6, pp 13-14 of the exsheets manual, I get a text echo "tsk[a]", not the counter.

I can handle the final formatting of the labels in solutions, I just need to know how to get the "a, b, c" instead of "1 tsk[a], 1 tsk[a], 1 tsk[a]".

What am I missing here?

[Included below: TeX code in its entirety, output from MS Word to show what I want and what I'm getting from LaTeX]


\documentclass[12pt,letterpaper,fleqn,titlepage,openany,oneside]{book}
\usepackage{comment}
\usepackage[left=.75in, right=.75in, top=1in, bottom=1in]{geometry} 
\usepackage{setspace}
\usepackage[inline]{enumitem} 
\usepackage{exsheets} 
\SetupExSheets[question]{pre-hook=\vspace{-24pt},post-hook=\vspace{-12pt},headings=block}
\SetupExSheets[solution]{headings=runin}
\SetupExSheets{counter-format=\arabic{enumi}~tsk[a]}
% ENVIRONMENTS FOR EXERCISES USING TASKS
\NewTasks[before-skip=6pt,after-skip=6pt,after-item-skip=0pt,item-indent=24pt,label-width=6pt,label-offset=12pt,counter-format=tsk[a].~]{exer3}[\exercise](3)
\NewTasks[before-skip=6pt,after-skip=6pt,after-item-skip=0pt,item-indent=24pt,label-width=6pt,label-offset=12pt,counter-format=tsk[a].~]{exer2}[\exercise](2)

\begin{document}
    \begin{enumerate}
    \item First exercise set. 
        \begin{exer3} 
        \exercise % THIS IS THE COUNTER WHOSE NAME I WANT
            \begin{question}
                Set one exercise one
            \end{question}
            \begin{solution}
                Set one solution one\\
                 \hrule \vspace{6pt}
             \end{solution}
        \exercise
            \begin{question}
                Set one exercise two
            \end{question}
            \begin{solution}
                Set one solution two\\
                \hrule \vspace{6pt}
            \end{solution}
        \exercise
            \begin{question}
                Set one exercise three
            \end{question}
            \begin{solution}
                Set one solution three\\
                \hrule \vspace{6pt}
            \end{solution}
            \end{exer3}
    \end{enumerate}

    \begin{enumerate}[resume]
        \item Second exercise set.
            \begin{exer2}
        \exercise
            \begin{question}
                Set two exercise one
            \end{question}
            \begin{solution}
                Set two solution one\\
                \hrule \vspace{6pt}
            \end{solution}
        \exercise
             \begin{question}
                Set two exercise two
            \end{question}
            \begin{solution}
                Set two solution two\\
                \hrule \vspace{6pt}
            \end{solution}
            \end{exer2}
    \end{enumerate}

\hrule \vspace{2pt} \hrule \vspace{6pt}

\printsolutions

\end{document} 

What I want:

1a. Set one solution one
________________________________________
1b. Set one solution two
________________________________________
1b. Set one solution three
________________________________________
2a. Set two solution one
________________________________________
2b. Set two solution two
________________________________________

What I get:

Solution 1 tsk[a]   Set one solution one
________________________________________
Solution 1 tsk[a]   Set one solution two
________________________________________
Solution 1 tsk[a]   Set one solution three
________________________________________
Solution 2 tsk[a]   Set two solution one
________________________________________
Solution 2 tsk[a]   Set two solution two
________________________________________
0
1

You're using tasks in a way I never imagined…

You have to make the tasks counter (which actually is an internal expl3 integer) known to exsheets pattern reader:

\usepackage{exsheets,tasks}
\ExplSyntaxOn
  \AddCounterPattern* [exsheets] {task} {tsk}
  \ReadCounterFrom    [exsheets] {task} \g__tasks_int
\ExplSyntaxOff

Embedded in your example document:

\documentclass{book}
\usepackage[inline]{enumitem} 
\usepackage{exsheets,tasks}
\ExplSyntaxOn
  \AddCounterPattern*[exsheets]{task}{tsk}
  \ReadCounterFrom   [exsheets]{task}\g__tasks_int
\ExplSyntaxOff

\SetupExSheets{
  question/pre-hook = \vspace{-24pt},
  question/post-hook = \vspace{-12pt},
  question/headings = block ,
  solution/headings = runin ,
  solution/post-hook = \par \hrule \vspace{6pt} ,
  counter-format=\arabic{enumi}~tsk[a]
}

\NewTasks[
  before-skip=6pt,
  after-skip=6pt,
  after-item-skip=0pt,
  item-indent=24pt,
  label-width=6pt,
  label-offset=12pt,
  counter-format=tsk[a].~]{exer3}[\exercise](3)
\NewTasks[
  before-skip=6pt,
  after-skip=6pt,
  after-item-skip=0pt,
  item-indent=24pt,
  label-width=6pt,
  label-offset=12pt,
  counter-format=tsk[a].~]{exer2}[\exercise](2)

\begin{document}

\begin{enumerate}
  \item First exercise set. 
  \begin{exer3} 
    \exercise
    \begin{question}
      Set one exercise one
    \end{question}
    \begin{solution}
      Set one solution one
    \end{solution}
    \exercise
    \begin{question}
      Set one exercise two
    \end{question}
    \begin{solution}
      Set one solution two
    \end{solution}
    \exercise
    \begin{question}
      Set one exercise three
    \end{question}
    \begin{solution}
      Set one solution three
    \end{solution}
  \end{exer3}
\end{enumerate}

\begin{enumerate}[resume]
  \item Second exercise set.
  \begin{exer2} 
    \exercise
    \begin{question}
      Set two exercise one
    \end{question}
    \begin{solution}
      Set two solution one
    \end{solution}
    \exercise
    \begin{question}
      Set two exercise two
    \end{question}
    \begin{solution}
      Set two solution two
    \end{solution}
  \end{exer2}
\end{enumerate}

\hrule \vspace{2pt} \hrule \vspace{6pt}

\printsolutions

\end{document}
4
  • I will try that.
    – user114366
    Sep 17 '16 at 0:19
  • @user114366 Where did you fail? I added a modified version of your example to my answer to show you that it's easy
    – cgnieder
    Sep 17 '16 at 7:25
  • I thought that I typed it identically to what you gave me (with the spaces) and the compiler returned an undefined control sequence error for the \end{exer3} line with a reference to g_. So I copied and pasted what you gave me and it worked. Now I see the double underbar between g and tasks. Well, duh. I NEVER would have figured this one out on my own.
    – user114366
    Sep 17 '16 at 15:32
  • Now, by using `headings=runin-nr' with what you gave me, I've almost got what I want. Is there an easy way to get the label "3.c" to not be boldface? Or should I open a new question?
    – user114366
    Sep 17 '16 at 15:38
0

I could not get that to work, but I did figure out a different answer after reading some other posts on the forum

\usepackage{etoolbox}
\AtBeginEnvironment{exer2}{\setcounter{question}{0}}
\AtBeginEnvironment{exer3}{\setcounter{question}{0}}
\SetupExSheets{counter-format=\arabic{enumi}.\alph{question}}

appears to be working.

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.