Open friendly opened 8 years ago
I'll take a look and suggest one solution.
I can't find were the custom \exercise macro is defined nor the \begin{Exercises} environment!
All latex commands, environments, etc. are defined in inputs/commands.tex
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
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?
I'm working on this issue.
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}};}
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.
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.
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 liketogether 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
andprobsoln.sty
, and a discussion forum at http://tex.stackexchange.com/questions/tagged/answersOne 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.