6

While trying to display some data in a table, I use tabu and siunitx. I want the content to be centered by the dot. However, the cell at last column, first row is not centered.

enter image description here

\documentclass{article}
\usepackage{siunitx}
\usepackage{tabu}
\newcolumntype Y{S[%
    group-four-digits=false,
    round-mode=places,
    round-precision=3,
    round-integer-to-decimal=false,
    per-mode=symbol,
    detect-all,
    ]}
\tabucolumn Y
\usepackage{booktabs}
\makeatletter
    \def\NN{\tabularnewline}
    \def\FL{\toprule}
    \def\ML{\NN\midrule}
    \def\LL{\NN\bottomrule}
\makeatother

\begin{document}

\begin{tabu}{|c|Y|Y|Y|Y|}
    \FL
    $K$ & {2} & {5} & {10} & {100}
    \ML
    $\gamma_3$ & 0.13731 & 0.14011 & 0.11446 & 0.040306
    \NN
    $\gamma_4$ & -0.22974 & -0.069162 & -0.17112 & 0.11587
    \LL
\end{tabu}
\end{document}
2
6

The problem arises because of the way you have 'hidden' the end-of-row inside another macro. Picking up the last cell in the row correctly is tricky, and this leads to the need to do various pieces of detection inside the package. However, that fails if the \\ (or \tabularnewline) is inside another command. As such, the best way to deal with this is to replace \ML with \\ \midrule here.

1
  • I tried to use \makeatletter \def\NN{\\} \def\FL{\toprule} \def\ML{\NN\midrule} \def\LL{\NN\bottomrule} \makeatother and doing that way it did work. Any clue?
    – cacamailg
    Feb 5 '13 at 12:35

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.