4

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.

  • 1
    Along the left margin? The right margin? From the end-point of the paragraph? – Werner Mar 01 '16 at 18:28
  • It could be remarked that pdfTeX does have primitives (\pdfsavepos/\pdflastxpos/pdflastypos) that record, at \shipout-time, where a given point is eventually placed on the page (or rendering canvas), and allow you to subsequently retrieve the saved position so that it can, e.g., be saved into an auxiliary file and used in the next run. – GuM Mar 01 '16 at 22:40

2 Answers2

5

For a line down the centre you can use

\documentclass{article}

\begin{document}

aaa aaa\\bb bbbb

\leaders\centerline{\vrule height1pt}\vfill

\end{document}
David Carlisle
  • 757,742
4

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

egreg
  • 1,121,712