2

I am facing a problem with a table that uses colors as a background for some cells. The used code is:

\documentclass[sigconf]{acmart}

\usepackage{comment}
\usepackage{balance}
\usepackage{graphicx}
\usepackage{booktabs} % For formal tables
\usepackage{xcolor}
\usepackage[table,xcdraw]{}

% Please add the following required packages to your document preamble:
% \usepackage{graphicx}
% \usepackage[table,xcdraw]{xcolor}
% If you use beamer only pass "xcolor=table" option, i.e. \documentclass[xcolor=table]{beamer}
\begin{table}[]
\centering
\caption{xxxxyyyyzzzzz}
\label{tab:xxxx}
\resizebox{\columnwidth}{!}{%
\begin{tabular}{|
>{\columncolor[HTML]{FFFFFF}}l |l|l|
>{\columncolor[HTML]{D9D9D9}}l |
>{\columncolor[HTML]{FF6D01}}l |
>{\columncolor[HTML]{D9D9D9}}l |
>{\columncolor[HTML]{D9D9D9}}l |
>{\columncolor[HTML]{FFFFFF}}l }
\cline{1-7}
 &
  \cellcolor[HTML]{FFFFFF}\textbf{S} &
  \cellcolor[HTML]{FFFFFF}\textbf{T} &
  \cellcolor[HTML]{FFFFFF}\textbf{R} &
  \cellcolor[HTML]{FFFFFF}\textbf{I} &
  \cellcolor[HTML]{FFFFFF}\textbf{D} &
  \cellcolor[HTML]{FFFFFF}\textbf{E} &
  \textbf{} \\ \cline{1-7}
\textbf{DDoS} &
  \cellcolor[HTML]{D9D9D9} &
  \cellcolor[HTML]{D9D9D9} &
   &
  \cellcolor[HTML]{D9D9D9} &
  \cellcolor[HTML]{FF6D01} &
   &
   \\ \cline{1-7}
\textbf{Tampering} &
  \cellcolor[HTML]{FF6D01} &
  \cellcolor[HTML]{0B5394} &
  \cellcolor[HTML]{FBBC04} &
   &
   &
   &
   \\ \cline{1-7}
\textbf{Hijacking} &
  \cellcolor[HTML]{FF6D01} &
  \cellcolor[HTML]{FF6D01} &
   &
   &
   &
   &
   \\ \cline{1-7}
\textbf{Jamming} &
  \cellcolor[HTML]{D9D9D9} &
  \cellcolor[HTML]{D9D9D9} &
   &
   &
  \cellcolor[HTML]{FF6D01} &
   &
   \\ \cline{1-7}
\textbf{Man-in-the-middle} &
  \cellcolor[HTML]{FBBC04} &
  \cellcolor[HTML]{FF6D01} &
  \cellcolor[HTML]{FBBC04} &
   &
   &
  \cellcolor[HTML]{FBBC04} &
   \\ \cline{1-7}
\textbf{Eavesdropping} &
  \cellcolor[HTML]{D9D9D9} &
  \cellcolor[HTML]{D9D9D9} &
   &
   &
   &
   &
   \\ \cline{1-7}
\textbf{Skimming} &
  \cellcolor[HTML]{FBBC04} &
  \cellcolor[HTML]{0B5394} &
  \cellcolor[HTML]{FBBC04} &
   &
   &
   &
   \\ \cline{1-7}
\textbf{Wormhole} &
  \cellcolor[HTML]{D9D9D9}\textbf{} &
  \cellcolor[HTML]{D9D9D9}\textbf{} &
  \textbf{} &
  \textbf{} &
  \cellcolor[HTML]{0B5394}\textbf{} &
  \textbf{} &
   \\ \cline{1-7}
\textbf{Bruteforce} &
  \cellcolor[HTML]{FBBC04} &
  \cellcolor[HTML]{D9D9D9} &
   &
  \cellcolor[HTML]{D9D9D9} &
   &
   &
   \\ \cline{1-7}
\textbf{Spoofing} &
  \cellcolor[HTML]{FF6D01}\textbf{} &
  \cellcolor[HTML]{0B5394} &
   &
  \textbf{} &
  \cellcolor[HTML]{0B5394} &
   &
   \\ \cline{1-7}
\textbf{Sybil Attack} &
  \cellcolor[HTML]{FBBC04} &
  \cellcolor[HTML]{D9D9D9} &
   &
  \cellcolor[HTML]{FBBC04} &
   &
  \cellcolor[HTML]{FF6D01}\textbf{} &
   \\ \cline{1-7}
\textbf{Node Replication} &
  \cellcolor[HTML]{D9D9D9} &
  \cellcolor[HTML]{0B5394} &
   &
  \cellcolor[HTML]{FBBC04} &
  \cellcolor[HTML]{FF6D01}\textbf{} &
   &
   \\ \cline{1-7}
\textbf{Relay Attack} &
  \cellcolor[HTML]{FBBC04} &
  \cellcolor[HTML]{0B5394} &
  \cellcolor[HTML]{FBBC04} &
   &
   &
   &
   \\ \cline{1-7}
\end{tabular}%
}
\end{table}

