0

I need to split the text in the cell. I have tried the \par but this command doesn't work inside the brackets { }. My attempt is below.

enter image description here

\begin{table}[]
\centering
\caption{Caption}\label{tab2}
\begin{tabular}{|p{4cm}|p{4cm}|p{4cm}|}
\hline
\multicolumn{1}{|c|} {\textbf{Title1}} & \multicolumn{1}{c|} {\textbf{Title2}} & \multicolumn{1}{c|} {\textbf{Title3}} \\ \hline
\multicolumn{1}{|l|}{text text text text} & text text text  text  text & text text text text text text text text text text \\ \hline
\multicolumn{1}{|l|}{ text text text } & text text text text text & text text text text text text text text text text text text \\ \hline
\multicolumn{3}{|c|}{ text text text } \\ \hline
\multicolumn{1}{|l|}{ text text text } & связях text text text text & text \\ \hline
\multicolumn{3}{|c|}{ text text }   \\ \hline
\multicolumn{1}{|l|}{ text text text } & text text text & text text text \\ \hline
\multicolumn{3}{|c|}{ text } \\ \hline
\multicolumn{2}{|c|}{ text text text } & text \\ \hline
\multicolumn{3}{|c|}{ text …} \\ \hline
\multicolumn{1}{|l|} {text text  texttexttext \par texttexttext} & texttexttext \par texttexttext texttexttexttext & texttexttexttext texttexttexttext \\ \hline
\end{tabular}
\end{table}
  • You've got \begin{tabular}{|p{4cm}... which will give you a 4cm wide cell in which lines will break, but then for some reason you then have \multicolumn{1}{|l|} { with an l column type instead of a p column type which completely overrides it and produces a cell which won't break lines? – Au101 Sep 5 '18 at 1:40
3

Your \multicolumn{1}{l} spoils your try. Please see the corrected version:

\documentclass{article}


\begin{document}

\begin{table}[]
\centering
\caption{Caption}\label{tab2}
\begin{tabular}{|p{4cm}|p{4cm}|p{4cm}|}
\hline
\multicolumn{1}{|c|} {\textbf{Title1}} & \multicolumn{1}{c|} {\textbf{Title2}} & \multicolumn{1}{c|} {\textbf{Title3}} \\ \hline
\multicolumn{1}{|l|}{text text text text} & text text text  text  text & text text text text text text text text text text \\ \hline
\multicolumn{1}{|l|}{ text text text } & text text text text text & text text text text text text text text text text text text \\ \hline
\multicolumn{3}{|c|}{ text text text } \\ \hline
\multicolumn{1}{|l|}{ text text text } & связях text text text text & text \\ \hline
\multicolumn{3}{|c|}{ text text }   \\ \hline
\multicolumn{1}{|l|}{ text text text } & text text text & text text text \\ \hline
\multicolumn{3}{|c|}{ text } \\ \hline
\multicolumn{2}{|c|}{ text text text } & text \\ \hline
\multicolumn{3}{|c|}{ text …} \\ \hline
%\multicolumn{1}{|l|} {text text  texttexttext \par texttexttext} & texttexttext \par texttexttext texttexttexttext & texttexttexttext texttexttexttext \\ \hline
{text text  texttexttext \par texttexttext} & texttexttext \par texttexttext texttexttexttext & texttexttexttext texttexttexttext \\ \hline
\end{tabular}
\end{table}

\end{document}

enter image description here

2
  • in your table all \multicolumn{1}{...}{...} are superfluous. remove them.
  • for column headers use the \thead macro from package makecell
  • for nicer looking of table i would add vertical space around cells' contents with use of \setcellgapes{3pt}\makegapedcells from the package makecell

    \documentclass{article}
    \usepackage{makecell}
    \renewcommand\thead{\normalsize\bfseries}
    \renewcommand\theadgape{}
    
    \begin{document}
        \begin{table}[htb]
        \setcellgapes{3pt}\makegapedcells
        \centering
    \caption{Caption}
        \label{tab2}
    \begin{tabular}{|p{4cm}|p{4cm}|p{4cm}|}
        \hline
    \thead{Title1}  & \thead{Title2}    & \thead{Title3}                    \\
        \hline
    text text text text
        & text text text text text
            & text text text text text text text text text text             \\
        \hline
    text text text
        & text text text text text
            & text text text text text text text text text text text text   \\
        \hline
    \multicolumn{3}{|c|}{ text text text }                                  \\
        \hline
    text text text
        & text text text text
            & text                                                          \\
        \hline
    \multicolumn{3}{|c|}{ text text }                                       \\
        \hline
    text text text
        & text text text
            & text text text                                                \\
        \hline
    \multicolumn{3}{|c|}{ text }                                            \\
        \hline
    \multicolumn{2}{|c|}{ text text text }
            & text                                                          \\
        \hline
    \multicolumn{3}{|c|}{ text \dots}                                       \\
        \hline
    text text  texttexttext \par
    texttexttext
        & texttexttext \par
          texttexttext texttexttexttext
            & texttexttexttext texttexttexttext                             \\
        \hline
    \end{tabular}
        \end{table}
    \end{document}
    

enter image description here

  • +1. Out of the question, IMHO also are superfluous all the vertical lines and the third horizontal line, whereas the others should be preferably booktabs rules. – Fran Sep 5 '18 at 9:05
  • @Fran, thank you! i agree with you, however this would change appearance of table, i.e. this would make table more "professional". – Zarko Sep 5 '18 at 9:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.