I found myself wanting an environment for outputting code samples and examples, in order to produce some standards documentation. After a couple of iterations I came up with the following:
| \definecolor{altlinecolor} {rgb}{0.7,0.7,0.7} | |
| \renewcommand{\FancyVerbFormatLine}[1]{% | |
| \ifodd\value{FancyVerbLine}% | |
| \colorbox{altlinecolor}{ | |
| \hspace{-0.04in}\makebox[\textwidth - 16pt][l]{#1} | |
| }\else#1\fi} | |
| \DefineVerbatimEnvironment{CleanCode}{Verbatim} | |
| { | |
| frame=single, | |
| framesep=2mm, | |
| labelposition=topline, | |
| numbers=left, | |
| formatcom=\vspace{0.2in} | |
| } |
Then all I need to do is wrapper this environment around the code in question.
| \begin{CleanCode} | |
| //your comments | |
| var iables = and function(calls); | |
| \end{CleanCode} |
Cheers.