Why is this snippet:


rendered to this?


and not the intended:

  • I believe that url makes use of verbatim. – Sigur Apr 8 '13 at 14:32
  • You are probably right @Sigur, but why does \Subject{} get expanded but not \lowercase? – SlimJim Apr 8 '13 at 14:33
  • \lowercase is not an expandable command. – David Carlisle Apr 8 '13 at 14:34
  • @sigur: url proves a \verb-like command but does not use verbatim to do so. – Matthew Leingang Apr 8 '13 at 15:52

\lowercase (and {}) are not expandable so you need to change the order of execution:







If you need to remove space you need to use expansion only if you are not going to interfere with \url. Fortunately LaTeX has a built-in command to remove spaces via expansion:

\newcommand{\Subject}{Skeleton bones}
  \edef\tmp{\lowercase{\noexpand\url{http://www.cheatsheet.jim.pm?subject=\zap@space#1 \@empty}}}%


  • it works but I have no clue how, know I want to remove spaces from the \Subject with \StrSubstitute{#1}{ }{} but I cannot get it to compile and show properly, I tried putting inside the lcURL at different places as well as a function RemoveSpace that mimics the magic from lcURL but all in vain. The most common error is ! Argument of \reserved@a has an extra }. – SlimJim Apr 8 '13 at 21:41
  • 1
    I don't think \StrSubstitute works via expansion so it will interfere with \url, see update. – David Carlisle Apr 8 '13 at 22:04

Just to see how one can use \StrSubstitute in this context:


\newcommand{\Subject}{Ske Le Ton}

  \StrSubstitute{#1}{ }{}[\tmp]%





With \begingroup and \endgroup we make sure that any definition of \tmp vanishes after usage.

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.