[Tex/LaTex] Automatic hyphenation of compound words

babelhyphenationshorthands

When I was learning to drive a typewriter (shortly after the death of my pet sabre-tooth), I picked up the habit of using a double hyphen when splitting compound words, thus:

The system has a high-
-performance component

I've read babel: Adding ngerman' s language shorthands to english as the main document language, and Stefan's answer to What's the benefit of loading babel when writing in English?, and thought this would do the trick:

\documentclass[draft]{article}
\usepackage[ngerman,british]{babel}
\useshorthands{"}
\addto\extrasbritish{\languageshorthands{ngerman}}
\selectlanguage{british}
\begin{document}
\noindent
Normal hyphenation, to illustrate:\\ 
\begin{minipage}{80pt}
Lala High"=performance.
\end{minipage}
\\[2pc]
\begin{minipage}{80pt}
Lalala lalala High"=performance.
\end{minipage}
\\[2pc]
My best guess:\\
\begin{minipage}{80pt}
Lala High"="~performance.
\end{minipage}
\\[2pc]
\begin{minipage}{80pt}
Lalala lalala High"="~performance.
\end{minipage}
\end{document}

It looks like the sequence "="~ is close to what I want, but it suppresses hyphenation of the parts.

I've now spent about two hours trying all kinds of combinations, but as I don't really understand what I'm doing, I thought it better to ask, here, someone who actually knows.

I could, of course, use the \discretionary command, but I'd prefer it to be automatic.

BTW, typographical criticism is welcome (such as "don't do that!"),
but I'd still like to know, even if just out of curiosity.

Best Answer

\useshorthands{"}
\makeatletter
\declare@shorthand{ngerman}{";}{\discretionary{-}{-}{-}\bbl@allowhyphens}
\makeatother
\addto\extrasbritish{\languageshorthands{ngerman}}

Now "; (choose another shorthand, if you prefer) will do what you're looking for:

\begin{minipage}{80pt}
Lalala lalala High";performance.
\end{minipage}

will typeset as

Lalala lalala High-
-performance.

but

\begin{minipage}{80pt}
Lala High";performance.
\end{minipage}

will typeset as

Lala High-per-
formance.

Don't do it. :)