[Tex/LaTex] Last cell in complex table not behaving

tablestabularxvertical alignment

I am having a hard time figuring out why the text in the last cell on each row of this complex table I am creating is not positioning correctly. As you can see from my code, the issue only occurs when I set the height of the row manually (using the [size] technique after \\ or \tabularnewline).

Can anyone point out what I am doing wrong? Everything seems to work apart from this small, but annoying issue. I know it's a "last cell on line" thing, because if I add another column, the issue transfers to the cells in that column.

\begin{tabularx}{\linewidth}{X|m{1.4cm}|m{1.4cm}|m{1.4cm}|m{1.4cm}}
& & \centering{\textbf{\emph{C1}}} & \centering{\textbf{\emph{C2}}} & 
\centering{\textbf{\emph{C3}}}
    \tabularnewline
\hline

\centering{R1}
& \centering{OK}
& \centering{OK}
& \centering{OK}
& \centering{BAD}
\tabularnewline[1em]
\hline

\centering{R2}
& \centering{L1\\L2}
& \centering{OK}
& \centering{OK}
& \centering{OK}
\tabularnewline
\hline

\end{tabularx}

Here is a screenshot of the offending cell:

image

Best Answer

\centering{OK} should be {\centering OK\par} as \centering does not take an argument, and the end of paragraph needs to be in its scope. that would fix your problem however a more convenient way is to remove all the \centering from the cells and use

>{\centering\arraybackslash}m{1.4cm}

which inserts the command automatically into each cell, and restores the meaning of \\ to end a table cell (\centering defines it to make a centred line break)

Related Question