# Background color in Verbatim

I've to use the yellow background for data values in the following code.

\usepackage
\begin{Verbatim}[commandchars=\\\{\}]
\color{blue}DATA \color{black}Heart;
\color{blue}INPUT \color{black}X Y @@;
\color{blue}DATALINES\color{black};
28 70 23 68 52 90 42 75 27 68
29 80 43 78 34 70 40 80 28 72
;
\color{blue}RUN\color{black};

\color{blue}PROC REG DATA\color{black}=Heart;
\color{blue}MODEL \color{black}Y=X;
\color{blue}RUN\color{black};

\end{Verbatim}


Any help will be highly appreciated.

Your question do not state that you are using the fancyvrb package? I do not see a background color option in the package, but for short snipits, use the SaveVerbatim environment and save it to box. Put the contents then in a colorbox

\documentclass{article}
\usepackage{fancyvrb}
\usepackage{color}
\begin{document}
\begin{SaveVerbatim}[commandchars=\\\{\}]{SVerbEnv}
\color{blue}DATA \color{black}Heart;
\color{blue}INPUT \color{black}X Y @@;
\color{blue}DATALINES\color{black};
28 70 23 68 52 90 42 75 27 68
29 80 43 78 34 70 40 80 28 72
;
\color{blue}RUN\color{black};

\color{blue}PROC REG DATA\color{black}=Heart;
\color{blue}MODEL \color{black}Y=X;
\color{blue}RUN\color{black};
\end{SaveVerbatim}
\fcolorbox{black}{yellow}{\BUseVerbatim{SVerbEnv}}
\end{document}


Alternative you can use the framed package to get mutipage stuff

\documentclass{article}
\usepackage{fancyvrb}
\usepackage{framed}
\usepackage{color}
\begin{document}
\begin{Verbatim}[commandchars=\\\{\}]
\color{blue}DATA \color{black}Heart;
\color{blue}INPUT \color{black}X Y @@;
\color{blue}DATALINES\color{black};
28 70 23 68 52 90 42 75 27 68
29 80 43 78 34 70 40 80 28 72
;
\color{blue}RUN\color{black};

\color{blue}PROC REG DATA\color{black}=Heart;
\color{blue}MODEL \color{black}Y=X;
\color{blue}RUN\color{black};
\end{Verbatim}
\end{document}


For the data lines only put it in a \colorbox

\documentclass{article}
\usepackage{fancyvrb}
\usepackage{color}
\begin{document}
\begin{Verbatim}[commandchars=\\\{\}]
\color{blue}DATA \color{black}Heart;
\color{blue}INPUT \color{black}X Y @@;
\color{blue}DATALINES\color{black};
\colorbox{yellow}{28 70 23 68 52 90 42 75 27 68}
\colorbox{yellow}{29 80 43 78 34 70 40 80 28 72}
\colorbox{yellow}{;                            }
\color{blue}RUN\color{black};

\color{blue}PROC REG DATA\color{black}=Heart;
\color{blue}MODEL \color{black}Y=X;
\color{blue}RUN\color{black};
\end{Verbatim}
\end{document}

• Thanks for your answer. Given code works fine but I need yellow background around only ( 28 70 23 68 52 90 42 75 27 68 29 80 43 78 34 70 40 80 28 72 ;) within Verbatim. – MYaseen208 Apr 16 '11 at 5:32
• @MYaseen208: Your question is realy unclear on what you want. For the line you request, put them in a colorbox (see the 3rd listing in the answer) – Danie Els Apr 16 '11 at 5:41
• Thanks a lot. Eventually I got it. Thanks for your help. – MYaseen208 Apr 16 '11 at 6:03