1

I would like to thank those who have edited my question, and thoae who had answered the previous post. I am trying to write a book with the following key features

  1. Questions laid out in the exam class format with question number, part and subpart
  2. Questions, question parts and subparts should indicate the number of marks or points as well as total points for the whole question such as \addtotalpoints in exam class
  3. Solutions which will be written after the question during typesetting, but appearing at the end of the book.

code:

\documentclass[12pt,fleqn]{book} 
\usepackage{exsheets}  
\SetupExSheets{  
 counter-format=ch.qu,counter-within=chapter  
        }  

\DeclareInstance{exsheets-heading}{block}{default}  
{  
join   = { title[r,B]number[l,B](1ex,0pt) } ,
attach =
{
    main[l,vc]title[l,vc](0pt,0pt) ;
    main[r,vc]points[l,vc](\marginparsep,0pt)
},
above  = \baselineskip-.5ex ,
below  = .5ex}\NewQuSolPair{exercise}{solution}  

\DeclareInstance{exsheets-heading}{myheadings2}{default}{  
   runin = true,  
   number-post-code = \space,}  

\SetupExSheets{  
question/pre-body-hook = {%  
\hyperlink{sol:\CurrentQuestionID}{\underline{\textbf{Exercise:}   
            \GetQuestionProperty{counter}{\CurrentQuestionID}}}\par
},  
solution/pre-hook = {%    \hypertarget{sol:\CurrentQuestionID}{}%
},
solution/pre-body-hook = {%
    \hyperref[qu:\CurrentQuestionID]{\underline{\textbf{Solution:} 
            \GetQuestionProperty{counter}{\CurrentQuestionID}}}\par
},
headings = myheadings2 }    


\section{Cell structure} 
\begin{itemize}
\item all living organisms are made up of cells
\item cells may be specialised to carry out a particular function
\item specialised cells include root hair cells, nerve cells, red blood cells
\end{itemize}  
\begin{exercise}  
\begin{enumerate}
\item[]
\item Which organelle is responsible for:
\begin{enumerate}
\item entry and exit of substances into or out of the cell
\item controlling all cellular activities  
\end{enumerate}
\item Below is a diagram of a plant cell.
\begin{enumerate}
\item Identify parts 1- 6.
\item Identify features which are \textbf{not} found in animal cells  
\end{enumerate}  
\end{enumerate}  
\end{exercise}  
\begin{solution} 
\begin{enumerate}
    \item[]
    \item 
    \begin{enumerate}
        \item cell membrane
        \item nucleus
    \end{enumerate}
    \item
    \begin{enumerate}
        \item \begin{itemize}
            \item chloroplast
            \item permanent vacuole
            \item cytoplasm
            \item cell wall
            \item cell membrane
            \item nucleus
        \end{itemize}
        \item 
        \begin{itemize}
            \item chloroplast/1
            \item permanent vacuole/2
            \item cell wall/4
        \end{itemize}
    \end{enumerate}
\end{enumerate}  
\end{solution}  
\chapter{Nutrition}
\section{Diet}\index{Diet}
\begin{itemize}  
\item living organisms need food for the following:
\begin{enumerate}
    \item  to produce energy that is used in work and physical exercise and to keep the body temperature at $37^OC$
    \item for growth
    \item to renew and repair worn out tissues
\end{enumerate}  
\end{itemize}
\begin{exercise}
\begin{enumerate}
\item 
\begin{enumerate}
    \item A person’s diet should contain carbohydrate and fat and protein.  Give two reasons why.
    \item Name one health problem, other than being overweight, that is linked to an unbalanced diet.
\end{enumerate}

\item Explain the importance of the following in maintaining good health
\begin{enumerate}
    \item personal hygiene
    \item sewage disposal
\end{enumerate} 
\end{enumerate}
\end{exercise}
\begin{question}
\begin{enumerate}
\item 
\begin{enumerate}
\item   
\begin{itemize}
    \item  to get a balanced diet / to prevent malnourishment
    \item to obtain energy
    \item  for  building cells / growth / repair
\end{itemize}
\item heart disease, any deficiency disease
\end{enumerate}

\item 
\begin{enumerate}
\item prevent the spread of diseases
\item prevent the spread of diseases
\end{enumerate}
\end{enumerate} 

\end{question}
\chapter{Answers}
\printsolutions
\end{document}
  • I had the same problem, but you can't use the exam class since you use book. Recreating the items you want is hard work. The exam class doesn't typeset the solutions at the end, but underneath the question. The best I came up with is using an enumerate and label all \items and then type all the solutions at the end of the document. – Jesse op den Brouw Aug 30 '18 at 12:00
  • I find lists too restrictive, especially w.r.t. \hangindent. I use \makebox and \parbox instead. As for moving the solutions to the end, one way is to create a new float class and use endfloat. Personally, I would accumulate them in a savebox (\vbox). – John Kormylo Aug 30 '18 at 12:33
3

This shows how to format titles using \makebox etc. It also shows how to accumulate solutions in a savebox.

Once you are satisfied with the formatting, you can create exercise and solution environments.

\documentclass[12pt,fleqn]{book} 

\newsavebox{\solutions}
\setbox\solutions=\vbox{}

\newsavebox{\titlebox}
\newcounter{exercise}

\begin{document}
\section{Cell structure}
\begin{itemize} 
\item all living organisms are made up of cells 
\item cells may be specialised to carry out a particular function 
\item specialised cells include root hair cells, nerve cells, red blood cells 
\end{itemize}

\sbox\titlebox{\refstepcounter{exercise}% to avoid writing it twice
\makebox[1in][l]{\normalfont\bfseries Exercise~\theexercise}%
\parbox[t]{\dimexpr \columnwidth-1.5in-\columnsep}{\normalfont Fill in the missing words.}\hfill
\makebox[0.5in][l]{\normalfont 10 points}}%

\noindent\usebox\titlebox
    \begin{enumerate}
        \item 
        Animals cells contain $..............$, a semi-fluid solution of salts and other molecules, and are surrounded by a $..............$. When surrounded by distilled water, the animal cells absorb water by $..............$. 
    \item   The leaves of green plants obtain the gas $..............$ which they require for photosynthesis, by a process of $..............$. They also lose the gas oxygen produced during $..............$ by the same process. These gases move in and out through small pores called $..............$.
    \item Water is obtained by plants from the soil solution. The water enters by the process of $..............$, via structures outside the root called $..............$.  Water is transported in the $..............$. Sugars produced during photosynthesis are transported in the $..............$    
    \end{enumerate}

\setbox\solutions=\vbox{\unvbox\solutions
\noindent\usebox\titlebox
    \begin{enumerate}
      \item 
        \begin{itemize}
            \item a cytoplasm
            \item cell membrane
            \item osmosis
        \end{itemize}
    \item
      \begin{itemize}
        \item carbon dioxide 
        \item diffusion
        \item photosynthesis
        \item stomata
      \end{itemize}
    \item 
      \begin{itemize}
        \item osmosis
        \item root hair cells
        \item xylem
        \item phloem
      \end{itemize}
  \end{enumerate}
\par}%

\chapter{Solutions}
  \unvbox\solutions
\end{document}

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.