Consider the following MWE:

\documentclass{scrreprt}

\usepackage{textcase}

\RequirePackage{listings}
\usepackage[american]{babel}

\begin{document}
    \MakeTextLowercase{A~B}
\end{document}

LaTeX fails with the error

! Undefined control sequence.
<to be read again> az
                     b
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
up vote 5 down vote accepted

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

\lccode`\~=`\z

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

\lccode`\~=0\relax

immediately after

\usepackage{listings}

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
  • 1
    I've reported this to the package maintainer: a fix is easy enough – Joseph Wright Apr 4 '16 at 15:02

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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