[Tex/LaTex] Line spacing and alignment issues in tables with multiline cells

tables

While trying to create tables with multiline cells, I run into some line spacing and alignment issues. The following code creates two tables:

\documentclass[10pt]{article}
\usepackage[english]{babel}
\usepackage{pbox}
\usepackage{multirow}

\begin{document}
\begin{table}[htp]
\centering
\begin{tabular}{lll}
cell11 & cell21 & cell31\\
cell12 & \begin{tabular}{l} cell221 \\ cell222 \\ \end{tabular} & cell32\\
\pbox[t]{5cm}{cell131 \\ cell132} & cell23 & cell33\\
cell14 & cell24 & \multirow{2}{*}{\pbox[t]{5cm}{cell341 \\ cell342}} \\
\\
cell15 & cell25 & cell35\\
cell16 & cell26 & cell36\\
\end{tabular}\vrule
\begin{tabular}{lll}
cell11 & cell21 & cell31\\
cell12 & cell221 & cell32\\
 & cell222 & \\
cell131 & cell23 & cell33\\
cell132 & & \\
cell14 & cell24 & cell341\\
 & & cell342\\
cell15 & cell25 & cell35\\
cell16 & cell26 & cell36\\
\end{tabular}
\caption{left: My attempts of a table with multiline cells. None of the attempts lead to the desired result. right: How it should look; the desired table with manually inserted empty cells, a lot of work and not really flexible.}
\end{table}
\end{document}

tables
The right table shows the desired result. It was created using empty cells, lacking flexibility in case of changing content. In the left table, the attempts to make multirow/multiline cells are shown.
Note the line spacing and alignment issues. Lines 5 and 6 (without any multiline
cells) have the correct distance from each other. A tabular within the table
(cells 221 and 222) gives the correct intra- and intercell line spacing, however
the horizontal alignment is incorrect. Additionally, cells 12 and 32 have an
incorrect vertical alignment. Using pbox (cells 131 and 132) aligns the full row
correctly. Line spacing within the cell is correct, but the spacing to the next
cell (from 132 to 14) is to small. This might lead to the impression, that 132
and 14 belong together. The same problem occurs when using multirow (cells
341 and 342). Within the cell, line spacing is correct, but spacing between 342
and 35 is to small.
Question: how to create a table with multiline cells and correct spacing/alignment?


For me, the two answers provided by David and Steven both work equally well. Since I like to keep my documents as simple as possible, I decided to use David's solution, as no additional package is needed. Consequently, I accepted his answer. This is just my personal preference and no judgement on the quality of the quality of the soultions.

Best Answer

enter image description here

\documentclass[10pt]{article}
\usepackage[english]{babel}


\begin{document}
\begin{table}[htp]
\centering
\begin{tabular}{lll}
cell11 & cell21 & cell31\\
cell12 & \begin{tabular}[t]{@{}l@{}} cell221 \\ cell222 \\ \end{tabular} & cell32\\
\begin{tabular}[t]{@{}l@{}} cell131 \\ cell132\end{tabular} & cell23 & cell33\\
cell14 & cell24 & \begin{tabular}[t]{@{}l@{}} cell341 \\ cell342\end{tabular} \\
cell15 & cell25 & cell35\\
cell16 & cell26 & cell36\\
\end{tabular}\vrule
\begin{tabular}{lll}
cell11 & cell21 & cell31\\
cell12 & cell221 & cell32\\
 & cell222 & \\
cell131 & cell23 & cell33\\
cell132 & & \\
cell14 & cell24 & cell341\\
 & & cell342\\
cell15 & cell25 & cell35\\
cell16 & cell26 & cell36\\
\end{tabular}
\caption{left: My attempts of a table with multiline cells. None of the attempts lead to the desired result. right: How it should look; the desired table with manually inserted empty cells, a lot of work and not really flexible.}
\end{table}
\end{document}