tags:

views:

46

answers:

2

This is a screen capture from Pragmatic Bookshelf book.

It looks like that the verbatim environment with the coloring, but I'm not sure.

How can one can use color for verbatim like environment as is shown?

Using line by line method would be a solution, but I expect a better way to go.

{\color{red}\begin{verbatim}
line 1
     line 2
\end{verbatim} }
\color{blue}{\begin{verbatim}
line 3
     line 4
\end{verbatim}}
+3  A: 

You can use the fancyvrb package. It includes options for colouring, so you can just use multiple Verbatim environment blocks.

igorw
+2  A: 

You can use the listings package also:

\lstinputlisting[language=Ruby]{source_filename.rb}

Or

\begin{lstlisting}
\end{lstlisting}
DiggyF