Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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}
share|improve this question
    
Is your question similar to Aligning text in S columns in a way that respects the decimal marker for numerical entries I wonder if the 'standard' \newcommand{\heading}[1]{\multicolumn{1}{c}{#1}} trick could work for you? –  cmhughes Feb 5 '13 at 5:28
    
I tried that. It does the trick, however a global solution would be better. –  cacamailg Feb 5 '13 at 5:31
add comment

1 Answer

up vote 6 down vote accepted

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.

share|improve this answer
    
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
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.