# Change paragraph font and background color

I'm submitting a project that involves blocks of code.

I figured a nice way to present it by be that paragraphs of code are black text on a light gray background, in courier font.

I'm wondering if it would be possible to create an environment, called "code" for example, such that,

\begin{code}
...
...
\end{code}


would have the gray background, and be in courier font.

Any ideas would be greatly appreciated!

-
What kind of code? You should consider the listings package. –  Peter Grill Apr 8 '12 at 3:25

To use the courier font use,

 \renewcommand\ttdefault{pcr}


To define a code environment you can use the listings package.

 \documentclass{book}
%\usepackage[scaled=O.85]{luximono}
\usepackage{xcolor,listings}
\definecolor{theblue} {rgb}{0.02,0.04,0.48}
\definecolor{thered}  {rgb}{0.65,0.04,0.07}
\definecolor{thegreen}{rgb}{0.06,0.44,0.08}
\definecolor{thegrey} {gray}{0.5}
\definecolor{theframe}{gray}{0.75}

\renewcommand\ttdefault{pcr}

\lstnewenvironment{code}[1][]
{\lstset{language=[LaTeX]TeX}\lstset{%
escapeinside={{(*@}{@*)}},
breaklines=true,
framesep=5pt,
basicstyle=\ttfamily,
showstringspaces=false,
keywordstyle=\ttfamily\textcolor{thegreen},
stringstyle=\color{orange},
rulecolor=\color{gray!10},
breakatwhitespace=true,
showspaces=false,  % shows spacing symbol
xleftmargin=0pt,
xrightmargin=5pt,
aboveskip=0pt, % compact the code looks ugly in type
belowskip=0pt,  % user responsible to insert any skips
backgroundcolor=\color{gray!15}, #1
}}
{}

\begin{document}
\begin{code}
\let a=2+3
\end{code}
\end{document}

-
Looks beautiful! Thank you very much! –  AlmostSurely Apr 8 '12 at 16:26