In the language I am defining in listings, text put inside {* and *} is commented out. I tried to implement this as morecomment = [s]{{*}{*}}, but understandably LaTeX gets the nesting confused. The result is that text placed between two * is commented out.

1 Answer 1


{* must be written as \{*, the same holds for *}: *\}.

The same escaping mechanism must be used for #, % and \ itself, i.e. \#, \% and \\. (This is actually stated multiple times in the listings.pdf manual)

I've 'misused' the Gnuplot language to define as additional comments {*...*}


\lstset{language=Gnuplot,morecomment = [s]{\{*}{*\}},commentstyle={\bfseries \color{blue}}}

  # A gnuplot comment
  plot sin(x) lt 2
  {* *}

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .