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 am using LyX to describe algorithms. A common scenario is that I have a snippet of pseudo code (in a float, for example) and a block of text which makes references to keywords in that pseudo code. The listings package can do this, I think, but I recall having trouble using math notation, like subscripts, with listings. On the other hand, I have not been able to find how to use the algorithms package inline.

share|improve this question
up vote 1 down vote accepted

Not really what you asked for, but did you try the mathescape option in listings? (as in this StackOverflow answer)

It seems to do what you want for sub/superscripts (but a more precise example might lead to a different answer).

share|improve this answer

Unless you do anything special, keywords in the algorithms package are simply bold, so you could format those yourself, i.e. as in \mathbf{while}, when you need to refer to those keywords in the text.

share|improve this answer

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.