4

As my nick suggests, I am just starting out with tex. Using plain tex, I am trying to create a document where certain paragraphs are separated by a centered horizontal line. I would like the separating line to be slighty larger than \hsize. I tried the following:

\parindent 0pt
\hsize 5in
{\hsize 6in \hrule}
\bigskip
x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x
%The "x x x ... x" above is the text of a dummy paragraph.
\bigskip
{\hsize 6in \hrule}
\vfill
\eject
\end

but it didn't work. The hrule width came out the same as the text width.

I would appreciate any advice as to how I can achieve the desired effect.

2
  • Welcome to TeX.SX! Usually, we don't put a greeting or a “thank you” in our posts. While this might seem strange at first, it is not a sign of lack of politeness, but rather part of our trying to keep everything very concise. Accepting and upvoting answers is the preferred way here to say “thank you” to users who helped you.
    – Seamus
    Mar 22, 2016 at 17:10
  • 2
    Are you looking for \hrule width6in?
    – Benjamin
    Mar 22, 2016 at 17:14

2 Answers 2

1

\hrule draws a rule as wide as the vertical box enclosing it; since we're in the main vertical list and there's a paragraph, the width is the same as the \hsize used for the paragraph, so 5 inches.

You perhaps want \hrule width 6in:

\input plipsum

\parindent 0pt
\hsize 5in

\hrule width 6in
\bigskip
\lipsum{1}
\bigskip
\hrule width 6in

\bye

enter image description here

If you want the rule to stick half an inch at the left, some more work is needed

\input plipsum

\parindent 0pt
\hsize 5in

\moveleft.5in\vbox{\hrule width 6in}
\nointerlineskip
\bigskip
\lipsum{1}
\bigskip
\nointerlineskip
\moveleft.5in\vbox{\hrule width 6in}

\bye

enter image description here

2
  • Yes, I want the hrule to extend beyond \hsize both left and right I haven't tried any of the solutions posted by others yet, but your second proposed solution works perfectly.
    – tex_novice
    Mar 22, 2016 at 17:49
  • @tex_novice I leave to you the necessary bits to avoid a page break between the rules and the text.
    – egreg
    Mar 22, 2016 at 17:51
3

You can use \hrulefill inside an \hbox of your desired width. Center this by putting it in \centerline.

I suggest adding some vertical space around the divider as well.

\def\divider{\par
  \vskip 1em
  \centerline{\hbox to 0.5\hsize{\hrulefill}}
  \vskip 1em
}

\beginsection Introduction

Dummy text.

\divider

\beginsection Conclusion

Dummy text.

\bye

enter image description here

2
  • After changing your 0.5 to 1.2, your solution also does the trick. Of the two solutions proposed so far, the output appears the same, Is there any advantage to one versus the other?
    – tex_novice
    Mar 22, 2016 at 18:11
  • This version is perhaps more "semantic" in spirit, since it allows you to define the width relatively instead of hard-coding the inches. Mar 22, 2016 at 19:23

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .