7

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}
8

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}
  • Yep, did not occur to me to try that. Any idea why that is the case? – Peter Grill Aug 3 '11 at 5:38
  • No, unfortunately not. I assume once the day starts in Europe, the real TeXperts will quickly solve this. – Jake Aug 3 '11 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. – Ulrike Fischer Aug 3 '11 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). – Martin Scharrer Aug 3 '11 at 8:18

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.