1

I want to fill the cell "physical badging", but when I use \cellcolor, a white rectangle appears on the right side. I don't understand why. The code is below:

\begin{tabular}{|c|c|c|c|c|c|}
\hline           
&\cellcolor{darkgray!95}\color{white} provider      & \cellcolor{darkgray!95}\color{white} timing & \cellcolor{darkgray!95}\color{white}friction &\cellcolor{darkgray!95}\color{white} resilience & \cellcolor{darkgray!95}\color{white}\makecell{infrastructure\\requirement}\\ \hline
\cellcolor{lightgray}\textbf{\makecell{manual \\ completion}}   & \makecell{worker or \\ employer} & async  & high & low   & low   \\ \hline
\cellcolor{lightgray}\textbf{\makecell{physical\\badging}   }& worker    & sync    & mid      & mid to high   & mid to high\\ \hline
\cellcolor{lightgray}\textbf{digital log}& worker  & sync     & low to mid     & mid    & low to mid \\ \hline
\cellcolor{lightgray}\textbf{\makecell{geofencing\\-\\smart\\contact\\tracing}}& process & sync & low  & high  & low to mid \\ \hline 
\end{tabular}

and the output is:

enter image description here

1
  • Welcome, you extend your code into a small example that can be compiled please?
    – JamesT
    Commented Apr 5, 2023 at 12:55

2 Answers 2

0

The following example works if you specify p{} column type with explicit width:

\documentclass{article}
\usepackage{geometry}
\usepackage{makecell}
\usepackage{xcolor}
\usepackage{colortbl}

\newcolumntype{P}{>{\centering}p{2.5cm}}
\renewcommand\cellalign{{}{P}}


\begin{document}
\begin{table}[tbh]
    \centering
    \begin{tabular}{| >{\columncolor{lightgray}}c| *5{c|}}
    \hline
        \rowcolor{darkgray!95}\cellcolor{white}
        & \color{white}provider
        & \color{white}timing
        & \color{white}friction
        & \color{white}resilience
        & \color{white}\makecell{infrastructure\\requirement} \\
        \hline
        \textbf{\makecell{manual\\completion}}
        & \makecell{worker or\\employer}
        & async
        & high
        & low
        & low \\
        \hline
        \textbf{\makecell{physical\\badging}}
        & worker
        & sync
        & mid
        & mid to high
        & mid to high \\
        \hline
        \textbf{\makecell{digital\\log}}
        & worker
        & sync
        & low to mid
        & mid
        & low to mid \\
        \hline
        \textbf{\makecell{geofencing\\-\\smart\\contact\\tracing}}
        & process
        & sync
        & low
        & high
        & low to mid \\
        \hline 
    \end{tabular}
\end{table}
\end{document}

enter image description here

1
  • Yes, It's work. Thanks @Celdor.
    – Dtinas10
    Commented Apr 5, 2023 at 15:23
1

For information, here is a way to create that tabular with {NiceTabular} of nicematrix.

\documentclass{article}
\usepackage{geometry}
\usepackage{xcolor}
\usepackage{nicematrix}

\begin{document}
\begin{table}[tbh]
\centering
\begin{NiceTabular}{>{\bfseries}c*5{c}}[hvlines,cell-space-limits=4pt]
\CodeBefore
  \rectanglecolor{darkgray!95}{1-2}{1-*}
  \rectanglecolor{lightgray}{2-1}{*-1}
\Body
    \RowStyle[color=white]{\sffamily}
    & provider
    & timing
    & friction
    & resilience
    & \Block{}{infrastructure\\requirement} \\
    \Block{}{manual\\completion}
    & \Block{}{worker or\\employer}
    & async
    & high
    & low
    & low \\
    \Block{}{physical\\badging}
    & worker
    & sync
    & mid
    & mid to high
    & mid to high \\
    \Block{}{digital\\log}
    & worker
    & sync
    & low to mid
    & mid
    & low to mid \\
    \Block{}{geofencing\\-\\smart\\contact\\tracing}
    & process
    & sync
    & low
    & high
    & low to mid \\
\end{NiceTabular}
\end{table}
\end{document}

You need several compilations (because nicematrix uses PGF/TikZ nodes under the hood).

Output of the above code

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .