[Tex/LaTex] \hrulefill, just vertically

fillrules

The command \hrulefill fills the rest of the line with a rule. Now, I would like to create a vertical line to the bottom of the page, starting from the last paragraph on that page. Is this possible?

I need the line on the left side, but I am also interested to understand how this can be achieved conceptually, as (to my knowledge) there is no way to know where you are at a certain moment during rendering.

Best Answer

The command \hrulefill doesn't know where it is issued from; it just fills the remaining space on the line in a similar way to what \hfill does (actually it is the same way).

For \vrulefill it's quite similar:

\documentclass{article}
\usepackage{lipsum}

\newcommand{\vrulefill}{\leaders\vrule\vfill}

\begin{document}

\lipsum[1]
\vrulefill

\clearpage % <-- not necessary if it's the last page

\end{document}

enter image description here

You can make the rule start from where the last paragraph ends by finishing the paragraph with \parvrulefill as in these examples:

\documentclass{article}
\usepackage{lipsum}

\newcommand{\vrulefill}{\leaders\vrule\vfill}

\makeatletter
\newcommand{\parvrulefill}{%
  {\abovedisplayskip=\z@\belowdisplayskip=\z@
   \abovedisplayshortskip=\z@\belowdisplayshortskip=\z@
   $$\xdef\vrule@shift{\the\predisplaysize}$$}%
   \par
   \kern-\baselineskip
  \leaders\hbox to\dimexpr\vrule@shift-2em{\hfill\vrule height1pt}\vfill
  \clearpage
}
\makeatother

\begin{document}

\lipsum*[1]\parvrulefill

\lipsum*[2]\parvrulefill

\end{document}

enter image description here

Related Question