LaTeX forum ⇒ GeneralReferences to Parts of a Problem

LaTeX specific issues not fitting into one of the other forums of this category.
gfelder
Posts: 1
Joined: Thu Dec 05, 2013 3:56 am

References to Parts of a Problem

Postby gfelder » Thu Dec 05, 2013 4:13 am

I am writing a textbook and each chapter has problems with associated answers, which I want displayed at the end of the book. After some searching I have found the answers package most helpful for this. However, I have run into a problem with multi-part problems.
  1. \documentclass{book}
  2. \usepackage{enumitem}
  3. \usepackage{answers}
  4.  
  5. \Newassociation{answer}{Answer}{ans}
  6.  
  7. \begin{document}
  8. \Opensolutionfile{ans}
  9.  
  10. \begin{enumerate}
  11. \item First exercise
  12. \begin{answer}
  13. First answer
  14. \end{answer}
  15. \item Second exercise
  16. \begin{enumerate}[ref=(\alph*)]
  17. \item\label{somelabel} The first part
  18. \begin{answer}
  19. Another answer.
  20. \end{answer}
  21. \item Use your answer to Part~\ref{somelabel} in this part.
  22. \begin{answer}
  23. Stuff
  24. \end{answer}
  25. \end{enumerate}
  26. \end{enumerate}
  27.  
  28. \Closesolutionfile{ans}
  29.  
  30. \textbf{Answers to Selected Exercises}
  31.  
  32. \input{ans}
  33. \end{document}

Within the text I often refer to earlier parts in a problem, e.g. "Using your answer to Part (b), find such-and-such". I've used the ref option to enumerate to get that to appear as (b) without the number of the problem. Unfortunately the answers package also uses that ref option and doesn't display the problem number at the back of the book. Does anyone know a simple way I could get the reference to look like Part (b) inside the text of the problem, but have the answer labeled 2b at the back of the book?

(I don't think this is relevant, but I am compiling with PDFLaTeX.)

Thank you,
Gary

P.S. This is my first post, so please do tell me if there is anything I should do differently in future posts.
Last edited by localghost on Thu Dec 05, 2013 11:57 am, edited 1 time in total.
Reason: Longer passages of source code are tagged as code block, not as in-line code.

Tags:

Return to “General”

Who is online

Users browsing this forum: No registered users and 4 guests