4

Is it possible to use a rowstyle with S-column provided by sinuitx? When I try the following the S-column does not allign the numbers (they are not even recognized as actual numbers):

\documentclass{article}
\usepackage{array}
\usepackage{siunitx}

\newcolumntype{+}{>{\global\let\currentrowstyle\relax}}
\newcolumntype{^}{>{\currentrowstyle}}
\newcommand{\rowstyle}[1]{\gdef\currentrowstyle{#1}%
  #1\ignorespaces
}

\begin{document}

\begin{tabular}{+l^c^r^S}
\rowstyle{\bfseries}
    A & B & C & {Number}\\
    a & a & a & 3.14 \\
    b & b & b & 12.1 \\
    c & c & c & .333 \\
\end{tabular}

\end{document}

I also tried using other symbols for the columntype commands - without success. Without the rowstyle the S-column works without a problem.

Maybe there is a solution using dcolumn but there are problems reported when using icomma and I would like to have the formatting of siunitx all over my document.

5

enter image description here

\documentclass{article}
\usepackage{array}
\usepackage{siunitx}

\newcolumntype{+}{>{\global\let\currentrowstyle\empty}}
\newcolumntype{^}{>{\currentrowstyle}}
\newcommand{\rowstyle}[1]{\gdef\currentrowstyle{#1}%
  #1\ignorespaces
}

\begin{document}

\begin{tabular}{+l^c^r^S}
\rowstyle{\bfseries}
    A & B & C & {Number}\\
    a & a & a & 3.14 \\
    b & b & b & 12.1 \\
    c & c & c & .333 \\
\end{tabular}

\end{document}
  • I just figured out that the solution works well for the example above. Unfortunately latex runs on endlessly when the first column behind + is an S column. Until now I could not figure out why. – Echo Mar 17 '15 at 9:09

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.