I want demonstrate a sample piece of R code WITH the knitr <<..>>= preamble in a LaTeX document. Here is an example of the output I desire:
It’s got to be simple – but I’m missing something. I checked the documentation and scanned stack overflow – but without luck. Here is a MWE:
\documentclass{article}
\begin{document}
<<mychunk, cache=TRUE, eval=FALSE, dpi=100>>=
"hello world"
@
\end{document}
Suggestions? I tried indenting the code in LaTex and wrapping in a verbatim block, but only got errors.
I just checked the manual of knitr. This is how the package author solved the problem:
which produces the output as shown on page 9 of the knitr manual
Here is a minimal example:
which produces the attached output.