Use siunitx to round numbers while using colortbl to color cells

Fang Jing 06/12/2018. 1 answers, 34 views
tables siunitx colortbl cellcolor

I typically use the siunitx package to round numbers in tables and use the \cellcolor command of the colortbl package to change the background colors of certain cells. However, as the following example shows, they do not really go together: Only numbers in non-colored cells are rounded correctly; numbers in colored cells are not rounded.

How can I make siunitx to round numbers in the colored cells as well?

Table from example




        tight-spacing           = true,
        group-digits            = false,
        input-signs             = ,
        input-symbols           = ,
        input-open-uncertainty  = ,
        input-close-uncertainty = ,
        table-align-text-pre    = false,
        round-mode              = places,
        round-precision         = 3,
        table-space-text-pre    = (,
        table-space-text-post   = ),
        Cell background & {Number}                        & {Number in parentheses} \\
        With color      & \cellcolor{yellow!50}-.0399377* & \cellcolor{yellow!50}(.0358997) \\
        Without color   & -.030879**                      & (.0203602)                      \\


1 Answers

Joseph Wright 06/12/2018.

You need to 'hide' the cell colour part from siunitx:

& {\cellcolor{yellow!50}} -.0399377* &

(The package can pick up simple \color commands but not at present \cellcolor ones.)

Related questions

Hot questions


Popular Tags