# How do I add text above a long underscore in Plain Tex?

This is a follow-up to this question and the requirement for Plain TeX is still in place.

I am trying to create the effect of floating a string (date) above the long underscore I create using the first method in the accepted answer.

This is the closest I have come, but obviously the underline does not match up with the underscore.

Date \hskip 1 pt \underbar{12-25-2014} \vrule height .4pt width 7cm


Split the rule into two parts and add the text as a zero width box in the middle; in order to enhance the “floating” character, I slightly raised the box.

\def\filltospace#1#2{{%
\dimen0=#1\relax
\dimen0=.5\dimen0
\vrule height -3pt depth 3.4pt width \dimen0
\raise1pt\hbox to 0pt{\hss#2\hss}%
\vrule height -3pt depth 3.4pt width \dimen0
}}

Date \filltospace{7cm}{12-25-2014}

\bye


Adding variations about the positioning (not at the center, that is) is easy.

foo $\underline{\hbox to 7cm{\hss12-25-2014\hss}}$ bar
\bye


• Was does \hss do? I've never heard of this command before. – Svend Tveskæg Dec 26 '14 at 11:56
• inserts infinitely stretchable and shrinkable horizontal glue, like \hfill in LaTeX – user2478 Dec 26 '14 at 11:59
• \hss and hfill are both primitives so also defined in latex, \hfill only has stretch component, not shrink \hss has both. – David Carlisle Dec 26 '14 at 13:08
• I get an error on \underline. This may not be available in plain tex. – merlin2011 Dec 26 '14 at 17:22
• do you forgot hte $...$? it is a math command – user2478 Dec 26 '14 at 18:32

If you need to keep the rule created by \vrule height -3pt depth 3.4pt width 7cm then you can write:

Date \rlap{12-25-2014}\vrule height -3pt depth 3.4pt width 7cm