Alternately coloured line environment with fancyvrb
Recently, while typing up an R tutorial, I used the LaTeX fancyvrb
package to create two environments—one coloured blue for R commands, and one coloured red to display R output. This worked well for large blocks of each type. Then I decided I wanted to display a number of one-line commands and output alternately. Looking up the fancyvrb package documentation
, it was easy to get alternate colours. The problem was, it did it globally. My environments for input and output also went psychedelic.
After a bit of messing around, I discovered the following solution. My red environments remain red, my blue environments stay blue, and alternate colours only turn up when I want them to!
To leave a comment
for the author, please follow the link and comment on his blog: The Praise of Insects
offers daily e-mail updates
news and tutorials
on topics such as: visualization (ggplot2
), programming (RStudio
, Web Scraping
) statistics (regression
, time series
) and more...
If you got this far, why not subscribe for updates
from the site? Choose your flavor: e-mail
, or facebook