\documentclass[dvipsnames,cmyk]{article}
\usepackage{listings,xcolor}
\lstset
{
breaklines=true,
tabsize=3,
showstringspaces=false
}
\lstdefinestyle{Common}
{
extendedchars=\true,
language={[Visual]Basic},
frame=single,
%===========================================================
framesep=3pt,%expand outward.
framerule=0.4pt,%expand outward.
xleftmargin=3.4pt,%make the frame fits in the text area.
xrightmargin=3.4pt,%make the frame fits in the text area.
%===========================================================
rulecolor=\color{Red}
}
\lstdefinestyle{A}
{
style=Common,
backgroundcolor=\color{Yellow!10},
basicstyle=\scriptsize\color{Black}\ttfamily,
keywordstyle=\color{Orange},
identifierstyle=\color{Cyan},
stringstyle=\color{Red},
commentstyle=\color{Green}
}
\lstdefinestyle{B}
{
style=Common,
backgroundcolor=\color{Black},
basicstyle=\scriptsize\color{White}\ttfamily,
keywordstyle=\color{Orange},
identifierstyle=\color{Cyan},
stringstyle=\color{Red},
commentstyle=\color{Green}
}
\begin{document}
\begin{description}
\item[Visual Basic] is a programming language from Microsoft.
\begin{lstlisting}[style=A]%please try style=B
Option Explicit
Sub Signal(strSignalfolge As String, Optional lngTakt As Long = 100)
'Prozedur erzeugt eine Serie von Warntönen.
'Die optionale Variable lngTakt gibt den Takt in Millisekunden vor (Standard: 100 ms)
'Das Muster kann über die String-Variable strSignalfolge beeinflusst werden:
' Stern (*) -> 1 Warnton
' Ziffern 1..9 -> 1..9 Takte Pause
' Leerzeichen -> 1 Sekunde Pause
' Minus (-) -> 1.5 Sekunden Pause
End Function
\end{lstlisting}
\item[Visual CSharp] is my favourite programming language.
\end{description}
\end{document}
The credits should go to Martin Scharrer. It is possible with the listings
package:
\documentclass{article}
\usepackage{listings,color}
\definecolor{verbgray}{gray}{0.9}
\lstnewenvironment{code}{%
\lstset{backgroundcolor=\color{verbgray},
frame=single,
framerule=0pt,
basicstyle=\ttfamily,
columns=fullflexible}}{}
\definecolor{shadecolor}{rgb}{.9, .9, .9}
\begin{document}
text
\begin{code}
line one
line two
\end{code}
\end{document}
This document works with tex4ht
and pdftex
.
Best Answer
Here is a solution inspired by the code of the
moreverb
package and using code lines of it: