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.

enter image description here Someone who knows how to fill with color only the box?

\begin{shaded} 
\begin{lstlisting}

if (a < b)
 {
    printf("A is smaller than  B!\n");
 }
 a = b;

\end{lstlisting}
\end{shaded}
share|improve this question
2  
listings has a setting backgroundcolor=\color{gray} for this purpose. –  Stephan Lehmke Dec 9 '13 at 20:18
    
Thank you,works great! –  kostas Dec 9 '13 at 20:22
    
@StephanLehmke: Maybe convert your comment into an answer? –  Kevin C Dec 10 '13 at 21:19
    
@KevinC Done. I thought this must be a duplicate of something, but doesn't seem so :-) –  Stephan Lehmke Dec 11 '13 at 4:57
    
Since you have some responses below that seem to answer your question, please consider marking one of them as ‘Accepted’ by clicking on the tickmark below their vote count (see How do you accept an answer?). This shows which answer helped you most, and it assigns reputation points to the author of the answer (and to you!). It's part of this site's idea to identify good questions and answers through upvotes and acceptance of answers. –  Jubobs Jan 13 at 14:33

1 Answer 1

listings has a setting backgroundcolor=\color{gray} for this purpose:

\lstset{backgroundcolor=\color{gray}}
\begin{lstlisting}

if (a < b)
 {
    printf("A is smaller than  B!\n");
 }
 a = b;

\end{lstlisting}

See section 2.7 of the manual which you should get with texdoc listings.

share|improve this answer

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.