I am using the ACM sigconf template in the Overleaf and I am getting many errors related to this table:

<argument> | {\columncolor 
                           [HTML]{FFFFFF}}l |l|l| >{\columncolor [HTML]{D9D9...
l.207 }
       
The control sequence at the end of the top line of your error message was never \def'ed. If you have misspelled it (e.g., `\hobx'), type `I' and the correct spelling (e.g., `I\hbox'). Otherwise just continue, and I'll forget about whatever was undefined.

Does anyone know why I am getting these errors? I generated the table using the Tables Generator.

2
  • 1
    You have error in preamble. Instead of \usepackage{xcolor} \usepackage[table,xcdraw]{} you should write \usepackage[table,xcdraw]{xcolor}.
    – Zarko
    Commented Oct 15, 2022 at 19:34
  • Dear @Zarko , before I open the question, I had put as you suggested, but I received an error telling that the template already uses the package. By trying again now, I read the compiler suggestion to put prologue,table,xcdraw in the document class. I added it and now it worked. It is: \documentclass[sigconf,prologue,table,xcdraw]{acmart}. Thank you for the help. Please add the suggestion as an answer. Commented Oct 15, 2022 at 19:44

1 Answer 1

5

Your MWE (Minimum Working Examples, a small but complete document with your table) has two errors:

  • missed the begin{document}
  • wrong use of xcolor
    • In case of use article document class you should instead of
\usepackage{xcolor} 
\usepackage[table,xcdraw]{}   

you should write

\usepackage[table,xcdraw]{xcolor}
  • In case of using acmart document class, you should change
\documentclass[sigconf]{acmart}

to what you suggest in comment_

\documentclass[sigconf,prologue,table,xcdraw]{acmart}

and delete

\usepackage{xcolor} 
\usepackage[table,xcdraw]{}   

