1

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

2
  • I should also add that I require line breaks, hence why I am using m{} and \centering{}. Thanks. – John Deeds Apr 20 '13 at 15:24
  • \centering is not a command with an argument; first of all remove the braces. – egreg Apr 20 '13 at 15:47
5

\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)

1
  • Thank you for your prompt reply, this works. Appreciate the help. – John Deeds Apr 21 '13 at 0:54

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.