1

I am trying to colour rows in some tables in a latex IEEEtran article but the colouring does not show at all, and no error is thrown as well. Here is the snippet of code I used:

\usepackage{array, booktabs, makecell, tabularx}
\usepackage[pdftex]{graphicx}
\usepackage{graphicx}
\usepackage[export]{adjustbox}
\usepackage{subfigure}
\usepackage{float}
\usepackage[colorlinks,allcolors=blue]{hyperref}
\usepackage{amsmath}
\setcellgapes{4pt}%parameter for the spacing
\usepackage{mdwmath}
\usepackage{mdwtab}
\usepackage{colortbl}
\usepackage{xcolor}
\usepackage{multirow}
\begin{document}
            \begin{table*}[t]
             \centering
             \caption{Some of the previous DBQ studies in the literature} \label{tab:Studies}
             \begin{tabular}{lccl}
               &&&\\
               \rowcolor{gray!20}
               \multirow{-2}{*}{\textbf{Country}} & \multirow{-2}{*}{\textbf{DBQ type}} & \multirow{-2}{*}{\textbf{Year published}} & \multirow{-2}{*}{\textbf{Resulting factors}}\\
                \rowcolor{gray!20}
                \midrule
                \multirow{2}{*}{UK\cite{parker1995}}& \multirow{3}{*}{....} & \multirow{3}{*}{1995} & driving under influence \\
                &&& driving while texting\\
                \bottomrule
             \end{tabular}
            \end{table*}
\end{document}
2
  • package mdwtab is not compatible with the package colortbl, consequently with it row colors not show up
  • ieee journals doesn't allows colored tables
  • your table code is unnecessary complicated. do you really need all this multirows and table over two columns? with example of table, which you provide it can be easily fit in one column.
  • if you persist with colored row with column headers than a possible mwe (mnimal working example) can be:

    \documentclass[twocolumn]{IEEEtran}
    \usepackage{booktabs, cellspace, multirow, tabularx}
        \setlength\cellspacetoplimit{4pt}
        \setlength\cellspacebottomlimit{4pt}
        \newcolumntype{R}{>{\raggedright\arraybackslash}X}
        \addparagraphcolumntypes{R}
    \usepackage{ragged2e}
    
    \usepackage[table]{xcolor}
    \usepackage[export]{adjustbox}
    \usepackage{amsmath}
    
    \usepackage[colorlinks,allcolors=blue]{hyperref}
    \usepackage{lipsum}
    
    \begin{document}
    \lipsum[66]
        \begin{table}[htb]
    \centering
    \caption{Some of the previous DBQ studies in the literature} \label{tab:Studies}
    \begin{tabularx}{\linewidth}{l c c S{R}}
    \rowcolor{gray!20}
    \textbf{Country}
        & \textbf{DBQ type} & \textbf{Year published} & \textbf{Resulting factors}  \\
    %
    UK\cite{parker1995}
        &                   & 1995                      & driving under influence   \\
    ...
        & ...               & ...                       & driving while texting     \\
        \bottomrule
    \end{tabularx}
        \end{table}
    \lipsum[1-5]
    \end{document}
    

enter image description here

  • above table is simple to extend to table*
  • if cell contents in your table is bigger, please provide three rows of table which emulate your real table.
  • Thank you for all your hard work! I will take everything in mind. Kudos – Med Aymane Ahajjam Feb 19 at 9:21

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.