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 have a table (tabular) with some fixed width columns, and I'd like to prevent a hyphen being inserted (preferring a line break to be inserted prematurely).

The sample table's content is below.

\begin{tabular}{p{4cm}p{4cm}}
Want to avoid hyphenation & also want to avoid hyphenation here \\
\end{tabular}

How can I do this? I'd also like to tell latex not to allow each column to exceed its specified width (so I don't want a solution that means assigning hyphenation the same badness rating as an overfull hbox).

share|improve this question
    
Setting \hyphenpenalty10000 causes the hyphenation to go away for me and I get no overfull hboxes. –  TH. Sep 8 '10 at 10:48

1 Answer 1

up vote 10 down vote accepted

Setting the text ragged right will do this for you. Something like

\usepackage{array}
...
\begin{tabular}{>{\raggedright}p{4cm}>{\raggedright\arraybackslash}p{4cm}}
Want to avoid hyphenation & also want to avoid hyphenation here \\
\end{tabular}
share|improve this answer
1  
Better use \RaggedRight from ragged2e, no? –  Konrad Rudolph Sep 8 '10 at 11:37
2  
The point was to not have hyphenation. \RaggedRight's whole purpose is to allow hyphenation. –  TH. Sep 8 '10 at 14:08
    
Thanks for this. Unfortunately this now means that I can't use the booktabs package with \midrule and \bottomrule (in both cases I get a misplace \noalign error). –  bryn Sep 9 '10 at 5:38
2  
Oh, that just means I was lazy with my example. Should be fixed now. –  Will Robertson Sep 9 '10 at 6:51
1  
Thanks -- I have no idea what \arraybackslash is for but that fixes the problem. –  bryn Sep 9 '10 at 8:20

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.