You will have to play with formatting, but you can achieve this by changing the source binding . What I'm showing below is actually a very simple modification of the main render_latex hook , which adds \\noindent\\textbf{Code:} before the code and \\noindent\\textbf{Output:} after this:
\documentclass{article} \begin{document} <<setup, include=FALSE>>= knit_hooks$set( source = function(x, options) { x = knitr:::hilight_source(x, 'latex', options) if (options$highlight) { if (options$engine == 'R' || x[1] != '\\noindent') { paste(c('\\noindent\\textbf{Code:}\\begin{alltt}', x, '\\end{alltt}', '','\\noindent\\textbf{Output:}'), collapse = '\n') } else { if ((n <- length(x)) > 5) x[n - 3] = sub('\\\\\\\\$', '', x[n - 3]) paste(c('\\noindent\\textbf{Code:}',x, '','\\noindent\\textbf{Output:}'), collapse = '\n') } } else .verb.hook(x) } ) @ Here your first chunk. <<chunk1, results = "hold" >>= 1:100 args(lm) @ And here another. <<chunk2, results = "hold">>= 1:5 6:10 @ That seems to be it. \end{document}
Here is the result:

Thanks to the slight modification suggested by @mrbcuda in the comments, you can separate the code and the output frames:
Here's a modification to the setup fragment:
<<setup, include=FALSE>>= knit_hooks$set( source = function(x, options) { x = knitr:::hilight_source(x, 'latex', options) if (options$highlight) { if (options$engine == 'R' || x[1] != '\\noindent') { paste(c('\\noindent\\textbf{Code:}\\begin{alltt}', x, '\\end{alltt}', '','\\end{kframe}\\begin{kframe}\\noindent\\textbf{Output:}'), collapse = '\n') } else { if ((n <- length(x)) > 5) x[n - 3] = sub('\\\\\\\\$', '', x[n - 3]) paste(c('\\noindent\\textbf{Code:}',x, '','\\noindent\\textbf{Output:}'), collapse = '\n') } } else .verb.hook(x) } ) @
And the resulting result:
