Sign up ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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?

Bill Cheswick

For more information in iTeX, see My talk at TUG 2010 is at

share|improve this question
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 '12 at 23:17
May I enquire why would you need the position information of every word? – morbusg Nov 20 '14 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". – Bill Cheswick Jun 7 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
share|improve this answer
These look promising. I will chase them down and report. Thanks! – Bill Cheswick Feb 20 '12 at 14:19

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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