I hope this is in the right place. For my statistics assignments, I do the computation inline with Sweave, like so:
\begin{itemize}
\item[Problem 1]
<<label=block1,eval=T,echo=F>>
varA <- 2+2
@
The answer to the problem is \Sexpr{varA}
\end{itemize}
I'd like to be able to reproduce the code in full in an appendix, but this doesn't work:
\subsection*{Code}
<<block1>>
@
There must be a clean way to do this that I'm missing.
=after the last>? – Roman Luštrik Apr 30 '12 at 07:00