# Get the Length of the Rest of a Line [duplicate]

Possible Duplicate:
Is there a way to measure the remaining space of a line of text?

I have some text and want to put a \hrulefill at the end following by a period. However, if the text of the line comes too close to the end of the line, the rule is omitted and just a period results -- or -- a new line is created, the rule is omitted, and the line begins with a period.

How can I determine if there is enough space at the end of the line for a sizeable enough hrulefill of some specified length?

-

## marked as duplicate by Peter Grill, Leo Liu, lockstep, Joseph Wright♦Dec 2 '11 at 8:17

As @Ben said this is actually a duplicate in the general case. However, if Phil's answer does it for you as well I would accept it and the question could stay, under a different, more specific title. –  Martin Scharrer Sep 15 '11 at 6:28

How about the following (using ideas from the command \qed in amsart.cls):
\newcommand{\myrulefill}{\unskip\penalty9999 \hbox{}\nobreak\hrulefill

That guarantees you at least 1em of hrulefill (you can change that 1em to some other length, of course), and prevents the hrulefill from being on a line by itself. You'd just put the command \myrulefill at the end of your paragraph.