This question is a follow up of previous questions: Problem with vertical centering of cells of a same row of a longtable and Vertically centering subtable in cells of a main longtable.
I am using the following code:
\documentclass{article}
\usepackage{longtable,array,xparse,lipsum}
\newcolumntype{L}[1]{>{\raggedright\arraybackslash}m{#1}}
\newcolumntype{C}[1]{>{\centering\arraybackslash}m{#1}}
\newcolumntype{R}[1]{>{\raggedleft\arraybackslash}m{#1}}
\NewDocumentCommand{\TB}{O{c} m O{c}}{%
\begin{tabular}[#1]{@{}#3@{}}#2\end{tabular}
}
\renewcommand*{\arraystretch}{1.15}
\begin{document}
\begin{longtable}{|L{6cm}|L{2cm}|C{2cm}|}
\caption{Your table caption} \label{tab:my_label} \\
\hline
header 1 & header 2 & header 3 \\
\hline
\endhead
\lipsum[1][1-8] & \TB{some text, \\ some text\\some text, \\ some text\\a2} & \TB{b1\\b2\\b3} \\
\hline
\end{longtable}
\end{document}
However, the vertical centering is not being produced:
Could you please help me? Thanks!
\begin{tabular}[#1]{@{}#3@{}}#2\end{tabular}
with\smash{\begin{tabular}[#1]{@{}#3@{}}#2\end{tabular}}
. Not sure why it works...L
,C
andR
column types top{}
and then enclose\lipsum[1][1-8]
within\TB
, that is\TB{\lipsum[1][1-8]}[p{\linewidth}]
, you will get the perfect middle alignment. For some reason, sometimes mixing multilined cells, with nested tabulars makesm{}
incorrect to determine middle points.\TB
to have a multine header, the header overflows the row of the header.