3

I'm currently working on a textbook. It contains numerous exercises and I'd like it to contain an answer key at the end of the book. The answer key should have the same structure as the book, that is all the chapter/section titles and correct exercise numbers. I can't figure out how to deal with a few issues in ConTeXt.

Here is my minimal example using \definelist:

\definelist[Answers]
\setuplist[Answers][criterium=all,pagenumber=no]
\defineenumeration[Exercise][alternative=top,inbetween={\blank[nowhite]},text=Task,way=bychapter]

\def\Task{\dosingleempty\doTask}
\long\def\doTask[#1]#2{
    \startExercise
        #2
        \writetolist[Answers]{}{\getnumber[Exercise] #1}
    \stopExercise
    }

\starttext

\chapter{First chapter}

Some text
\Task[Answer 1]{Content here}
\Task[Answer 2]{Text goes here}

\chapter{Second chapter}

\Task{Question three without answer}
\Task[Answer 4]{Number four}

\completelist[Answers]

\stoptext

Issues:

  1. Why does \getnumber[Exercise] not work? (Answers without question numbers make no sense.)
  2. How to include chapter and section titles/numbers where appropriate in the answer key? (To make the structure and navigation clear and to prevent ambiguity.)
  3. How to deal with questions that don't have an answer in the key?
  4. [optional] How to include page numbers of the actual content that the answers are referring to in the header/footer of the answer key (e.g. Answers pp. 76-100)?

Edit: scanned answer key illustration to point 2

  • Can you explain what you mean by point 2. Perhaps, it will be easiest if you can post an image that shows the desired output. – Aditya Dec 17 '13 at 18:30
  • @Aditya, I have updated the question with a scanned page, see edit. (By the way, that image is almost identical to what my concept looks like - including the itemize in answers) – user19041 Dec 17 '13 at 19:10
2

I'll write in more detail in later, but this may help you get started:

\defineenumeration
  [Task]
  [
    title=yes,
    text=Task,
    way=bychapter,
    titlecommand=\gobbleoneargument,
  ]

\starttext

\chapter{First chapter}

Some text
\startTask{Answer 1}
  Content here
\stopTask
\startTask{Answer 2}
  Content here
\stopTask

\chapter{Second chapter}
\startTask
  Content here
\stopTask
\startTask{Answer 4}
  Content here
\stopTask


\completelist[Task][criterium=all, pagenumber=no]

\stoptext

Another option is to use the annotation module by Wolfgang Schuster which provides a key-value driven interface, so you'll be able to write:

\startTask[list={....}] .... \stopTask
  • Thanks a lot! However, I tried to experiment with this solution incorporating \definecombinedlist to get the chapters and sections but without success (newest ConTeXt generates empty list). The second important issue is dealing with the "Tasks" that don't have answers in the list so that they don't appear there at all. Also, if point 4 of my actual question requires too much coding, please don't waste your time. – user19041 Dec 17 '13 at 17:14

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.