3

I commonly run into issues with controlling the exact amount of space between two environments.

Recently, for example, I was trying to understand how to insert a horizontal rule between two boxes without adding extraneous space. The following example does what I want:

\documentclass{article}
\parindent=0pt
\begin{document}
BEFORE 1\\BEFORE 2
\hrule
AFTER 1\\AFTER 2
\end{document}

enter image description here

I wanted to replicate this with \hrulefill instead, to customize the width of the rule and add additional elements on the rule's line, but this does not work (the \offinterlineskip setting applies to too much):

\documentclass{article}
\parindent=0pt
\begin{document}
\offinterlineskip
BEFORE 1\\BEFORE 2\par
\hrulefill\par
AFTER 1\\AFTER 2\par
\end{document}

enter image description here

On the other hand, the following works, without having to change \parskip, \lineskip, or any other parameter:

\documentclass{article}
\parindent=0pt
\begin{document}
BEFORE 1\\BEFORE 2\hrule height 0pt
\hrulefill\hrule height 0pt
AFTER 1\\AFTER 2
\end{document}

enter image description here

What role does \hrule height 0pt play here, exactly? How does it compare to \par, and what would be the equivalent sequence of commands using \par to generate the example below? (In other words, how would one emulate \hrule using \hrulefill and \par?)

Clément
  • 4,004
  • I have seen https://tex.stackexchange.com/questions/454389/hrulefill-vertical-spacing , but the answer to this question just suggest adding add-hoc negative vertical spaces around the \hrulefill, and I'd like to understand there's anything wrong with the (seemingly) more robust \hrule height=0pt – Clément Aug 04 '21 at 06:18
  • 1
    Normally TeX tries to put baselines \baselineskip apart, but if the calculated \vskip is less than \lineskiplimit it uses \lineskip instead. \hrule ignores all that. – John Kormylo Aug 04 '21 at 15:40

0 Answers0