title: Keeping R Markdown syntax highlighting when printing
body: <p>I'm afraid the response will be: "Markdown is meant to be simple and it doesn't do that", but it (almost) never hurts to ask.  </p>
  
  <p>When writing an R Markdown document I can view the HTML file in a browser and it looks great.  When I try to print it, either on paper or as PDF, the color in the figures is printed but not the syntax highlighting.  Is there a way to maintain syntax highlighting when printing?</p>
  
  <p>Example:</p>
  
  <pre><code>Minimal Example
  =====
  
  This text looks great in the file and the plot prints in color, but see commented code     below.
  
  ```{r}
  # this commented line will be green in the HTML file, but will be black when I print it
  z &lt;- cor(mtcars) 
  require(lattice) # 'require' will be blue in the HTML file, but will be black when I print it
  levelplot(z)
  ```
  </code></pre>
  
  <p>I push the "Knit HTML" button in RStudio and open the HTML in Chrome or Safari and there are no problems.  If I print from the HTML from the browser all the syntax highlighting is lost.</p>