[Tex/LaTex] \hrule with indents in Plain TeX

indentationplain-texrules

I am trying to learn the 'metal' of TeX after 20 years of using higher level packages, such as LaTeX.

In my test document I have an indented block representing simple recipes. I've created this with two macros, for the beginning and end of a recipe:

\def\beginrecipe{
  \par
  \begingroup
  \leftskip=\baselineskip
  \multiply\leftskip by 2
  \rightskip=\leftskip
  \parindent=-\baselineskip
  \parfillskip=0pt plus 1fil
  \reciperule
}
\def\endrecipe{
  \par
  \reciperule
  \endgroup
}

I want the recipe blocks to have horizontal rules at the top and bottom, so I've defined my \reciperule command to be:

\def\reciperule{
  \vskip0.5em\hrule\vskip0.5em
}

In the document this is used something like:

\beginrecipe
{\bf Blonde roux}

2 tbsp of butter.

2 tbsp of flour.

Melt the butter in a pan and add the flour.

Cook the flour without browning for 2 minutes, stirring with a whisk.
\endrecipe

This works well, but the \hrule is too wide. It spans the width of the text-block, I want it to just fill the width of the recipe. So it should start \baselineskip in from the left, and extend to \baselineskip from the right.

I've tried to do this with \hskip\baselineskip and using \hrulefill to fill the available space. The problem is \hskip reserves a line worth of height, which is far too much, I want the rule to be thin.

Can I either indent an \hrule (I know I can set its width, so this would work), or can I get \hskip, \hrulefill, etc, to have a specified height?

Or is there an easier way to do the whole thing (that doesn't use a package beyond Plain TeX)?

Best Answer

You have to \moveright a box with a rule in it, but also to watch out against page breaks before the rule

\def\beginrecipe{
  \par
  \begingroup
  \leftskip=\baselineskip
  \multiply\leftskip by 2
  \rightskip=\leftskip
  \parindent=-\baselineskip
  \parfillskip=0pt plus 1fil
  \nobreak
  \reciperule
}
\def\endrecipe{
  \par\nobreak
  \reciperule
  \endgroup
}
\def\reciperule{
  \nointerlineskip
  \vskip0.5em
  \moveright\baselineskip\vbox{
    \advance\hsize-3\baselineskip
    \hrule width \hsize
  }
  \nointerlineskip
  \nobreak
  \vskip0.5em
}

\beginrecipe
{\bf Blonde roux}

2 tbsp of butter.

2 tbsp of flour.

Melt the butter in a pan and add the flour.

Cook the flour without browning for 2 minutes, stirring with a whisk.
Cook the flour without browning for 2 minutes, stirring with a whisk.
\endrecipe

\bye

enter image description here