8

In responding to how to typeset a Long underscore in LaTeX, I attempted to use a \phantom with \ul, but end up Argument of \makeph@nt has an extra }. So, what is the proper way to use a \phantom command in such a situation.

\documentclass{article}
\usepackage{xcolor}%
\usepackage{soul}%

\newcommand{\UnderlineText}[2][red]{\setulcolor{#1}\ul{#2}}%

\begin{document}
    Signature: \UnderlineText[blue]{Sign here}

    %Signature: \UnderlineText[blue]{\phantom{Sign here}}% Error if un-commented.
\end{document}

1 Answer 1

10

If you wrap the \phantom{...} in an extra set of curly braces, the code works:

\documentclass{article}
\usepackage{xcolor}%
\usepackage{soul}%

\newcommand{\UnderlineText}[2][red]{\setulcolor{#1}\ul{#2}}%

\begin{document}
    Signature: \UnderlineText[blue]{{\phantom{Sign here}}}
\end{document}
4
  • Yep, did not occur to me to try that. Any idea why that is the case? Commented Aug 3, 2011 at 5:38
  • No, unfortunately not. I assume once the day starts in Europe, the real TeXperts will quickly solve this.
    – Jake
    Commented Aug 3, 2011 at 5:39
  • 4
    Simply read section 2 of the documentation. It describes what must be protected inside a soul argument and how you can do it. Commented Aug 3, 2011 at 7:55
  • 4
    AFAIK soul reads the content of its macros token (or brace group) by token and so splits the \phantom and its argument apart. It has an internal list of macro to officially support (like the \textxx format macros), but fails on macros unknown to it (it can't know how many arguments they have). Wrapping the whole thing in braces will make soul take it as one unit. However, line breaking might not be done for these (AFAIK soul boxes all single units). Commented Aug 3, 2011 at 8:18

You must log in to answer this question.

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