6

I would like to use ctable in my thesis for tables and graphics and I also would like to use siunitx for formatting numbers and aligning numbers on the decimal marker in tables.

Everything seemed to work well until I discovered some strange behaviour in the last column. The heading does not get centered there (I tried the different settings for siunitx: table-alignment, table-text-alignment, in the preamble and for the specific column). It did not help.

ctable version is rev 26694, v 1.23;

siunitx is rev 29017, v 2.5p

This is my minimal example:

\documentclass[english]{book}
\usepackage[utf8]{inputenc}
\usepackage{babel}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{ctable}
\usepackage{siunitx}
\begin{document}

% Does not center the heading in the last column.
\ctable[]{
  |l
  |S
  |S
  |S|
}{}{
  \FL
  &         {Tom} &     {Suzy} &    {Rob} \ML
  Eating &      122.5 &     1.025 &     1.5 \NN
  Sleeping &    9.1 &       1346.5 &    213.7 \NN
  Working &     7.5 &       9.5 &       2.0125 \NN
  Watching TV & 5.25 &      117.5 &     7.5 \LL}

% Works fine with simple tabular
\begin{tabular}{
  |l
  |S
  |S
  |S|
  }
  \hline
  &         {Tom} &     {Suzy} &    {Rob} \\ \hline
  Eating &      122.5 &     1.025 &     1.5 \\
  Sleeping &    9.1 &       1346.5 &    213.7 \\
  Working &     7.5 &       9.5 &       2.0125 \\
  Watching TV & 5.25 &      117.5 &     7.5 \\ \hline
\end{tabular}

\end{document}

This is how it looks to me:

ctable and tabular

  • 1
    Interesting... A simple fix is adding an empty last column by changing the |S| to |S|@{}l@{}, and the changing {Rob} \ML to {Rob} &\ML. – Peter Grill Mar 4 '13 at 21:14
  • Welcome to TeX.sx! – Peter Jansson Mar 4 '13 at 21:29
  • 1
    It's a known problem, I believe: an S column needs to see either & or \\ to know where it ends and \ML is not good when there's \multicolumn. I tried to find an answer by Joseph Wright, but didn't find it. – egreg Mar 4 '13 at 21:38
  • 1
    rather than change the preamble you can just change \ML to \tabularnewline \midrule which is the same thing, but works – David Carlisle Mar 4 '13 at 21:42
  • Thank you, too! I was too quick in hitting Enter on my last comment (and too slow in editing it). So here the rest of my text: It seems to work just fine with &, \\ and with \\tabularnewline. I will use those commands together with the original booktabs-commands in the future. To me those are easier to read and remember anyway. Problem solved :-) But to mark it as such it would net an answer, right? – jogru Mar 4 '13 at 21:50
5

Just to close off the solution in the comments

Rather than change the preamble you can just change \ML to \tabularnewline \midrule which is the same thing, but works.

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.