In May 2012 user9588 answered:
\documentclass[12pt,a4paper]{article}
\def\rehbox{{\unskip\unpenalty\setbox0\lastbox\ifhbox0 \rehbox
\hbox{\unhbox0} \else \leavevmode \fi}}
\newcommand\printhyphens[1]{%
\setbox0\vbox{{%
\pretolerance-1\hsize=0pt\hfuzz=\maxdimen
\noindent\hspace*{0pt}#1\par\rehbox}\par}%
\unvbox 0
}
\begin{document}
\printhyphens{If you cannot reconsider this proposal, you are
incompatible, my dearest friend.}
\end{document}
Is it possible to construct a macro \printhyphs which does following:
\documentclass[12pt,a4paper]{article}
<hyphenfile = my-path/sillyhyphens.txt>
\begin{document}
\printhyphs{If you cannot}
\printhyphs{reconsider this proposal, you are}
\printhyphs{incompatible, my dearest friend.}
\end{document}
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.
\showhyphens{<text>}the hyphens are shown in the .log file and you can filter it. – egreg Jul 07 '13 at 16:05xltxtraredefines\showhyphensso that it works also with XeTeX. – egreg Jul 07 '13 at 21:29