1

Sorry, but I am so bad in English. I try my best to describe my problem.

Here is an example

\usepackage{ulem}
\usepackage{xparse}
\NewDocumentCommand{\test}{o m}{
    % #1#2
}
\begin{document}

%\uline{\test[ab]{c d}}  %fine
\uline{\test[a b]{c d}}

\end{document}

log:

Runaway argument?
\ERROR {c d}\xdef \UL@spfactor {\the \spacefactor } \UL@end *  
./test.tex:60: Paragraph ended before \test  was complete.
<to be read again> 
                   \par 
l.60 
     
I suspect you've forgotten a `}', causing me to apply this
control sequence to too much text. How can we recover?
My plan is to forget the whole thing and hope for the best.

\uline{\test[ab]{c d}} is fine.

but \uline{\test[a b]{c d}} raised an error, where the difference between them is the optional argument [ab] and [a b] (there is a white space between a and b).

What should I do if I want something like \uline{\test[a b]{c d}} to work fine?

thanks!

2
  • Not quite sure why, but \uline{\test[{a b}]{c d}} works.
    – Teepeemm
    Apr 26 at 17:50
  • @Teepeemm thank you.
    – hua
    Apr 29 at 12:09

1 Answer 1

1

\uline starts off its job by splitting its argument at spaces. Those inside braces are not taken into account when doing this splitting, but there's no way to exclude from consideration those appearing in brackets. This ends up in examining \test[a as a single chunk, which will break.

\test[{a b}]{c d} should do.

Maybe you've better luck with lua-ul (which requires LuaLaTeX).

1
  • Thank you. \test[{a b}]{c d} it works.
    – hua
    Apr 29 at 12:07

You must log in to answer this question.

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