I'm using the solution here for scala support, but this fails to properly color the scala code, and throws a number of errors when processing lstset – % ! Package keyval Error: breakatwhitespace undefined.
Can anyone help me figure out what's wrong with this simple example?
\documentclass[journal]{IEEEtran}
\usepackage{listings}
% "define" Scala
\lstdefinelanguage{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]"""
}
\usepackage{color}
\definecolor{dkgreen}{rgb}{0,0.6,0}
\definecolor{gray}{rgb}{0.5,0.5,0.5}
\definecolor{mauve}{rgb}{0.58,0,0.82}
\lstset{frame=tb,
language=scala,
aboveskip=3mm,
belowskip=3mm,
showstringspaces=false,
columns=flexible,
basicstyle={\small\ttfamily},
numbers=none,
numberstyle=\tiny\color{gray},
keywordstyle=\color{blue},
commentstyle=\color{dkgreen},
stringstyle=\color{mauve},
frame=single,
breaklines=true,
breakatwhitespace=true
tabsize=3
}
% A number of keyval errors occur here - basically
% nothing in lstset is recognized. Errors look like:
% ! Package keyval Error: breakatwhitespace undefined.
\begin{document}
\begin{lstlisting}
object Test {
def main(args: Array[String]) {
var a = 0;
// for loop execution with a range
for( a <- 1 to 10){
println( "Value of a: " + a );
}
}
}
\end{lstlisting}
\end{document}
EDIT: After adding in \listfiles
, here's the file list I see
*File List*
IEEEtran.cls 2007/03/05 V1.7a by Michael Shell
ot1ptm.fd 2001/06/04 font definitions for OT1/ptm.
xspace.sty 2009/10/20 v1.13 Space after command names (DPC,MH)
epsfig.sty 1999/02/16 v1.7a (e)psfig emulation (SPQR)
graphicx.sty 1999/02/16 v1.0f Enhanced LaTeX Graphics (DPC,SPQR)
keyval.sty 1999/03/16 v1.13 key=value parser (DPC)
graphics.sty 2009/02/05 v1.0o Standard LaTeX Graphics (DPC,SPQR)
trig.sty 1999/03/16 v1.09 sin cos tan (DPC)
graphics.cfg 2010/04/23 v1.9 graphics configuration of TeX Live
pdftex.def 2011/05/27 v0.06d Graphics/color for pdfTeX
infwarerr.sty 2010/04/08 v1.3 Providing info/warning/error messages (HO)
ltxcmds.sty 2011/11/09 v1.22 LaTeX kernel commands for general use (HO)
url.sty 2006/04/12 ver 3.3 Verb mode for urls, etc.
cite.sty 2010/09/10 v 5.3
fancybox.sty 2010/05/15 1.4
listings.sty 2007/02/22 1.4 (Carsten Heinz)
lstmisc.sty 2007/02/22 1.4 (Carsten Heinz)
listings.cfg 2007/02/22 1.4 listings configuration
color.sty 2005/11/14 v1.0j Standard LaTeX Color (DPC)
color.cfg 2007/01/18 v1.5 color configuration of teTeX/TeXLive
lstlang1.sty 2004/09/05 1.3 listings language file
lstlang1.sty 2004/09/05 1.3 listings language file
supp-pdf.mkii
pdftexcmds.sty 2011/11/29 v0.20 Utility functions of pdfTeX for LuaTeX (HO)
ifluatex.sty 2010/03/01 v1.3 Provides the ifluatex switch (HO)
ifpdf.sty 2011/01/30 v2.3 Provides the ifpdf switch (HO)
epstopdf-base.sty 2010/02/09 v2.5 Base part for package epstopdf
grfext.sty 2010/08/19 v1.1 Manage graphics extensions (HO)
kvdefinekeys.sty 2011/04/07 v1.3 Define keys (HO)
kvoptions.sty 2011/06/30 v3.11 Key value format for package options (HO)
kvsetkeys.sty 2012/04/25 v1.16 Key value parser (HO)
etexcmds.sty 2011/02/16 v1.5 Avoid name clashes with e-TeX commands (HO)
epstopdf-sys.cfg 2010/07/13 v1.3 Configuration of (r)epstopdf for TeX Live
ot1pcr.fd 2001/06/04 font definitions for OT1/pcr.
sections/introduction.tex
sections/background.tex
sections/challenges.tex
sections/solution.tex
figures/vnc-overview.pdf
sections/results.tex
omsptm.fd
figures/client-heap.png
figures/master-heap.png
sections/relatedwork.tex
sections/conclusion.tex
clasp.bbl
Best Answer
As noted by Peter in his comments, your TeX distribution seems badly out of date. Time to blow the rust off it, and fire up your package manager.
Also, you're missing a comma after
breakatwhitespace=true
.Besides, since October 2013, the
listings
package comes with a language definition for Scala (in thelstdvrs.dtx
file). If you update your TeX distribution, you shouldn't have to redefine that language from scratch in your.tex
file in order to use it.