4

I can't hyphenate the words

Cam•bri•an--Or•do•vi•cian

because they are connected with an endash. The same probably happens when using the emdash.

I tried this

 \defineshorthand{"=}{\penalty1000-\hskip0pt}
 \hyphenation{Cambrian"="=Ordovician}

But I obviously don't understand this shorthand thingy.

lockstep
  • 250,273
  • 3
    the 0pt skip makes a space so Tex sees this as two words and hyphenates each separately, you can't put the compound in \hyphenation or define rules for the compound that differ from the two separate words – David Carlisle Feb 21 '13 at 21:54

1 Answers1

4

\defineshorthand{"|}{\penalty1000--\hskip0pt} would work in Cambrian"|Ordovician, but as David says, not in \hyphenation; you have to use the shorthand every time you typeset such a word.

As well, you might actually want to say the following, depending on the typographical traditions of your language:

\defineshorthand{"|}{\penalty1000\discretionary{--}{}{--}\penalty10000\hskip0pt}

The command \discretionary takes 3 arguments and it typesets #3 if no linebreak occurs at that place, and it typesets #1<end-of-line>#2 if linebreak occurs at that place.

Complete example showing the different break variants:

enter image description here

\documentclass{article}

\pagestyle{empty}

\usepackage[ngerman,english]{babel}
\useshorthands{"}
\addto\extrasenglish{\languageshorthands{ngerman}}
\defineshorthand{"|}{\penalty1000\discretionary{--}{}{--}\penalty10000\hskip0pt}

\begin{document}

\begin{tabular}{p{4cm}p{3.5cm}p{3cm}}
Hellohello Cambrian"|Ordovician World text text text text text text text
&
Hellohello Cambrian"|Ordovician World text text text text text text text
&
Hellohello Cambrian"|Ordovician World text text text text text text text
\end{tabular}

\end{document}
yo'
  • 51,322
  • thank you. I tried that, and it does hyphenate the word, but also it prints the shorthand: Cambrian”|Or- dovician I'm using LuaLaTeX and the fontspec and xunicode packages. – Paglia Orba Feb 22 '13 at 07:19
  • It should print the hyphen in the place of break of course! – yo' Feb 22 '13 at 07:35
  • that's what I meant, it actually prints the "| instead of the endash.. – Paglia Orba Feb 22 '13 at 08:16
  • @PagliaOrba This complete example should help you I hope. – yo' Feb 22 '13 at 11:01
  • In the babel package for Cyrillic there is a similar command "= for hyphenation which does not work for other language. If you write multi-language documents, it might be more convenient to use "= instead of "| So Cambrian"=Ordovician looks visually better than Cambrian"|Ordovician – Sergiy Maksymenko Nov 19 '22 at 09:59