I want to implement a command like these:






It seems, that lstlisting interpretes the argument #1 as code not as argument.

How to force lstlisting to take #1 as argument?

  • 1
    Why would you want to do that? Use the commands provided by listings to create new envrionments or inline commands. Your command currently looks like \lstinline. – TeXnician May 29 '18 at 8:07
  • It becomes more complex later on. This is only the example for this question. – Alex44 May 29 '18 at 8:08
  • 3
    you can not, in general, use any verbatim command (including listings) in the argument of another command. – David Carlisle May 29 '18 at 8:10
  • Could you please explain at which point the commands provided by listings aren't sufficient? – TeXnician May 29 '18 at 8:11
  • There is nothing insufficient. It is only for formatting / pre-defining minipages. There are some hundreds code snippets which shall displayed always in the same format. – Alex44 May 29 '18 at 8:14

You can define new inline versions of \lstinline like this. The important point is not to use a (mandatory) argument so that \lstinline can do its own magic.





enter image description here

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.