# Table with text wrapping?

Row 1 has one line and centered for each cell.

Row 2. Column 1 has two (2) lines. each line centered.
Row 2. Column 2 has one line. centered horizontal and vertical.
Row 2. Column 3 has text wrapping.justified.

Row 3 and 4 repeat Row 1.

• Welcome to TeX.sx! Although your question has an answer, please add a minimal working example (MWE) that illustrates your problem, or what you have that you want to fix. This is a good idea for virtually all questions here. There is also no need to put a thanks in your question. Thanks is best expressed with upvotes, and it is the style here not to put it into the question. – qubyte May 2 '12 at 11:20
• In addition to Harish Kumar's excellent answer, there are several other good answers to an old question over in StackOverflow: How to wrap text in LaTeX tables? – Mars Aug 28 '13 at 22:09
• @Mars the package tabularx described in your link is by far the most neat solution. – deps_stats Nov 4 '18 at 0:47

\documentclass{article}
\usepackage{array}
\newcolumntype{L}{>{\centering\arraybackslash}m{3cm}}

\begin{document}

\begin{table}
\begin{tabular}{|L|c|L|}\hline
one & two & three \\\hline
This is two line thing and centered & only one line&  \multicolumn{1}{m{3cm}|}{This is justified and may go to second line as well, neatly}\\\hline
one & two & three \\\hline
one & two & three \\\hline
\end{tabular}
\end{table}
\end{document}


Thanks for your answer, it inspired me to make some custom column-types, and I'd love to share them.

\documentclass[a4paper,13pt]{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{center}
\begin{tabular}{ | C{0.45\textwidth} | C{0.45\textwidth} | }
\hline
Correct (from the reader) & Experimental (HyperChem) \\ \hline
\end{tabular}
\begin{tabular}{ | L{0.45\textwidth} | m{0.45\textwidth} | }
\includegraphics[width=0.45\textwidth]{as1correlationcorrect} & \includegraphics[width=0.45\textwidth]{as1correlationbondorderbonddissociationenergyexperiment} \\ \\

\textbf{Figure 3: }Correlation between bond-order and Dissociation Energy, with the literature-experiment values for D$$_0$$. & \textbf{Figure 4: }Correlation between bond-order and Dissociation Energy, with the computer-experiment values for D$$_0$$.

\\ \hline
\end{tabular}
\end{center}
\end{document}


Without calling \newcolumntype, there is a built in command that we could use, which is >{\centering\arraybackslash}m{length}, where the variable "length" specifies the width that the text spans

\begin{table}[H]
\centering
\begin{tabular}{>{\centering\arraybackslash}m{3.7cm}|>{\centering\arraybackslash}m{3.7cm}|>{\centering\arraybackslash}m{3.7cm}}
\hline
Only one line here. & Same for column two. & Same for column three. \\
\hline
We have two lines here, each line centered. & This cell will have three lines and each line centered as well. & Here is a justified cell, please check this out! \\
\hline
This cell has one line. & So does this one. & And this one, too! \\
\hline
\end{tabular}
\end{table}


And the output looks like

The text is centered both horizontally and vertically in each cell. If you prefer to have the text aligned to top vertically, use >{\centering\arraybackslash}p{3.7cm} instead.