Overful hbox (How to make the sentence in a table into 2 line?)
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} &
\seqsplit{5fsdsadsadasdsadsadasdsadsa} &
\seqsplit{6dasdsadasdasdasdasdsadasdsa} \\
\hline
1 & 2 & 3 & & & \\
1 & 2 & 3 & & & \\
\hline
\end{tabularx}
\caption{tes}
\label{tab:my_label}
\end{table}
\end{document}
\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 &
\begin{tabular}{@{}c@{}}5fsdsadsadasd\\sadsadasdsadsa\end{tabular} &
\begin{tabular}{@{}c@{}}6dasdsadasdasd\\asdasdsadasdsa\end{tabular} \\
\hline
1 & 2 & 3 \\
1 & 2 & 3 \\
\end{tabular}
\caption{tes}
\label{tab:my_label}
\end{table}
\end{document}