1

I am using the listings package for LaTex to include GAMS-Code in my LaTex-file. The package does not support GAMS as a language. So I have to define the language like descriped in this article. In GAMS, after declaring a symbol there is place for an explanatory text. I want to make the listings package to recognize this as a comment, so I can set special color options and keywords are not formated as keywords. But I can only define comments by their delimiters and not by their position (starting the second word after certain keywords). So as an example the GAMS code contains

sets i decision variables

Then "decision variables" is the explanatory text and I want it to have a different color (blue). "variables" is a keyword but it should not be marked as one in my Latex-file because it is inside the explanatory text. Is there any chance of making the listings package recognizing the explanatory text as a comment. What would my LaTex command

\lstdefinelanguage{GAMS}{
    morekeywords={sets, variables,...}
    morecomment= <This should be the interesting part>

look like?

MattAllegro
  • 6,455
  • 5
  • 45
  • 52
Niclas von Caprivi
  • 709
  • 1
  • 7
  • 12
  • 1
    GAMS allows to put quotes (single and/or double quotes) around this explanatory text, so your example could look like this: Sets i "Decision variables"; Maybe you could always use that for the explanatory text and thus use the " as an additional comment character in LaTex? – Lutz Feb 12 '18 at 07:36
  • Seems like a good workaround. Thank you @Lutz, I will use that. – Niclas von Caprivi Feb 12 '18 at 07:40

0 Answers0