# Overful hbox (How to make the sentence in a table into 2 line?)

\begin{table}[h!]
\centering
\begin{tabular}{l|c |c |c |c |c |c}
\hline
1 & 2 & 3 \\
1 & 2 & 3 \\
\end{tabular}
\caption{tes}
\label{tab:my_label}
\end{table}


Output:

5fsdsadsadasd

• You can use p{<width>} column type for last three columns. It will works fine with natural words (which eventually can be hyphenated). – Zarko Aug 2 at 17:29
• you should supply a proper test file, you have given no indication of the required page width, also 5fsdsadsadasdsadsadasdsadsa not being a real word, which means that it will not hyphenate and so automatic line breaking is harder, is your real text natural language text? – David Carlisle Aug 2 at 17:38
• @DavidCarlisle Thanks. I am not sure how to check my page width. I used a template for it. And yes, {5fsdsadsadasdsadsadasdsadsa} can be a real word, just an example – aan Aug 2 at 21:44
• @user193541 then it is a bad example as breaking 5fsdsadsadasdsadsadasdsadsa automatically is far harder than breaking natural language text, so both examples that have have are probably not suitable for natural language. You could have posted a complete document just useing article as both answers have done – David Carlisle Aug 2 at 21:50

You haven't indicated how wide columns 4, 5, and 6 are supposed to be. Hence, I'll assume they're supposed to be equally wide. I will further assume that the overall width of the tabular material should be \textwidth, i.e., as wide as the text block. The code below employs a tabularx environment and three columns of type X.

Since there is no obvious way -- to me at least... -- to decide where the strings "5fsdsadsadasdsadsadasdsadsa" and "6dasdsadasdasdasdasdsadasdsa" should be split, I'll use the \seqsplit macro to force line breaks to occur whenever the strings reach the widths of the respective cells.

\documentclass{article}
\usepackage{tabularx,seqsplit}
\begin{document}
\begin{table}[h!]
\setlength\extrarowheight{2pt} % for a ever so slightly more open "look"
\begin{tabularx}{\textwidth}{|c |c |c |X |X |X |}
\hline
1 & 2 & 3 &
\seqsplit{4jkjhkjkhjhkjkjkjl} &
\hline
1 & 2 & 3 & & & \\
1 & 2 & 3 & & & \\
\hline
\end{tabularx}
\caption{tes}
\label{tab:my_label}
\end{table}
\end{document}

• Thanks, work very well. – aan Aug 2 at 21:54
• Can you explain what "\setlength\extrarowheight{2pt} " means? Is this mean 2 line? – aan Aug 2 at 22:03
• @user193541 - \extrarowheight is a length parameter that governs much extra vertical whitespace is inserted at the top of each row; its default value is 0pt. Try is out an a tabular environment -- first with the value set at its default, then with a value of 2pt. I think you'll notice the difference right away. – Mico Aug 2 at 22:18
• Thanks. However, the words is combine without a spacing in the orginal words. Meaning let say '\seqsplit{Testing 1 testing 2 Testing 3l}'. It will become 'Testing1testing2Testing3' and not 'Testing 1 testing 2 Testing 3' – aan Aug 2 at 22:28
• @user193541 - Don’t use \seqsplit if there’s no need for it. – Mico Aug 2 at 22:42

\documentclass{article}

\begin{document}

\begin{table}[htp]% h on its own is asking for trouble
\centering
\begin{tabular}{l|c |c |c |c |c |c}
1 & 2 & 3 & 4jkjhkjkhjhkjkjkjl &