12

As far as I know, the Scala programming language is not supported by the listings package. Is an implementation under way? Will it be included in the standard listings distribution?

1
  • 3
    Once I had the same problem with another programming language. I defined it myself and send the result to the listings-maintainer. In the next release it was added. When you look to lstdrvrs.dtx you can find a lot of authors.
    – knut
    Mar 7 '12 at 22:32
19

Shamelessly pinched from this site, the following provides a Scala language definition for listings. Simply place it in your preamble, and use listings in the normal way.

% "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]"""
}
1
  • 1
    Thanks, a lot of keywords are missing, though. Like Unit, Boolean, Int... Other than that, thanks for the TeX code. :) May 14 '14 at 16:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.