Listings package: otherkeywords / comments questionAdd tags
2 posts
• Page 1 of 1
Listings package: otherkeywords / comments questionHi there,
I've been using the Listings package to develop a new language definition to display some source code for an academic project I'm working on. The language I want to display has various assignment operators akin to <=, <-, :=: etc. and I've declared them in the otherkeywords section. The problem I'm having is that when styling my comments to appear green the operators declared as otherkeywords don't get styled by the comment style and remain their original keyword style. The confusing thing is that the otherkeywords style is set using the keywordstyle command and the keywords themselves behave normally within a commented section.
If anyone could give me any pointers or advice I'd really appreciate it.
Re: Listings package: otherkeywords / comments questionI found a way around the problem by using the classoffset and declaring the otherkeywords as more keywords instead.
For future reference here is the amended version: % My language definition \lst@definelanguage[]{OPL}% { classoffset=0, keywords={maximize, minimize, subject, to, forall, sum, solve, int, int+, float, float+, enum, ftoi, mod, abs, maxint, sqrt, ceil, floor, distToInt, frac, trunc, infinity, first, last, card, ord, next, prev, range, in, struct, prod, min, max, union, inter, not, initialize, var, dmin, dmax, dsize, bound, dnexthigher, alldifferent, circuit, distribute, try, endtry, tryall, if, endif, then, else, while, select, once, search, when, onValue, generate, generationMin, generationMax, generateSeq}, keywordstyle=\color{eclipse-keywords}\bfseries, classoffset=1, morekeywords={..,=,<,>,<=,=>,==}, keywordstyle=\color{black}\bfseries, classoffset=0, comment=[l][\color{eclipse-comments}]{//},% morecomment=[s][\color{eclipse-comments}]{/*}{*/},% string=[b][\color{eclipse-strings}]\``,% morestring=[b][\color{eclipse-strings}]',% basicstyle=\sffamily, tabsize=4, showstringspaces=false, numbers=left, %% number lines numberstyle=\tiny, %% the style of the numbers in the side numberblanklines=true, showspaces=false, showtabs=false, }[keywords,comments,strings]%
2 posts
• Page 1 of 1
Who is onlineUsers browsing this forum: No registered users and 10 guests |





