2

this is my style defined for C#:

\lstdefinestyle{CSharp}{
  language=[Sharp]C
  ,captionpos=b
  ,columns=fixed
  ,morekeywords={var,get,set}
  ,basicstyle=\footnotesize\ttfamily 
  ,keywordstyle=\color{blue}
  ,commentstyle=\color{ForestGreen}
  ,stringstyle=\color{BrickRed};
  ,breaklines=true
  ,tabsize=1
  ,showstringspaces=false
  ,showspaces=false
  ,showtabs=false
  ,breakatwhitespace=true
  ,escapeinside={(*@}{@*)}
  ,emph={double,bool,int,unsigned,char,true,false,void,get,set}
  ,emphstyle=\color{blue}
  ,lineskip={-1.5pt} % single line spacing
}

The problem is that for some reason, when the embedded strings are rendered, they look like this:

Console.WriteLine(;";S;:;String;");

but should:

Console.WriteLine("S:String");

I would appreciate any help.

3

The tell-tale hint is the presence of multiple semicolons just before each "token" (syntactic unit of characters) involved in the string.

If you inspect your source code, you'll find the line stringstyle=\color{BrickRed};, which is telling lstlisting to add a semicolon and switch the color to BrickRed each time a token inside a string is typeset. Get rid of the semi-colon and the problem should be fixed.

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.