[Tex/LaTex] How to use LaTeX-commands inside of a listing


I'm using the listings package in a LaTeX document. It works great, but it doesn't allow me to put LaTeX commands inside of the listing. I would like to use a counter to enumerate some of the interesting parts in the source code.

Is there a way to enable LaTeX commands in source listings?

Best Answer

OK, found the answer. You can use escapechar=<char> to set a character that will escape you to the latex mode. See The Listings Package, 4.3.13 Escaping to LaTeX.