Let's say we want to typeset long two-language compounds. We prefer to break such words right after the first-language word is over and before the second-language words starts; if the results get ugly (say, overfull boxes), we wish to allow for breaking also within the single-language parts.
Consider, e.g., Pipes-and-Filters-Architektur, Map/Reduce-Konzept, Assume/Guarantee-Spezifikation, and Quicksortprinzip — all of the kind English+German.
Here are our attempts so far:
\documentclass{article}
\usepackage[USenglish,ngerman]{babel}
\babelprovide[hyphenrules=ngerman-x-latest]{ngerman}%%% according to the documentation of dehyph-exptl.
%\showoutput
\begin{document}
\showhyphens{
\foreignlanguage{USenglish}{Pipes\penalty10000-\penalty2\hskip0pt and\penalty10000-\penalty2\hskip0pt Filters}\penalty10000-\penalty1\hskip0pt Architektur % Pipes-and-Filters-Architektur
\foreignlanguage{USenglish}{Map\penalty10000/\penalty2\hskip0pt Reduce}\penalty10000-\penalty1\hskip0pt Konzept % Map/Reduce-Konzept
\foreignlanguage{USenglish}{Assume\penalty10000/\penalty2\hskip0pt Guarantee}\penalty10000-\penalty1\hskip0pt Spezifikation % Assume/Guarantee-Spezifikation
\foreignlanguage{USenglish}{Quicksort}"-prinzip % Quicksortprinzip
}
\end{document}
Would this rock? We get the output (hyphens with
\showhyphens
and penalties with\showoutput
) which seems right, but I am still not sure.The above typesetting seems quite cumbersome; is there an easier way to reach the same goal? Is
\penalty10000
really necessary between a word and a slash or a dash?How to say in
\foreignlanguage{USenglish}{Quicksort}"-prinzip
that we prefer breaking between the English part and the German part rather than breaking inside any of the two parts?
Map/Reduce-Konzept
andAssume/Guarantee-Spezifikation
asMap\slash Reduce-Konzept
andAssume\slash Guarantee-Spezifikation
, respectively. By using the macro\slash
rather than by hard-coding the/
symbol, you're indicating to TeX that it's ok to insert a line break after the/
symbol (without inserting a hyphen symbol, of course).\slash
simply/\penalty\exhyphenpenalty
(line 597 of latex.ltx)? If we wish to tweak penalties, we should probably say/\penalty something_else
anyway (as/\penalty2
in my example), don't we?