6

Following the siunitx documentation in regards to '7.13 Creating a column with numbers and units' and '7.14 Tables with heading rows' I have tried to make a table a table with currency as unit. The problem arises when I use \rowcolor. Problem table

I can patch up the problem by setting table-format=7.1 but this creates unwanted space or deleting \rowcolor[gray]{0.92}, but I want the alternating rowcolors.

\documentclass[a4paper, 12pt]{article}

\usepackage{siunitx,booktabs,colortbl}
\begin{document}

\begin{table}[h]
    \centering
    \begin{tabular}
{lSS[table-format=7.0]@{\,}s[table-unit-alignment = left]} \toprule
Company name                    &{Employees}&\multicolumn{2}{c}{Turnover} \\\midrule \rowcolor[gray]{0.92}
JOHNSON CONTROLS APS            &616       &1293896    & \si{USD} \\
SKOV A/S GLYNGOERE              &304       &682921     & \si{USD} \\\rowcolor[gray]{0.92}
EXHAUSTO A/S                    &262       &410914     & \si{USD} \\
SONDEX A/S                      &116       &616943     & \si{USD} \\\rowcolor[gray]{0.92}
NILAN A/S                       &114       &137        & \si{USD} \\
 \bottomrule
\end{tabular}
\end{table}
\end{document}

EDIT: I found a crude solution by setting table-format=7.1 and adding \hspace{-0.7em} before every unit/currency. Crude solution

  • Why don't you add the repeaded unit to the column header? – leandriis Nov 29 '18 at 20:12
2

Make the gap a bit wider to prevent overlapping of the columns:

\documentclass[a4paper, 12pt]{article}

\usepackage{siunitx,booktabs,colortbl}
\begin{document}

\begin{table}[h]
    \centering
    \begin{tabular}{
        l
        S[table-format=3.0]
        S[table-format=7.0]
        @{\hskip 0.08in}
        s[table-unit-alignment = left]
    }
\toprule
Company name                    &{Employees}&\multicolumn{2}{c}{Turnover} \\\midrule \rowcolor[gray]{0.92}
JOHNSON CONTROLS APS            &616       &1293896    & \si{USD} \\
SKOV A/S GLYNGOERE              &304       &682921     & \si{USD} \\\rowcolor[gray]{0.92}
EXHAUSTO A/S                    &262       &410914     & \si{USD} \\
SONDEX A/S                      &116       &616943     & \si{USD} \\\rowcolor[gray]{0.92}
NILAN A/S                       &114       &137        & \si{USD} \\
 \bottomrule
\end{tabular}
\end{table}
\end{document}

enter image description here

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.