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 try to make XeLaTeX hyphenate the German word "Sicherheitsbeauftragter". I tried several values for x in \tolerance=x and instances of \hyphenation{Si-cher-heits-be-auf-trag-ter}. Nothing worked. MWE:

\documentclass{article}
\usepackage{polyglossia}
\setmainlanguage{german}
\usepackage{array}
\usepackage{ragged2e}
\hyphenation{Si-cher-heits-be-auf-trag-ter} 
\begin{document}
\begin{tabular}{>{\RaggedRight}p{7.7em}@{|}}
Sicherheitsbeauftragter\\
Technischer Leiter
\end{tabular}
\end{document}

Screenshot of hyphenation not working

I also tried babel instead of polyglossia and pdfLaTeX instead of XeLaTeX but except for how the "|" looks, there is no difference.

share|improve this question
add comment

2 Answers

up vote 11 down vote accepted

\hspace{0pt} right before Sicherheitsbeauftragter allows TeX to break the word, because TeX does not hyphenate the first word in a paragraph. (AFAIK this had made the implementation easier and in English with the many short words, it wasn't much of a problem.)

Since the \hspace inserts a break point at this place, this can be avoided by \nobreak in horizontal mode:

\leavevmode\nobreak\hspace{0pt}Sicherheitsbeauftragter

Or the star form of \hspace can be used:

\hspace*{0pt}Sicherheitsbeauftragter

This can be automated (see Herbert's comment) in the column description:

\begin{tabular}{>{\RaggedRight\hspace*{0pt}}p{7.7em}@{|}}
share|improve this answer
    
Also \selectlanguage{german} should be issued before \hyphenation or, maybe preferably, the command should be between \begin{otherlanguage*} and \end{otherlanguage*}. –  egreg Apr 13 '13 at 18:05
    
@egreg The OP has used \setmainlanguage{german} (package polyglossia). –  Heiko Oberdiek Apr 13 '13 at 18:08
    
or use \begin{tabular}{>{\RaggedRight\hspace{0pt}}p{7.7em}@{|}} –  Herbert Apr 13 '13 at 18:08
    
@HeikoOberdiek Try adding \showthe\language just before \hyphenation, you'll get 0. –  egreg Apr 13 '13 at 18:22
    
@egreg It's 30 for me after \begin{document}. \hyphenation is no longer necessary, the hyphenation with the ngerman patterns (loadhyph-de-1996 or dehyphn-x-2012-05-30) is correct. –  Heiko Oberdiek Apr 13 '13 at 18:30
show 1 more comment

You can also suggest places for hyphenation using \-. The following works for me.

\documentclass{article}
\usepackage{polyglossia}
\setmainlanguage{german}
\usepackage{array}
\usepackage{ragged2e}
\begin{document}
\begin{tabular}{>{\RaggedRight}p{7.7em}@{|}}
Sicherheits\-be\-auf\-tragter\\
Technischer Leiter
\end{tabular}
\end{document}
share|improve this answer
    
The problem here is, that the word is read from a source file, in which "\-" shouldn't occur (aka readable to non-texies). –  Toscho Apr 15 '13 at 11:56
    
Ah, then in that case Heiko's answer is a much more suitable solution. –  erik Apr 16 '13 at 2:42
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.