Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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}
share|improve this question

1 Answer 1

up vote 6 down vote accepted

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}
share|improve this answer
    
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

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.