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.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question

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

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

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
  \hbox to 1em{\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.

share|improve this answer
I implemented this and it works like a charm! Thanks for everyone's help. Sorry for the duplicate. – Doug Sep 15 '11 at 21:10
@Doug: No problem. This is a specific case and therefore not an exact duplicate. Please accept this answer then by clicking the tick mark on the top left of it. Thanks. – Martin Scharrer Sep 16 '11 at 7:04

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