In May 2012 user9588 answered:

\def\rehbox{{\unskip\unpenalty\setbox0\lastbox\ifhbox0 \rehbox
    \hbox{\unhbox0} \else \leavevmode \fi}}
  \unvbox 0

\printhyphens{If you cannot reconsider this proposal, you are
  incompatible, my dearest friend.}

Is it possible to construct a macro \printhyphs which does following:


<hyphenfile = my-path/sillyhyphens.txt>

\printhyphs{If you cannot}
\printhyphs{reconsider this proposal, you are}
\printhyphs{incompatible, my dearest friend.}

Running (pdf|xe)latex will create a file: my-path/sillyhyphens.txt, containing:

If you can- not
re- con- sid- er this pro- pos- al, you are
in- com- pat- i- ble, my dear- est friend.

Whether or not the -signs are followed by a space is irrelevant.

  • I don't think this is possible; hyphenation happens at a very late stage of processing, when TeX is preparing boxes for typesetting. If you use \showhyphens{<text>} the hyphens are shown in the .log file and you can filter it. – egreg Jul 7 '13 at 16:05
  • I need this for the syllables in a (large) text and I use showhyphens at the moment. But it does not work (properly) with xelatex and filtering them is problematic. When they can appear in the .log file, so why not in another? – Jack Jul 7 '13 at 16:18
  • @Jack The package xltxtra redefines \showhyphens so that it works also with XeTeX. – egreg Jul 7 '13 at 21:29
  • @egreg Yes, I know. But one has to feed the words separated by commas rather than spaces and, worse: the hypenated words do not appear together on one line but as separate (hyphenated) words, spread all over the .log file. This makes processing a bit cumbersome. – Jack Jul 7 '13 at 22:18
  • @Jack We don't add "Solved" to the title; rather, if an answer is helpful and solves (totally or mostly) the problem, the better way is to accept it, by clicking the check mark near the start of the answer's text. – egreg Jul 8 '13 at 23:17

A solution based on package soul. \printhyphs is implemented as soul driver that collects the syllables and hyphenation points in macro \printhyphs@line, which written into the output file at the end of \printhyphs in \SOUL@postamble:



    \g@addto@macro\printhyphs@line{ }%
    \g@addto@macro\printhyphs@line{- }%

\printhyphs{If you cannot}%
\printhyphs{reconsider this proposal, you are}%
\printhyphs{incompatible, my dearest friend.}%

File sillyhyphens.txt is written with the following lines:

If you can- not
re- con- sider this pro- posal, you are
in- com- pat- i- ble, my dear- est friend.
  • Heiko, this is terrific and what I hoped for. Is the "y- ou" the only anomaly? Do you have a sugestion on how to get rid of the "y- ou" other than with sed or awk? – Jack Jul 7 '13 at 22:23
  • @Jack: Answer fixed and the settings for \lefthyphenmin and \righthyphenmin removed. – Heiko Oberdiek Jul 7 '13 at 22:35
  • I just found out that I had to fiddle a bit with \lefthyphenmin and \righthyphenmin. Thanks again! – Jack Jul 7 '13 at 22:49
  • @Jack: Just remove them, then the values of the current language are used. They were a left over from the example driver in the documentation of soul. – Heiko Oberdiek Jul 7 '13 at 22:50

from time to time, a "hyphenation exception log" (update) is published in tugboat. the most recent was in vol.33, no.1. the full list, in the form of a tugboat article file, tb0hyf.tex, is posted to ctan along with its .pdf output as part of the hyphenex package.

a "showhyphens" routine is used to produce this list; the code is in the article .tex file, and should be able to be adapted to the purpose you have in mind.

  • Thanks Barbara, for you confirmation that it IS possible. The point is that I tried to adapt the \printhyphens in my org post, but my knowledge of TeX is far to limited. I could not even understand all the error messages that were thrown on my screen. I'll go after Heiko's hint. – Jack Jul 7 '13 at 22:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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