I have happily used the fancyvrb
package with the Verbatim
environment so far, but I want to change my figures to use the listing
package with the lstlisting
environment in order to have bold-faced keywords which improve readability.
Unfortunately, I have no clue to adjust the listing settings to get the same (very nice) font I had before with fancyvrb...
Here is my fancy verb settings:
% fancy verb
\usepackage[T1]{fontenc}
\usepackage{fancyvrb}
\usepackage{relsize}
\fvset{fontfamily=fvm}
\fvset{fontsize=\relsize{-2}}
\fvset{baselinestretch=1.3}
And here for listings, using the Scala language:
% listings
\usepackage{listings}
\lstdefinelanguage{scala}{ % "define" Scala
morekeywords={abstract,case,catch,class,def,do,else,extends,false,final,%
finally,for,if,implicit,import,match,mixin,new,null,object,override,package,%
private,protected,requires,return,sealed,super,this,throw,trait,true,try,%
type,val,var,while,with,yield},
otherkeywords={=>,<-,<\%,<:,>:,\#,@},
sensitive=true,
morecomment=[l]{//},
morecomment=[n]{/*}{*/},
morestring=[b]",
morestring=[b]',
morestring=[b]"""
}
\lstset{ % activate the language and predefine settings
language=scala,%
fontadjust=true,%
columns=[c]fixed,%
keepspaces=true,%
basewidth={0.58em, 0.53em},%
tabsize=2,%
basicstyle=\renewcommand{\baselinestretch}{0.95}\ttfamily,%
commentstyle=\itshape,%
keywordstyle=\bfseries,%
mathescape=true,%
escapechar=€,%
captionpos=b,%
framerule=0.3pt,%
firstnumber=0,%
numbersep=1.5mm,%
numberstyle=\tiny,%
}
And here is the document body contrasting both:
\documentclass{article}
% ... paste the fancy verb and listing settings from above here
\begin{document}
\begin{Verbatim}
object Stream {
def cons[A](hd: A, tl: => Stream[A]) = new Stream[A] {
def head = hd
lazy val tail = tl
...
}
}
\end{Verbatim}
\begin{lstlisting}
object Stream {
def cons[A](hd: A, tl: => Stream[A]) = new Stream[A] {
def head = hd
lazy val tail = tl
...
}
}
\end{lstlisting}
\end{document}
Neither does the font of listing look remotely like the T1/fancyvrb one, nor does LaTeX seem to pay attention to setting the keywords in bold-face:
I guess I need to change the basicstyle
entry, but how?
listings
together withfancyvrb
? See the according section in documentation oflistings
.