The \hrulefill command could draw rubber length underlines, like abc___def. I just want to draw line in the vertical centre of a text, like abc---def. Thanks.
Asked
Active
Viewed 4,131 times
2 Answers
12
The xhfill package provides different leader commands to do exactly this:

\documentclass{article}
\usepackage{xhfill}% http://ctan.org/pkg/xhfill
\setlength{\parindent}{0pt}% Just for this example
\begin{document}
abc\xrfill{1pt}xyz \par
abc\xrfill[.5ex]{.4pt}xyz
\end{document}
Specifically regarding your question, \xrfill[<raise>]{<width>} prints a rule of width <width> raised <raise> from the baseline. Other leader options are also provided by the package. See the documentation for more examples.
For drawing a rule of specific (rather than rubber) length, you can always use a regular raised \rule:

\documentclass{article}
\setlength{\parindent}{0pt}% Just for this example
\begin{document}
abc\hspace{4cm}xyz \par
abc\raisebox{.5ex}{\rule{4cm}{.4pt}}xyz
\end{document}
Werner
- 603,163
3
The command \leaders is intended for such things. In your case you can write
abc\leaders\hrule depth -2pt height 2.4pt\hskip 10pt plus 1fill xyz
to get a rule of height 0.4pt raised 2pt above the baseline with minimum width 10pt.
Andrew Swann
- 95,762
xhfillonly works in latex. – Andrew Swann Aug 03 '12 at 09:40