When reading a LaTeX document on an iPad with iTeX, I need to know the position of every word on the page. (I also need to know the positions of images, URLs, footnotes, etc., but they are all manageable by adding \special- s to the appropriate macros.) This could be used for searching, dictionary lookups, etc.

What I would love to do is insert a \special with some attribute before each word. This would need some automatic per-word processing, because I want it for the whole document, and damn the expense! A new program, dvigrid, would emit lines needed containing the word's rectangle and other, specifiable information.

It needs to be a general solution, something that can live with the popular document classes.

A related need is the word ordinal in the output. This would be a new answer to the old word-count question (which use external programs), except here TeX could count the words.

There are examples of commands that do this for every word in a parameter, like putting the words in a box. But none seem appropriate for doing an entire document this way. I can't find an appropriate hook or hack, even deep inside the double danger parts of TeX.

Does anyone have a suggestion? Can this even be done without modifying TeX?

For more information in iTeX, see http://itex.cheswick.com

My talk at TUG 2010 is at http://river-valley.zeeba.tv/tex-and-the-ipad/

  • 1
    I don't think there's a reliable way to do this in general on the "macro side". Maybe some processing with LuaTeX could do it.
    – egreg
    Feb 19, 2012 at 23:17
  • May I enquire why would you need the position information of every word?
    – morbusg
    Nov 20, 2014 at 9:10
  • Sure. For one thing, I need it to show string matches for searches. I also want to be able to tap on a word, and do such operations as "define". Jun 7, 2015 at 13:34

1 Answer 1



  1. Use LuaTeX to intercept the paragraph breaker to emit whatsit nodes at every word boundary
  2. Study synctex - it may give you what you want (positions of every word etc.)
  3. Check out the creation of tagged PDF by ConTeXt or the patched pdfTeX
  • These look promising. I will chase them down and report. Thanks! Feb 20, 2012 at 14:19

You must log in to answer this question.

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