Testing your MWE in Overleaf (I haven't installed acmart document class) I get:

enter image description here

Addendum:
Off-topic: An example of handwritten table using tblr table defined in the tabularray package and named colors:

\documentclass[sigconf,dvipsnames]{acmart}
\usepackage[skip=0.33\baselineskip]{caption}
\usepackage[dvipsnames]{xcolor}
\usepackage{tabularray}
\NewTableCommand\SCC[1]{\SetCell{bg=#1}}


\begin{document}
    \begin{table}[ht]
    \centering
\caption{Threats classified with STRIDE and CVSS}
\label{tab:stride}
    \begin{tblr}{hlines, vlines,
                 colspec = {l *{6}{Q[c, wd=2em, bg=gray!20]}},
                 row{1} = {font=\bfseries, bg=white}
                 }
        & S & T & R & I & D & E             \\
DDoS    &   &   &   &   & \SCC{orange}
                            &               \\
Tampering
        & \SCC{Orange}
            & \SCC{NavyBlue}
                & \SCC{Dandelion}
                    & \SCC{Orange}
                        &   &               \\
Hijacking
        & \SCC{Orange}
            & \SCC{Orange}
                &   & \SCC{Orange}
                        &   &               \\
Jamming
        &   &   &   &  \SCC{Orange}
                        & \SCC{Orange}
                            &               \\
Man-in-the-middle
        & \SCC{Dandelion}
            & \SCC{Orange}
                & \SCC{Dandelion}
                    & \SCC{Orange}
                        &   & \SCC{Dandelion}  \\
Eavesdropping
        &   &   &   & \SCC{Orange}
                        &   &               \\
Skimming
        & \SCC{Dandelion}
            & \SCC{NavyBlue}
                & \SCC{Dandelion}
                    & \SCC{Orange}
                        &   &               \\ 

Wormhole    
        &   &   &   & \SCC{Orange}
                        & \SCC{NavyBlue}
                            &               \\
Bruteforce
        & \SCC{Dandelion}
            &   &   &   &   &               \\
Spoofing
        & \SCC{Orange}
            & \SCC{NavyBlue}
                &   & \SCC{Orange}
                        & \SCC{NavyBlue}
                            &               \\
Sybil Attack
       & \SCC{Orange}
            &   &   & \SCC{Dandelion}
                        &   & \SCC{Orange}  \\
Node Replication
       &    &\SCC{NavyBlue}
                &   & \SCC{Dandelion}
                        & \SCC{Orange}  
                            &           \\
Relay Attack
       & \SCC{Dandelion}
            & \SCC{NavyBlue}
                & \SCC{Dandelion}
                    & \SCC{Orange}
                        &   &           \\
     \end{tblr}
    \end{table}
\end{document}




\documentclass{article}
%---------------- show page layout. don't use in a real document!
\usepackage{showframe}
\renewcommand\ShowFrameLinethickness{0.15pt}
\renewcommand*\ShowFrameColor{\color{red}}
%---------------------------------------------------------------%
\usepackage{pgfplots}
\usepgfplotslibrary{groupplots}
\pgfplotsset{compat=1.18}

\begin{document}
    \begin{figure}[ht]
\begin{tikzpicture}
    \begin{groupplot}[
group style={
    group size=3 by 1,
    ylabels at=edge left,
    horizontal sep=6mm,
            },
%
    width=0.27\linewidth, %height=4cm,
    scale only axis,
    title style = {font=\small},
%
    enlarge x limits=0.3,
    xlabel={x},     ylabel={y},
    symbolic x coords={3-6, 6-12, 12-24},
    %xtick={3-6, 6-12, 12-24},
    xticklabel style={font=\small},
    ytick={0,2,...,12},
    ymin=0,     ymax=12,
%
    nodes near coords,
    every node near coord/.append style={font=\scriptsize},
%
    legend image code/.code={\draw[#1] (0cm,-0.1cm) rectangle (0.6cm,0.1cm);},
    legend style={at={(0.5,-0.3)},
                  anchor=north,
                  legend columns=-1,
                  font=\footnotesize,
                  /tikz/every even column/.append style={column sep=1em}
                  }
                    ]
\nextgroupplot[title=MADDPG]
    \addplot[ybar, fill=olive]  coordinates {  (3-6,   6.886) };
    \addplot[ybar, fill=orange] coordinates {  (6-12,  8.501) };
    \addplot[ybar, fill=teal]   coordinates {  (12-24,10.179) };

\nextgroupplot[title={\scriptsize MATD3}]
    \addplot[ybar, fill=olive]  coordinates {  (3-6,   6.886) };
    \addplot[ybar, fill=orange] coordinates {  (6-12,  8.501) };
    \addplot[ybar, fill=teal]   coordinates {  (12-24,10.179) };
\legend{\color{olive}{Random},
        \color{orange}{++Cost},
        \color{teal}{++FTE}},

\nextgroupplot[title={\scriptsize MASAC}]
    \addplot[ybar, fill=olive]  coordinates {  (3-6,   6.886) };
    \addplot[ybar, fill=orange] coordinates {  (6-12,  8.501) };
    \addplot[ybar, fill=teal]   coordinates {  (12-24,10.179) };
    \end{groupplot}
\end{tikzpicture}
        \caption{Triage++ Performance}
        \label{PlusPlusCombinedBar}
    \end{figure}
\end{document}


\documentclass{article}
\usepackage[margin=25mm]{geometry}
\usepackage[T1]{fontenc}
\usepackage{tabularray}
\UseTblrLibrary{booktabs, siunitx}

\begin{document}
    \begin{longtblr}[
caption={Add caption},
  label={tab:addlabel}    
                    ]{hlines, vlines,
                      colspec={l 
                               X[2,l] 
                               *{4}{X[c, si={table-format=-1.4}]}},
                      row{1,2}={guard, font=\bfseries, m},
                      rowhead=2
                      }
\SetCell[r=2]{l}    Value
        &    \SetCell[r=2]{l}    Group
            &    \SetCell[c=4]{c}    Tukey HSD test
                &    &    &                                 \\
        &   &    diff
                &    lwr
                    &    upr
                        &    {Pr(>\,F) \\ (0.05)}           \\
\SetCell[c=6]{l, font=\bfseries}   Gender                                   \\
    HEDONISM
        & Male-Female
            & -0.2468   & -0.2890   & -0.2046   &  0.0000   \\
    SELF\_DIRECTION
        & Male-Female
            & -0.2015   & -0.2506   & -0.1524   &  0.0000   \\
    STIMULATION
        & Male-Female
            &  0.1442   &  0.0919   &  0.1966   &  0.0000   \\
    SECURITY
        & Male-Female
            &  0.0264   & -0.0300   &  0.0828   &  0.3584   \\
    CONFORMITY
        & Male-Female
            &  0.0378   & -0.0132   &  0.0888   &  0.1459   \\
    TRADITION
        & Male-Female
            &  0.0619   &  0.0121   &  0.1117   &  0.0148   \\
    ACHIEVEMENT
        & Male-Female
            & -0.0389   & -0.0928   &  0.0150   &  0.1567   \\
    POWER
        & Male-Female
            &  0.2788   &  0.2352   &  0.3225   &  0.0000    \\*
    UNIVERSALISM
        & Male-Female
            &  0.2295   &  0.1844   &  0.2746   &  0.0000   \\*
    BENEVOLENCE
        & Male-Female
            &  0.0388   & -0.0143   &  0.0920   &  0.1520   \\
\SetCell[c=6]{l, font=\bfseries}   Age                                      \\
\SetCell[r=3]{l}    HEDONISM
    & Old-Middle
            &  0.1400   &  0.0624   &  0.2176   &  0.0001   \\*
    & Young-Middle
            & -0.3025   & -0.3800   & -0.2250   &  0.0000   \\*
    & Young-Old
            & -0.4425   & -0.5306   & -0.3543   &  0.0000   \\
    \SetCell[r=3]{l}    SELF\_DIRECTION
        & Old-Middle
            &  0.1956   &  0.1292   &  0.2620   &  0.0000   \\*
    & Young-Middle
            & -0.3776   & -0.4439   & -0.3113   &  0.0000   \\*
    & Young-Old
            & -0.5732   & -0.6486   & -0.4978   &  0.0000   \\
    \end{longtblr}
    \end{document}

Result is quite similar as above (colors may slightly differ and text in the first column is not boldface):

enter image description here

IN the case, that for some reason (to my opinion typography less pleasent), then change `colspec to:

                 colspec = {Q[font=\bfseries *{6}{Q[c, wd=2em, bg=gray!20]}},

You must log in to answer this question.

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