TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm writing a LaTeX document using Sweave (a Beamer presentation, really), which weaves R code and LaTeX. Is there a way to make my chunks of code and its output highlighted? I could use listings package but that would mean I would have to rummage through the .tex file and wrap all Schunks so I'm looking for perhaps more elegant solutions if currently available.

share|improve this question
up vote 13 down vote accepted

The SweaveListingUtils package contains additions to Sweave that enables pretty-printing input and output using the LaTeX listings package. Example usage can be found in the vignette.

Another alternative is to override the Schunk, Sinput and Soutput environments using \renewenvironment so that they do whatever you want them to.

share|improve this answer
"Continued" at Stackoverflow: stackoverflow.com/questions/4808052/… – Roman Luštrik Jan 27 '11 at 10:32

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.