5

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?

1
  • linebreaks are important in tex error messages, I fixed your question to show the full errror. Commented Apr 4, 2016 at 14:33

1 Answer 1

5

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.

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .