I have the following example, which draws a vertical line at the top of the paper:
\def\makeheadline{
\setbox0=\hbox to 0pt{\hskip-1in\hskip15cm \vrule depth 3cm \hss}
\ht0=0pt \dp0=0pt
\vbox to 0pt{\vskip-1in \box0 \vss}
% orignal \makeheadline follows
\vbox to 0pt{\vskip-22.5pt
\line{\vbox to 8.5pt{}\the\headline}\vss}\nointerlineskip}
Hello World!
\bye
Now I want to add an additional horizontal line. I tried it this way:
\def\makeheadline{
\setbox0=\hbox to 0pt{\hskip-1in\hskip15cm \vrule depth 3cm \hss}
\ht0=0pt \dp0=0pt
\setbox0=\hbox to 0pt{\hskip-1in \hrule width 15cm \hss}
\ht0=0pt \dp0=0pt
\vbox to 0pt{\vskip-1in \box0 \vss}
% orignal \makeheadline follows
\vbox to 0pt{\vskip-22.5pt
\line{\vbox to 8.5pt{}\the\headline}\vss}\nointerlineskip}
Hello World!
\bye
But this throws the error:
! You can't use `\hrule' here except with leaders.
Can anybody explain what is wrong with the hrule?
Best Answer
The primitive
\hrule
is a vertical command; when TeX encounters it, it switches to vertical mode, emitting\par
if it is in (unrestricted) horizontal mode.Because of this, it cannot appear inside
\hbox
.To the contrary,
\vrule
is a horizontal command, so it triggers starting a paragraph if found in vertical mode.In your case
\vrule height 0.4pt width 15cm
will do.