TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question

migrated from stackoverflow.com Aug 26 '11 at 11:54

This question came from our site for professional and enthusiast programmers.

up vote 18 down vote accepted

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.14 Escaping to LaTeX.

share|improve this answer
Is there a default? I couldn't find it quickly. From what I understand there is no default. – Sam Stoelinga Oct 23 '13 at 9:13

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.