4

I'm using \leaders to make a flexible width rule, with the statement \leaders 0pt plus 1fil\hrule, but I also want to put text above this line. \rlap{text}\leaders works fine, except that the text is very close to the line (which isn't very aesthetic). I like the look of \underbar{text}, but I need the line to extend further, so I'm trying to use a more generic \leaders to accomplish this. This can't be done with a \vbox, as far as I can tell because once in a box that is not the one I'm trying to format, the glue doesn't expand as far as I'd like. So, I'm trying to use \lower 2pt\leaders. This fails because \lower requires a box as an argument. I had the thought that this might be improved by using a box, but there still has to be a leader statement for the box to be full size, and I can't find a way to set, for example, \box0, to be this size (which appears impossible because if the box is already constructed, it's inflexible). I've tried both using \lastbox and setting the box directly, but neither works because the box is already constructed.

The final product I imagine will look something like this minimal nonworking example (or maybe it will use a box with depth or another trick):

\line{\hfil\leaders\hbox{\lower2pt\hrule}\hfil}

It appears to me that this doesn't obviously violate any part of the TeX boxes-and-glue model, so I expect that it's possible. How can I construct this?

3

1 Answer 1

5

The issue with a construction like \leaders\vtop{\vskip2in\hrule width 1pt} is that leaders behave differently if used with a box instead of a rule: Instead of always filling the full width, you only get full copies of the box. So it is better to stay with a simple rule.

You can't easily \lower a rule, but you can draw it lower fro the beginning. A \hrule by default has height 0.4pt, depth 0pt, so to get a rule 2pt lower, you can use

abc
\rlap{text}\leaders\hrule height -1.6pt depth 2pt\hfil
\penalty-10000 % Make sure that we actually have some space to fill
some more text
\bye

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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