Consider the following MWE:





LaTeX fails with the error

! Undefined control sequence.
<to be read again> az
l.9     \MakeTextLowercase{A~B}


The error seems to lie in the combination of MakeTextLowercase, the listings package and the tilde. Whenever I remove any of these three components, everything works fine. Does anyone have a clue where the problem is?

  • linebreaks are important in tex error messages, I fixed your question to show the full errror. – David Carlisle Apr 4 '16 at 14:33

This is a bug in listings: it's globally setting


which is not sensible. TeX is then lower casing ~ to z and not finding a definition for an active z (oddly enough). I'd suggest simply fixing this with


immediately after


The bug itself is caused by the internal macro \lst@CCPut, which sets the \lccode for both ~ and / to a variety of values to set up internal data. Regrettably, this is not done in a group and there is no 'reset' code to put things back to normal, so we get 'junk' lower case mappings for these two code points.

  • Perfect answer - within minutes. Thanks! – user1742364 Apr 4 '16 at 15:00
  • 2
    I've reported this to the package maintainer: a fix is easy enough – Joseph Wright Apr 4 '16 at 15:02
  • @JosephWright have you ever heard anything back? – stefanct May 11 '19 at 17:02
  • @stefanct Nope, never heard anything – Joseph Wright May 11 '19 at 18:10

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.