With the following LaTeX file I get the error message

! Extra }, or forgotten \endgroup.
<argument> {\lstinline {""}}

l.11 \cmd{{\lstinline{""}}}

Commenting out \usepackage[german]{babel} makes the file compile.






My goal is to have an empty string "" plus some further strings within some text, and since I use \lstinline extensively otherwise, I would prefer to format those strings with \lstinline as well. A potential workaround could be to format those strings without help of the listings package, but maybe there is a better solution.

For your reference: I also checked out Possible incompatibility between babel, listings and arsclassica and Textcase, Listings, and Tilde, but although it seemed to be a similar situation, this appears to be a different problem.

  • 2
    If you have \lstinline in the argument to another command, listings cannot do its normal job with category codes. A verbatim command (and \lstinline is included) should never appear as the argument to another command. What's the real purpose of \cmd?
    – egreg
    Mar 6, 2020 at 18:36
  • 1
    Off-topic: Unless you must adhere to the pre-1997 orthography rules, you should specify the option ngerman, not german, when loading the babel package.
    – Mico
    Mar 6, 2020 at 18:48
  • @egreg: I have stripped down my code to a minimal working example. I use several commands in my document: Some are just for being able to create different versions of the document (sometimes with solutions shown, sometimes not, so I only have to centrally change a command), some are for factoring out common formatting stuff, so I can centrally change formatting. Mar 6, 2020 at 20:25
  • 1
    @DirkHerrmann I understand, but the problem remains. Maybe a workaround can be found for ", but there are several other things that can and will go wrong when \lstinline is in the argument to another command.
    – egreg
    Mar 6, 2020 at 20:26
  • 1
    @DirkHerrmann That's why I asked about the intended working of \cmd.
    – egreg
    Mar 6, 2020 at 20:34


You must log in to answer this question.

Browse other questions tagged .