A comprehensive solution (based on this answer) is to define new column types (say, L, C, and R) that take their width as argument and do the following:
-
Issue
\raggedright
,\centering
, or\raggedleft
to achieve the desired horizontal alignment, -
Declare
\let\newline\\
to allow to use\newline
for manual line breaks within a cell (note that\centering
& friends change the meaning of\\
-- this is the problem with Jake's solution), -
Issue
\arraybackslash
(i.e.,\let\\\tabularnewline
) to allow (again) to use\\
for ending rows, -
Issue
\hspace{0pt}
to allow the first word in a cell to be hyphenated.
In the example below, the new column types are based on (vertically centered) m-columns, but one may use (top- or bottom-aligned) p- or b-columns as well.
\documentclass{article}
\usepackage{array}
\newcolumntype{L}[1]{>{\raggedright\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
\newcolumntype{C}[1]{>{\centering\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
\newcolumntype{R}[1]{>{\raggedleft\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
\begin{document}
\begin{tabular}{| c | L{3cm} | C{3cm} | R{3cm} |}
foo &
A cell with text that wraps around, is raggedright and allows \newline
manual line breaks &
A cell with text that wraps around, is centered and allows \newline
manual line breaks &
A cell with text that wraps around, is raggedleft and allows \newline
manual line breaks \\
\end{tabular}
\end{document}