3

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 1 '16 at 18:28
  • Something like this? – Alenanno Mar 1 '16 at 19:05
  • 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 1 '16 at 22:40
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

  • but it would look so much nicer down the centre:-) – David Carlisle Mar 1 '16 at 19:09
  • … With the usual caveat as to the use of \predisplaysize. For instance, if the document were being typeset with a non-zero \lastlinefit, we would get a bitter surprise. – GuM Mar 1 '16 at 21:29
  • @GustavoMezzetti Who's using \lastlinefit? ;-) – egreg Mar 1 '16 at 21:39
  • The same ones that might use, for example, \parfillskip = 0pt plus 1000pt ;-) – GuM Mar 1 '16 at 21:41
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}
  • I thought \centerline was a Plain macro that we weren't supposed to use in LaTeX. – musarithmia Mar 1 '16 at 19:26
  • And aren't you setting a bad example with `\\` in body text? – musarithmia Mar 1 '16 at 19:27
  • @AndrewCashner no of course my examples are never bad, ask egreg:-) – David Carlisle Mar 1 '16 at 19:48
  • @AndrewCashner \leaders\hbox to \hsize{\hss\vrule height 1pt \hss}\vfill} – David Carlisle Mar 1 '16 at 19:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.