[texhax] Preserving dash when hyphenating compound words
Aleksandar Zec
zealeksanman at gmail.com
Fri Aug 27 21:41:03 CEST 2010
Hello Uwe,
Many thanks for the answer. (Sorry for the holiday delay in answering...)
2010/8/19 Uwe Lueck <uwe.lueck at web.de>:
[...]
> \hyp or that macro it calls according to the hyphenat documentation might be redefined (about as follows) or you use some \dhyp or so instead of \hyp with
>
> \newcommand{\dhyp}{\discretionary{-}{-}{-}}
>
> (not tested, sorry; if it works, why use hyphenat?) cf. TeXbook on \discretionary.
This \dhyp indeed produces intended additional dash, but it disables
hyphenation of compound words. I actually need
straw-chop-
per
straw-
-chopper
and hyphenat's \BreakableHyphen serves this purpose. So, some
experimenting shows that this code gives good results in all cases:
------------------------------------------------------
\documentclass{article}
\usepackage{hyphenat}
\newcommand{\dhyp}{\discretionary{-}{}{}%
\ifmmode-\else\BreakableHyphen\fi}
\begin{document}
\noindent\fbox{%
\begin{minipage}{2cm}%
and electroencephalography\\
straw\dhyp{}chopper\\
\hspace*{1.1cm}straw\dhyp{}chopper
\end{minipage}%
}
\end{document}
------------------------------------------------------
Not very elegant, though.
Thanks,
Alex
More information about the texhax
mailing list