I'd like to use TeX to hyphenate paragraphs of text--and only to hyphenate. My goal is to show hyphenated text on a webpage, with ­ entities where a possible word break could happen.

So I'd like to get contents of an hbox of a paragraph after hyphenation in some machine-parseable format.

I could firstly put my paragraph into a box register, e.g. with \setbox42=\hbox{Hyphenate me please}, then I force the hyphenation algorithm to do its job (how?), then I show the contents of page with \showlists.

I have read the TeXbook, but I don't know how to force hyphenation to happen.

Any ideas?

  • I guess LuaTeX might be helpful here.
    – Caramdir
    Mar 18, 2011 at 21:19
  • 1
    Have you seen hyphenator.js? It uses the same patterns as TeX to hyphenate. Mar 19, 2011 at 5:08

2 Answers 2


The command

\showhyphens{Hyphenate me please}

will produce

Underfull \hbox (badness 10000) in paragraph at lines 20--20
[] \OT1/cmr/m/n/10 Hy-phen-ate me please

in the .log file.

  • This one will show normal hyphens and discretionary ones in the same way, so that I won't be able to distinguish between them. Still, it might be good enough. Thanks!
    – liori
    Mar 18, 2011 at 21:10
  • 3
    not so fast -- if a word contains a discretionary hyphen (equivalent to ­), all other possible hyphenation points are ignored by tex. so you don't get both shown the same way with \showhyphens. maybe someone working with german conventions has come up with an alternate method in an extended tex, but not with the original tex program. Mar 18, 2011 at 22:43

I had the exact same idea once and started writing it up into a package to output html and PDF from the same input file... But I ran out of time to finish it. In fact, I'm not even sure what state it was in when I left it; the code is here: https://github.com/wspr/miter

In short, the idea is to use the soul package to determine where the hyphenation points are. This uses a similar idea to \showhyphens but is rather more flexible.

Let me know if you manage to get anything working from all this; I'd be interested to see the results.

You must log in to answer this question.

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