# A phantom-like command that instead replaces the text with a horizontal line?

I'm trying to find a way of replacing part of text with a horizontal line. I'd like it to behave like the phantom command which replaces the text with an empty box of the correct width (and height), but instead put a horizontal line through the box.

As a specific example, I'm seeking something like a \phantomdash command, where adding it to text in this manner

Lorem ipsum dolor sit amet, \phantomdash{consectetuer adipiscing} elit...


would replace "consectetuer adipiscing" with a horizontal line of the width of the argument "consectetuer adipiscing".

Question: Is there a command for this already? If not, what is a way to achieve this?

-

censor can help in this regard:

\documentclass{article}
\usepackage{censor}% http://ctan.org/pkg/censor
\setlength{\censorruledepth}{.5ex}
\setlength{\censorruleheight}{.4pt}
\let\phantomdash\xblackout
\begin{document}
Lorem ipsum dolor sit amet, consectetuer adipiscing elit\ldots

Lorem ipsum dolor sit amet, \phantomdash{consectetuer adipiscing} elit\ldots

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse eget pharetra nisi, at cursus orci. Fusce ipsum justo, \ldots

Lorem ipsum dolor sit amet, consectetur adipiscing elit. \phantomdash{Suspendisse eget pharetra} nisi, at cursus orci. Fusce ipsum justo, \ldots
\end{document}

-
Thanks for that (this worked for me). And thanks for the other answers too! – Rebecca J. Stones May 1 '14 at 2:07
\documentclass{article}
\usepackage[normalem]{ulem}
\newcommand\phantomdash[1]{%
\uline{\phantom{#1}}%
}
\begin{document}
Lorem ipsum dolor sit amet, \phantomdash{consectetuer adipiscing} elit...
\end{document}


You can move the line up if you want so:

\documentclass{article}
\usepackage[normalem]{ulem}
\newcommand\phantomdash[1]{%
\setlength\ULdepth{-0.5ex}
\uline{\phantom{#1}}%
}
\begin{document}
Lorem ipsum dolor sit amet, \phantomdash{consectetuer adipiscing} elit...
\end{document}

-

I write a lot of documents where I create blanks for answers on quizzes and then fill in the blanks for an answer key or solution sheet. Here's the sort of approach I take to this.

\documentclass{article}

\makeatletter
\newlength\ae@tmp@length
\newcommand\phantomdash[1]{%%
\settowidth\ae@tmp@length{#1}%%
\rule[-0.25ex]{\ae@tmp@length}{0.4pt}%%
\else
#1%%
\fi}

\makeatother
\begin{document}

What is the antipode of the north pole?  \phantomdash{the south pole}.


 \IfFileExists{./.design/hide.answers.true}{\hideanswerstrue}{\hideanswersfalse}