1

(Edited with the minimalist reproducible code)

I am writing a 2-column paper using IEEEtrans.cls. The paper contains a table whose rows have alternating background colors. The problem is, The first line of the first column of every row is covered by a mysterious black box as the figure below:

enter image description here

I can workaround this problem by opening the PDF with Acrobat and manually remove those black boxes. But I want to solve this problem at the typesetting stage.

(Found how to solve the problem, but don't know why)

I found that arydshln package causes the problem and solved it by not using this package. But still, I have no idea why and no idea what if I should use that package someday.

The code for the table is given below:

\documentclass[journal,comsoc,9pt]{IEEEtran}
\usepackage[table,xcdraw]{xcolor}
\usepackage{arydshln} % This causes the problem
\begin{document}
\nocite{*}
\begin{table}[]
\centering
\label{tab:table-label}
\begin{tabular}{ccc}
  \hline
  \rowcolor[HTML]{EFEFEF} 
  \textbf{Column 1}                                                                                                                  & \textbf{Column 2}                                                                                                                           \\ \hline
  \rowcolor[HTML]{FFFFFF} 
  \begin{tabular}[c]{@{}c@{}}Cell\\ (1,1)\end{tabular}                 & \begin{tabular}[c]{@{}c@{}}Cell\\(1, 2)\end{tabular}                                                                         \\
  \rowcolor[HTML]{EFEFEF} 
  \begin{tabular}[c]{@{}c@{}}Cell\\(2, 1)\end{tabular}           & \begin{tabular}[c]{@{}c@{}}Cell\\(2,2)\end{tabular}                                                             
  \end{tabular}
\end{table}
\end{document}
11
  • 1
    Isn't it easier to type simple tex markup directly than type the text into a generator that generates awful, over complicated tex? Nov 12, 2017 at 10:31
  • 1
    on your note about arydashln that is why questions should always have a complete example document, the problem is in code you haven't shown. Nov 12, 2017 at 10:32
  • 4
    Since you don't use the package, it shouldn't be in your code in the first place. Without looking closer, a table generator has been mentioned. They produce code on what you said the tabular material should look like. A generator will add cells or spaces without merci. It does not have the slightest clue what the table is supposed to represent.
    – Johannes_B
    Nov 12, 2017 at 10:42
  • 1
    Probably Zarko, Bernard or Mico will provide a better table.
    – Johannes_B
    Nov 12, 2017 at 10:42
  • 2
    arydshln had to be loaded before xcolor.
    – Zarko
    Nov 12, 2017 at 11:46

1 Answer 1

2

since Johannes_B provoke me :-) ...

  • as mentioned in my comment above, arydshln had to be loaded before xcolor.

off-topic:

  • context of table is not clear, so is not clear why you nested tabular environment in cells
  • from provided code follows, that you like to have gray background of table
  • below are two possible solutions

\documentclass[journal,comsoc,9pt]{IEEEtran}
\usepackage{arydshln} % had to be before xcolor
\usepackage[table,xcdraw]{xcolor}
\newcommand\mycell[1]{\begin{tabular}[c]{@{}c@{}}#1\end{tabular}}

\begin{document}
\begin{table}[htb]
\definecolor{mygray}{HTML}{EFEFEF}
\centering
    \caption{}
\label{tab:table-label}
\begin{tabular}{*{2}{>{\columncolor{mygray}}c}}
  \hline
\textbf{Column 1}   & \textbf{Column 2} \\
    \hline
Cell                & Cell              \\
(1,1)               & (1, 2)            \\
    \hline
Cell                & Cell              \\
(2,1)               & (2, 2)            \\
    \hline
  \end{tabular}
\end{table}

\begin{table}[htb]
   \caption{}
\definecolor{mygray}{HTML}{EFEFEF}.
\centering
\label{tab:table-label}
\begin{tabular}{*{2}{>{\columncolor{mygray}}c}}
  \hline
\textbf{Column 1}       & \textbf{Column 2}     \\
    \hline
\mycell{Cell\\ (1,1)}   & \mycell{Cell\\ (1,2)} \\
    \hline
\mycell{Cell\\ (2,1)}   & \mycell{Cell\\ (2,2)} \\                                                                             \hline
  \end{tabular}
\end{table}
\end{document}

enter image description here

1
  • Thanks for the answer. What I meant to use nested tabular is to handle multiple-lined text into cells, but they are not guaranteed to have the same number of lines. So, the second solution is what I looking for.
    – Jeon
    Nov 12, 2017 at 14:06

You must log in to answer this question.

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