Friends, I'm curious on how to do the following in LaTeX:

Dictionaries have two words on the top of each page, meaning the interval of words to be found on that specific page, e.g.,


In the figure, analyst refers to the lower bound (the first word), and ancillary refers to the upper bound (the last word) in this page.

I was wondering of how we could achieve something similar in LaTeX. Let's say we have the following document:


    \item[adequate] \lipsum[1]
    \item[adhere] \lipsum[2]
    \item[adherence] \lipsum[3]
    \item[adhesion] \lipsum[4]
    \item[adhesive] \lipsum[5]
    \item[adjacent] \lipsum[6]
    \item[adjective] \lipsum[1]
    \item[adjoin] \lipsum[2]
    \item[adjourn] \lipsum[3]
    \item[adjournment] \lipsum[4]
    \item[adjunt] \lipsum[5]
    \item[adjust] \lipsum[6]

My example

For this page, I expect to see both adequate and adhesive in the top of the page (first and last items on the page, respectively). The same rule applies to the rest of the pages. Update: I should've mentioned that I'm curious of an "automatic" way of choosing which words will be set in the page headers. =)

Any ideas?

  • 4
    Section 10 of the fancyhdr documentation shows how to do this.
    – Alan Munn
    Aug 19, 2011 at 19:07
  • 1
    @Alan: Interesting, thanks for mentioning. In fact, I was looking for something like an automatic procedure to look which words are the first and last in the current page and then set them in the header. fancyhdr solves the second part (how to put them in there), I wonder how could we solve the first one. =) Aug 19, 2011 at 19:16
  • 1
    It's all in there. See my posted answer.
    – Alan Munn
    Aug 19, 2011 at 21:19
  • @Alan: my bad, I probably misread the documentation. ;-) Aug 19, 2011 at 21:34

1 Answer 1


Here's a worked up example based on section 10 of the fancyhdr documentation:

% empty \sectionmark
% create a command to create marks and collapse them if they are identical
{\rightmark} % if equal
{\rightmark--\leftmark}} % if not equal 
% define a wrapper on the description environment to add the marks
% this part is quick and dirty; it would be better to define one's own
% environment to do this, but the basic idea is the same: you need
% to add the \markboth command to each dictionary entry
    \ditem[adequate] \lipsum[1]
    \ditem[adhere] \lipsum[2]
    \ditem[adherence] \lipsum[3]
    \ditem[adhesion] \lipsum[4]
    \ditem[adhesive] \lipsum[5]
    \ditem[adjacent] \lipsum[6]
    \ditem[adjective] \lipsum[1]
    \ditem[adjoin] \lipsum[2]
    \ditem[adjourn] \lipsum[3]
    \ditem[adjournment] \lipsum[4]
    \ditem[adjunt] \lipsum[5]
    \ditem[adjust] \lipsum[6]

output of code

  • Absolutely fantastic, Alan! Thanks a million! =) Aug 19, 2011 at 21:31

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .