Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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.

share|improve this question

1 Answer 1

up vote 5 down vote accepted

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}
\definecolor{shadecolor}{cmyk}{0,0,1,0} %yellow
\begin{document}
\begin{shaded}
\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{shaded}
\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}
share|improve this answer
    
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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.