I am trying to define a command with xparse that takes an optional argument but no mandatory argument. The optional argument is a number, which works fine with a single digit but not with more. The command is as follows:
\usepackage{xparse}
\usepackage{xspace}
\NewDocumentCommand \HL { o } {\IfNoValueTF #1 {\emph{HL}\xspace}{\emph{HL} {#1}\xspace}}
\HL
(\HL[1])
(\HL[10])
I want the following result:
HL
(HL 1)
(HL 10)
But I get this:
HL
(HL 1)
(HLHL 10)
\IfNoValueTF{#1}
: you're missing the braces.