friendly / VCDR

Visualizing categorical data with R
0 stars 0 forks source link

Solutions manual for book #75

Open friendly opened 8 years ago

friendly commented 8 years ago

I'm considering how to start on a solutions manual for the book, that would give hints or answers to selected exercises from the chapters. Ideally, this should just use the existing chXX/exercise.Rnw files, to which answers could be added via something like

\begin{answer}
...
\end{answer}

together with some latex package allowing these to be printed if some flag is TRUE.

I searched online, and found several such latex packages: exsheets.sty, answers.sty, exercise.sty and probsoln.sty, and a discussion forum at http://tex.stackexchange.com/questions/tagged/answers

One problem is that the exercises are marked up with a custom \exercise macro, and I can't tell whether that would work with any of these exercise packages.
@sciencegraph : could you take a look at these and recommend what should be tried? Perhaps there is a way to modify the definition of \exercise to make it work with some package.

sciencegraph commented 8 years ago

I'll take a look and suggest one solution.

sciencegraph commented 8 years ago

I can't find were the custom \exercise macro is defined nor the \begin{Exercises} environment!

friendly commented 8 years ago

All latex commands, environments, etc. are defined in inputs/commands.tex

sciencegraph commented 8 years ago

I think that is easier to define a new "answer" environment, than recycle a package. In order to print or ignore the answers, the first answer of this question works fine. http://tex.stackexchange.com/questions/37925/how-to-make-latex-ignore-the-contents-of-an-environment

friendly commented 8 years ago

I tested this, in answer-test.tex in the latest commit. It works as advertised when I want to show the answers, with

\newcommand{\showanswers}{TRUE}  % comment this line if you don't want to show answers

But I get a latex error if I comment out that line to suppress the answers. Could you look into this?

Also, is there a better way to parameterize the lead-in text label for an answer than just

\newcommand{\answserstart}{\noindent\emph{Answer}:}

I know I could use renewcommand to change this to \emph{Hint}, but could I add an optional argument to the answer environment to specify that text?

sciencegraph commented 8 years ago

I'm working on this issue.

sciencegraph commented 8 years ago

You can add arguments to a new command like in this example that has two arguments: \newcommand{\thenewcommand}[2]{ \draw (1.4,1.4) node[#2,anchor=north west,xshift=-8pt]{\tiny{#1}};}

sciencegraph commented 8 years ago

I've deleted the answers that referred to the issue that appeared when trying to hide the answers because I was doing more tests. Anyways, it is just necessary to load the "verbatim" package instead of the "comment" one.

friendly commented 8 years ago

In book.Rnw, the comment.sty is loaded and used in several places (ch04.Rnw only), so maybe loading verbatim after comment is necessary.

I'm trying to sort this out on a test file, before incorporating it into the main book files.