# How to break line in a long column in tabular

I am trying to write a table that has 4 columns. However the 4th column is too large and i am writting texts inside this column and then the table goes outside the page. I would like to break a line using tabular everytime the text gets too large. This is an example:

\begin{table}
\begin{tabular}{llll}
\hline\noalign{\smallskip}
Study & CNN & Task & Optimization \\
\noalign{\smallskip}\hline\noalign{\smallskip}
authors &  CNN and Extreme Learning Machine & Image Classification & Ensemble methods with CNN.
\noalign{\smallskip}\hline
\end{tabular}
\end{table}

• The makecell package and its eponymous command provides the possibility to use \ in standard columns. Jun 29 at 23:13
• You may want to take a look at the tabularx and the booktabs package. Jun 30 at 4:42

You could experiment with the p type column which allows auto line breaks

reference from -- https://tex.stackexchange.com/a/166746/197451

\begin{table}
\begin{tabular}{llll}
\hline\noalign{\smallskip}
Study & CNN & Task & Optimization \\
\noalign{\smallskip}\hline\noalign{\smallskip}
authors &  CNN and Extreme Learning Machine & Image Classification & \multicolumn{1}{p{4cm}|}{\raggedright At oprette en server med bestemte regler som tillader folk at spille sammen. More Text more text More Text}  \\
\noalign{\smallskip}\hline
\end{tabular}
\end{table}

• this would be the right answer but you posted the wrong code copied from the question still using l Jun 30 at 7:26

To make your code compilable, a \\ right before the last \noalign{\smallskip}\hline is missing. Having added this missing piece of code, let's focus on improving the output. With the help of the tabularx package you can easily make sure a table fits into the textwidth and horizontal lines from the booktabs package could be used instead of \noalign{\smallskip}\hline. Applying thouse changes, one ends up with:

Depending on your documentclass, the margin and font sizes as well as the individual contents of the table, you may want to alter the width of the X type columns. Table layout with tabularx (column widths: 50%|25%|25%) contains useful information on that. Text in narrower columns often looks better left aligned instead of justified and if you want left-aligned text in your X type columns, you could use >{\raggedright\arraybackslash}X instead of X.

\documentclass{article}
\usepackage{booktabs}
\usepackage{tabularx}
\begin{document}

\begin{table}
\begin{tabularx}{\linewidth}{lXlX}
\toprule
Study & CNN & Task & Optimization \\
\midrule
authors &  CNN and Extreme Learning Machine & Image Classification & Ensemble methods with CNN.\\
\bottomrule
\end{tabularx}
\end{table}

\end{document}