49

I would like to typeset catchwords. That is, I would like to put a “preview” of the next page’s first word at the bottom of every page.

An example taken from the Wikipedia page linked above:
catchword

The next page begins with the word (actually word fragment in this particular case) “dos”, and so that word is typeset flush right just below the text-block.

(How) can this be done with TeX?

Erasm
  • 491
  • try with "\looseness=-1" after the last word ? – madit Oct 03 '12 at 18:26
  • 6
    Are you asking about http://en.wikipedia.org/wiki/Catchword? “A catchword is a word placed at the foot of a handwritten or printed page that … anticipates the first word of the following page.” – J. C. Salomon Oct 03 '12 at 18:43
  • @J.C.Salomon Yes, exactly! – Erasm Oct 03 '12 at 18:46
  • A possible answer may be, how to add once (!) \enlargethispage{\baselineskip} automagically, if one word (not a whole line full of text) is otherwise printed on the next page. – Keks Dose Oct 03 '12 at 18:47
  • 1
    @Erasm I don't think this is possible in (La)TeX, but maybe some LuaTeX trickery can help. – egreg Oct 03 '12 at 19:28
  • 4
    This is surely possible in LuaTeX: use the post_linebreak_filter to analyze the paragraphs and then atbegshi to find the last line on the page and add the information you've got from step one. Easy ;-)) – topskip Oct 03 '12 at 19:45
  • @egreg surely you mean in an automated sense. I think that adding a different word to the footer of every page would be relatively easy once the list of words is known. Getting the list of words could be done by looking at the pdf. – StrongBad Oct 03 '12 at 20:23
  • @egreg Donald Arseneau made it possible in LaTeX ;-) (see my answer). – Gonzalo Medina Oct 04 '12 at 00:58

1 Answers1

49

You can use the fwlw ("First Word, Last Word") package; a little example using a footer defined with the fancyhdr package:

\documentclass{article}
\usepackage[latin]{babel}
\usepackage[a6paper,footskip=0pt]{geometry}
\usepackage{fwlw}
\usepackage{fancyhdr}
\usepackage[veryoldstyle]{kpfonts}
\usepackage{lipsum}
\fancyhf{}
\fancyfoot[R]{\usebox\NextWordBox}
\renewcommand\headrulewidth{0pt}
\pagestyle{fancy}

\begin{document}

\lipsum[4-60]

\end{document}

An image of the first four pages:

enter image description here

The package gives access to the first word on the current page (\FirstWordBox), the first word on the next page (\NextWordBox), and the last word on the current page (\LastWordBox).

The package also offers a predefined page style NextWordFoot to read ahead to the first word on the next page:

\documentclass{article}
\usepackage[latin]{babel}
\usepackage[a6paper,footskip=0pt]{geometry}
\usepackage{fwlw}
\usepackage[veryoldstyle]{kpfonts}
\usepackage{lipsum}

\pagestyle{NextWordFoot}

\begin{document}

\lipsum[4-60]

\end{document}

enter image description here

doncherry
  • 54,637
Gonzalo Medina
  • 505,128
  • 8
    Who could imagine there's a package for this? :) – henrique Oct 04 '12 at 01:25
  • Is there another way of doing it without wasting the footer? – NVaughan Oct 04 '12 at 01:49
  • 5
    @NVaughan sure; in many ways. You can use, for example, the background package: `\documentclass{article} \usepackage[latin]{babel} \usepackage[a6paper,footskip=0pt]{geometry} \usepackage{fwlw} \usepackage{fancyhdr} \usepackage[veryoldstyle]{kpfonts} \usepackage{lipsum} \usepackage[bottom]{background}

    \backgroundsetup{ scale=1, color=black, opacity=1, vshift=64pt, contents={\makebox[\textwidth][r]{\usebox\NextWordBox}}, }

    \begin{document}

    \lipsum[4-60]

    \end{document}`

    – Gonzalo Medina Oct 04 '12 at 02:02
  • @GonzaloMedina, cheers! – NVaughan Oct 04 '12 at 02:10
  • 2
    @GonzaloMedina Great find! – egreg Oct 04 '12 at 06:29
  • This is great! – raphink Oct 11 '12 at 09:11
  • Excellent answer! Note that often times it would be the first syllable, not the whole first word. But that'd require a bit more work that I'm not entirely sure babel's hyphenation would handle correctly (since a one letter syllable often can't be left alone), and frankly, only a purist would notice :) – user0721090601 Oct 28 '16 at 01:05
  • I did search for this exact question but somehow in the search results this question did not appear, that didn't certainly feel right, I mean certainly people must have thought about this. But perhaps my keywords were. So I went about composing my own question with examples. But as I composed my question, creating examples (manually with marginnote package, and I preview the question. This one appears in the box of related questions! Just makes me like LaTeX even more. – Damitr Apr 07 '20 at 14:51