Stenographic staining?

This is a screen capture from the book Pragmatic Bookshelf.

http://img13.imageshack.us/img13/3168/screenshot20100717at123.png

It seems like a verbatim medium with coloring, but I'm not sure.

How can color be used for shorthand environments as shown?

Using the line by line method will be a solution, but I expect you to be better.

{\ color {red} \ begin {verbatim}
line 1
     line 2
\ end {verbatim}}
\ color {blue} {\ begin {verbatim}
line 3
     line 4
\ end {verbatim}}
+5
source share
3 answers

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

+4
source

fancyvbr

\documentclass[a4paper,10pt]{scrartcl}
\usepackage{color}
\usepackage[utf8]{inputenc}
\usepackage{fancyvrb}
\usepackage[usenames,dvipsnames]{xcolor}

\fvset{frame=single,framesep=1mm,fontfamily=courier,fontsize=\scriptsize,numbers=left,framerule=.3mm,numbersep=1mm,commandchars=\\\{\}}

\begin{document}
   \begin{Verbatim}[label={My orange command sample output}]
# \textcolor{Orange}{My orange command}
My black output
that it can be
many lines long
but this specific \textbf{\textcolor{OliveGreen}{word}}
and the following 2
\textbf{\textcolor{red}{lines are important so they}}
\textbf{\textcolor{red}{need to be highlighted and bold}}
   \end{Verbatim}
\end{document}

Sample output of this code

+17

listings:

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

\begin{lstlisting}
\end{lstlisting}
+3

All Articles