Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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.

share|improve this question
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
add comment

1 Answer

\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}
share|improve this answer
    
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 7:19
    
It should print the hyphen in the place of break of course! –  tohecz Feb 22 '13 at 7:35
    
that's what I meant, it actually prints the "| instead of the endash.. –  Paglia Orba Feb 22 '13 at 8:16
    
@PagliaOrba This complete example should help you I hope. –  tohecz Feb 22 '13 at 11:01
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.