4

The column type \newcolumntype{L}[1]{>{\RaggedRight\arraybackslash}p{#1}} proposed here does not hyphenate long words that don't have a hyphen, but instead lets them protrude beyond the column.

Isn't \RaggedRight designed specifically to facilitate hyphenation?

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{tabularx}

\usepackage{ragged2e}

\newcolumntype{L}[1]{>{\RaggedRight\arraybackslash}p{#1}}

\begin{document}

raggedright:

\begin{tabularx}{40pt}{|>{\raggedright\let\newline\\\arraybackslash\hspace{0pt}}p{40pt}|}
Synthetically do 
\end{tabularx}

\bigskip

raggedright with finalhyphendemerits=0:

\begin{tabularx}{40pt}{|>{\raggedright\let\newline\\\arraybackslash\hspace{0pt}}p{40pt}|}
\finalhyphendemerits=0
Synthetically do 
\end{tabularx}

\bigskip

RaggedRight:

\begin{tabular}{|L{40pt}|}
Synthetically do 
\end{tabular}

\end{document}
root
  • 418

1 Answers1

5

\RaggedRight actually makes hyphenation more likely with respect to the standard \raggedright, but less likely than in the standard justified paragraphs.

Normally when justifying paragraphs, tex only has a small amount of flexibility in inter-word spacing, so often needs to hyphenate to achieve the target line width.

With \raggedright infinitely stretchable glue is added to the right of each line, so TeX never needs to hyphenate unless the word is longer than the line width, as it always has available white space.

\RaggedRight allows a small finite amount of stretchability at the end of each line, so this will be taken in preference to hyphenation, but if avoiding hyphenation would leave a line too short then (unlike \raggedright) the line will be hyphenated so that the white space at the end of the line is within the specified range.


TeX does not hyphenate the first word of a paragraph, so you need to insert \hspace{0pt} but you have not done this in the RaggedRight case.

enter image description here

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{tabularx}

\usepackage{ragged2e}

\newcolumntype{L}[1]{>{\RaggedRight\arraybackslash}p{#1}}

\begin{document}


RaggedRight:

\begin{tabular}{|L{40pt}|}
Synthetically do 
\end{tabular}



\begin{tabular}{|L{40pt}|}
\hspace*{0pt}Synthetically do 
\end{tabular}

\end{document}
David Carlisle
  • 757,742