1

I have the following script using IEEE conference template from: https://www.ctan.org/tex-archive/macros/latex/contrib/IEEEtran/?lang=en

I find formatting this table tricky. The problems are:

1) The most left column is not right. I need the black horizontal lines to start from the beginning of the row (see some space in the left of each row) and I need one space before starting the text of the row (need it to look similar to the most right column).

2) Column A must be underlined like column B and C. But, the line is not well placed. It should end before the vertical line.

Here is the script:

\documentclass[compsoc, conference, letterpaper, 10pt, times]{IEEEtran}
\ifCLASSOPTIONcompsoc
  % IEEE Computer Society needs nocompress option
  % requires cite.sty v4.0 or later (November 2003)
  \usepackage[nocompress]{cite}
\else
  % normal IEEE
  \usepackage{cite}
\fi
\ifCLASSINFOpdf
\else
\fi
\usepackage{graphicx}

\usepackage{colortbl}

\usepackage{array}
\usepackage{booktabs}
\usepackage{multirow}
\newcommand{\head}[1]{\textnormal{\textbf{#1}}}
\newcommand{\normal}[1]{\multicolumn{1}{l}{#1}}
\usepackage{amssymb}% http://ctan.org/pkg/amssymb
\usepackage{pifont}% http://ctan.org/pkg/pifont
\newcommand{\cmark}{\ding{51}}%
\newcommand{\xmark}{\ding{55}}%
\newcommand*\rot{\rotatebox{90}}
\usepackage{tabularx}

\begin{document}
\title{Test Document}

% make the title area
\maketitle

\section{Introduction}
This is an introduction.

\begin{table*}[tb!] 
\caption{A Table}

\centering
\resizebox{\textwidth}{!} {
\begin{tabular} {@{} lc*{16}l @{}}
\hline
\multicolumn{1}{c}{A} 
&&\multicolumn{3}{c}{B}    
&&\multicolumn{3}{c}{C}  
&&\multicolumn{3}{c}{D}  
&&\multicolumn{2}{c}{E}  

\\
\cmidrule(lr){0-1} 
\cmidrule(lr){3-5} 
\cmidrule(lr){7-9}
\cmidrule(lr){11-13}
\cmidrule(lr){15-16}
\\
& \vline &\rot{Col. 1} & \rot{Col. 2} & \rot{Col. 3} 
& \vline & \rot{Col. 1} & \rot{Col. 2} & \rot{Col. 3} 
& \vline & \rot{Col. 1} & \rot{Col. 2} &\rot{Col. 3} 
& \vline & \rot{Col. 1} & \rot{Col. 2} 

\\ \hline
\rowcolor[gray]{.9} 
Text1 &\vline  & \cmark & {}     & {}     & \vline  & {}     & \cmark  & {}      & \vline  & {} &\cmark  & & \vline &    & \cmark \\\hline
Text2 &\vline  & {}     & \cmark & {}     & \vline  & {}     & \cmark   & {}      & \vline & {} & \cmark & & \vline & {} & \cmark   \\\hline
\rowcolor[gray]{.9}
Text3 & \vline & \cmark & {}     & {}     & \vline  & {}     & \cmark   & {}      & \vline & {} &\cmark  & &\vline & {} & \cmark    \\
\hline
Text4 & \vline & \cmark & {}    & {}     & \vline   & {}     & \cmark   & {}      & \vline & {} &\cmark  & &\vline & {} & \cmark   \\
 \hline
\rowcolor[gray]{.9} 
Text5 & \vline & {}     & \cmark & {}    & \vline   & \cmark  & {}      & {}      & \vline & \cmark & {} & &\vline & {} & \cmark    \\
\hline
Text6 & \vline & \cmark & {}    & {}     & \vline   & \cmark  & {}      & {}      & \vline & {}     & \cmark & & \vline & {} & \cmark   \\
\hline
\rowcolor[gray]{.9}
Text7 & \vline & \cmark & {}    & {}     & \vline   & \cmark  & {}      & {}       & \vline & \cmark & {}    & & \vline & \cmark & {}  \\
\hline
Text8 & \vline & \cmark & {}   & {}     & \vline    & {}     & \cmark   & {}      & \vline  & {}     &\cmark & & \vline & {} & \cmark  \\
\hline
\rowcolor[gray]{.9}
Text9 & \vline & {}     & {}     & \cmark & \vline & \cmark  & \cmark  & {}       & \vline  & {}     &\cmark & & \vline & {} & \cmark \\\hline
Text10 & \vline & {}     & {}     & \cmark & \vline & {}      & {}      & \cmark   & \vline  & {}     &\cmark & &\vline & {} & \cmark   \\
\hline
\end{tabular}
}
\end{table*}
\end{document}

enter image description here

closed as unclear what you're asking by Zarko, ChrisS, Stefan Pinnow, TeXnician, Henri Menke Jul 9 '17 at 9:00

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

1

Your problem is caused by using @{} in tabular column definition. work around is explained in documentation of colortbl package, so it has nothing with used document class.

Edit: In case, that you will consider to use tabularx instead of tabular, the solution of your problem is:

  • reduce number of columns to number of columns with content (12)
  • change column definition to (with out vertical lines)

\begin{tabularx}{\linewidth}{@{}>{\columncolor{white}[0pt][\tabcolsep]}l
                                                                 *{10}{C}
                                >{\columncolor{white}[\tabcolsep][0pt]}C
                            @{}}

or (with vertical lines)

\begin{tabularx}{\linewidth}{@{}>{\columncolor{white}[0pt][\tabcolsep]}l  |
                                                                  *{3}{CCC|}
                                                                       C 
                                >{\columncolor{white}[\tabcolsep][0pt]}C
                            @{}}

Off-topic: I took liberty in change your table so, that it can fit in column width. For this I use tabularx table environment, reduce font size to \small, remove vertical lines and for horizontal lines use rules from booktabs (to obtain more professional look of table):

enter image description here

As you can see, this table hasn't your problems. Maybe you liked it :). The MWE is:

\documentclass[twocolumn]{article}
\usepackage{amssymb}% http://ctan.org/pkg/amssymb
\usepackage{pifont}% http://ctan.org/pkg/pifont
\newcommand{\cmark}{\ding{51}}%
\newcommand{\xmark}{\ding{55}}%

\usepackage[table]{xcolor}% instead of colortbl
\usepackage{booktabs, makecell, multirow, tabularx}
\usepackage{rotating}% added
\newcolumntype{C}{>{\centering\arraybackslash}X}

%-------------------------------------- only for show page layout
\usepackage{showframe}
\renewcommand\ShowFrameLinethickness{0.15pt}
\renewcommand*\ShowFrameColor{\color{red}}
%---------------------------------------------------------------%
\usepackage{lipsum}
\begin{document}
\lipsum[1]
    \begin{table}[ht]
\caption{A Table}
    \centering
\setlength\tabcolsep{3pt}
    \settowidth\rotheadsize{Col. 3}
\begin{tabularx}{\linewidth}{@{}>{\columncolor{white}[0pt][\tabcolsep]}l
                                                                 *{10}{C} 
                                >{\columncolor{white}[\tabcolsep][0pt]}C
                            @{}}
    \toprule
\multicolumn{1}{c}{A}       
        &   \multicolumn{3}{c}{B}   
            &   \multicolumn{3}{c}{C}
                &   \multicolumn{3}{c}{D}
                    &   \multicolumn{2}{c}{E}           \\
\cmidrule(lr){1-1}
\cmidrule(lr){2-4}\cmidrule(lr){5-7}\cmidrule(lr){8-10}
\cmidrule(lr){11-12}
        & \rothead{Col. 1} & \rothead{Col. 2} & \rothead{Col. 3}
        & \rothead{Col. 1} & \rothead{Col. 2} & \rothead{Col. 3}
        & \rothead{Col. 1} & \rothead{Col. 2} & \rothead{Col. 3}
        & \rothead{Col. 1} & \rothead{Col. 2}                   \\ 
    \hline
\rowcolor[gray]{.9}
Text1   & \cmark        &               & 
        &               & \cmark        & 
        &               & \cmark        &
        &               & \cmark                        \\
Text2   &               & \cmark        & 
        &               & \cmark        & 
        & \cmark        &               & \cmark        \\
\rowcolor[gray]{.9}
Text3   & \cmark        &               &
        &               & \cmark        &  
        &               & \cmark        &
        &               & \cmark                        \\
Text4   & \cmark        &               & 
        &               & \cmark        & 
        &               & \cmark        & 
        &               & \cmark                        \\
\rowcolor[gray]{.9}
Text5   &               & \cmark        &
        & \cmark        &               & 
        & \cmark        &               &
        &               & \cmark                        \\
\hline
Text6   & \cmark        &               & 
        & \cmark        &               &
        &               & \cmark        & 
        &               & \cmark                        \\
\rowcolor[gray]{.9}
Text7   & \cmark        &               & 
        & \cmark        &               & 
        & \cmark        &               & 
        & \cmark        &                               \\
Text8   & \cmark        &               & 
        &               & \cmark        & 
        &               & \cmark        & 
        &               & \cmark                        \\
\rowcolor[gray]{.9}
Text9   &               &               & \cmark 
        & \cmark        & \cmark        &
        &               & \cmark        & 
        &               & \cmark                        \\
Text10  &               &               & \cmark 
        &               &               & \cmark   
        &               & \cmark        & 
        &               & \cmark                        \\
    \bottomrule
\end{tabularx}
\end{table}
\lipsum
\end{document}

Above MWe should work also with IEEEtran document class (which now I haven't installed).

If you persist to have table over two columns and with vertical lines, than replace in above MWE consider instead existing the following lines:

...
    \begin{table*}
\caption{A Table}
    \centering
\setlength\tabcolsep{3pt}
    \settowidth\rotheadsize{Col. 3}
    \begin{tabularx}{\linewidth}{@{}>{\columncolor{white}[0pt][\tabcolsep]}l  |
                                                                      *{3}{CCC|}
                                                                           C
                                    >{\columncolor{white}[\tabcolsep][0pt]}C
                                @{}}
    \toprule
\multicolumn{1}{c}{A}       
        &   \multicolumn{3}{c}{B}   
            &   \multicolumn{3}{c}{C}
                &   \multicolumn{3}{c}{D}
                    &   \multicolumn{2}{c}{E}           \\
\cmidrule(lr){1-1}
\cmidrule(lr){2-4}\cmidrule(lr){5-7}\cmidrule(lr){8-10}
\cmidrule(lr){11-12}
        & {Col. 1} & {Col. 2} & {Col. 3}
        & {Col. 1} & {Col. 2} & {Col. 3}
        & {Col. 1} & {Col. 2} & {Col. 3}
        & {Col. 1} & {Col. 2}                   \\ 
    \hline
    ...

and you will obtain:

enter image description here

Edid (2): and with all vertical lines as in code in your question and with vertical column heads:

enter image description here

complete MWE for the last image is:

\documentclass[twocolumn]{article}
\usepackage{amssymb}% http://ctan.org/pkg/amssymb
\usepackage{pifont}% http://ctan.org/pkg/pifont
\newcommand{\cmark}{\ding{51}}%
\newcommand{\xmark}{\ding{55}}%

\usepackage[table]{xcolor}% instead of colortbl
\usepackage{booktabs, makecell, multirow, tabularx}
\usepackage{rotating}% added
\newcolumntype{C}{>{\centering\arraybackslash}X}
%-------------------------------------- only for show page layout
\usepackage{showframe}
\renewcommand\ShowFrameLinethickness{0.15pt}
\renewcommand*\ShowFrameColor{\color{red}}
%---------------------------------------------------------------%
\usepackage{lipsum}
\begin{document}
\lipsum[1]
    \begin{table*}
\caption{A Table}
    \centering
\setlength\tabcolsep{3pt}
    \settowidth\rotheadsize{Col. 3}
    \begin{tabularx}{\linewidth}{@{}>{\columncolor{white}[0pt][\tabcolsep]}l|
                                                                      *{3}{CCC|}
                                                                           C
                                    >{\columncolor{white}[\tabcolsep][0pt]}C
                                @{}}
    \toprule
\multicolumn{1}{c}{A}       
        &   \multicolumn{3}{c}{B}   
            &   \multicolumn{3}{c}{C}
                &   \multicolumn{3}{c}{D}
                    &   \multicolumn{2}{c}{E}           \\
\cmidrule(lr){1-1}
\cmidrule(lr){2-4}\cmidrule(lr){5-7}\cmidrule(lr){8-10}
\cmidrule(lr){11-12}
        & \rothead{Col. 1} & \rothead{Col. 2} & \rothead{Col. 3}
        & \rothead{Col. 1} & \rothead{Col. 2} & \rothead{Col. 3}
        & \rothead{Col. 1} & \rothead{Col. 2} & \rothead{Col. 3}
        & \rothead{Col. 1} & \rothead{Col. 2}                   \\ 
    \hline
\rowcolor[gray]{.9}
Text1   & \cmark        &               & 
        &               & \cmark        & 
        &               & \cmark        &
        &               & \cmark                        \\
Text2   &               & \cmark        & 
        &               & \cmark        & 
        & \cmark        &               & \cmark        \\
\rowcolor[gray]{.9}
Text3   & \cmark        &               &
        &               & \cmark        &  
        &               & \cmark        &
        &               & \cmark                        \\
Text4   & \cmark        &               & 
        &               & \cmark        & 
        &               & \cmark        & 
        &               & \cmark                        \\
\rowcolor[gray]{.9}
Text5   &               & \cmark        &
        & \cmark        &               & 
        & \cmark        &               &
        &               & \cmark                        \\
Text6   & \cmark        &               & 
        & \cmark        &               &
        &               & \cmark        & 
        &               & \cmark                        \\
\rowcolor[gray]{.9}
Text7   & \cmark        &               & 
        & \cmark        &               & 
        & \cmark        &               & 
        & \cmark        &                               \\
Text8   & \cmark        &               & 
        &               & \cmark        & 
        &               & \cmark        & 
        &               & \cmark                        \\
\rowcolor[gray]{.9}
Text9   &               &               & \cmark 
        & \cmark        & \cmark        &
        &               & \cmark        & 
        &               & \cmark                        \\
Text10  &               &               & \cmark 
        &               &               & \cmark   
        &               & \cmark        & 
        &               & \cmark                        \\
    \bottomrule
\end{tabularx}
\end{table*}
\lipsum
\end{document}

Edit (3): And for fun and completeness off-topic sugestions one more solution without (black) vertical lines, without rotating column headers and all columns have equal width:

enter image description here

\documentclass[twocolumn]{article}
\usepackage{amssymb}
\usepackage{pifont}
\newcommand{\cmark}{\ding{51}}%

\usepackage[table]{xcolor}% instead of colortbl
\usepackage{booktabs, tabularx}
\usepackage[skip=1ex]{caption}
\newcolumntype{C}{>{\centering\arraybackslash}X}

\usepackage{lipsum}
\begin{document}
\lipsum[1]
    \begin{table*}
\caption{A Table}
    \centering
\setlength\tabcolsep{3pt}
    \begin{tabularx}{\linewidth}{@{}>{\columncolor{white}[0pt][\tabcolsep]}X   @{\quad}
                                                                      *{3}{CCC @{\quad}}
                                                                           C
                                    >{\columncolor{white}[\tabcolsep][0pt]}C
                                @{}}
    \toprule
\multicolumn{1}{c}{A}
        &   \multicolumn{3}{c}{B}
            &   \multicolumn{3}{c}{C}
                &   \multicolumn{3}{c}{D}
                    &   \multicolumn{2}{c}{E}           \\
\cmidrule(r){1-1}
\cmidrule(r){2-4}\cmidrule(r){5-7}\cmidrule(r){8-10}
\cmidrule{11-12}
        & {Col. 1} & {Col. 2} & {Col. 3}
        & {Col. 1} & {Col. 2} & {Col. 3}
        & {Col. 1} & {Col. 2} & {Col. 3}
        & {Col. 1} & {Col. 2}                   \\
    \hline
\rowcolor[gray]{.9}
Text1   & \cmark        &               &
        &               & \cmark        &
        &               & \cmark        &
        &               & \cmark                        \\
Text2   &               & \cmark        &
        &               & \cmark        &
        & \cmark        &               & \cmark        \\
\rowcolor[gray]{.9}
Text3   & \cmark        &               &
        &               & \cmark        &
        &               & \cmark        &
        &               & \cmark                        \\
Text4   & \cmark        &               &
        &               & \cmark        &
        &               & \cmark        &
        &               & \cmark                        \\
\rowcolor[gray]{.9}
Text5   &               & \cmark        &
        & \cmark        &               &
        & \cmark        &               &
        &               & \cmark                        \\
Text6   & \cmark        &               &
        & \cmark        &               &
        &               & \cmark        &
        &               & \cmark                        \\
\rowcolor[gray]{.9}
Text7   & \cmark        &               &
        & \cmark        &               &
        & \cmark        &               &
        & \cmark        &                               \\
Text8   & \cmark        &               &
        &               & \cmark        &
        &               & \cmark        &
        &               & \cmark                        \\
\rowcolor[gray]{.9}
Text9   &               &               & \cmark
        & \cmark        & \cmark        &
        &               & \cmark        &
        &               & \cmark                        \\
Text10  &               &               & \cmark
        &               &               & \cmark
        &               & \cmark        &
        &               & \cmark                        \\
    \bottomrule
\end{tabularx}
\end{table*}
\lipsum
\end{document}

All above off-topic suggestions consider your wish to color rows. I personally will not color rows. For help reader to track rows I would eventually add some vertical space after each forth rows in try to fit table into one column. However, different people, different taste, ...

  • @user6875880, see edited answer. – Zarko Jul 8 '17 at 20:52
  • And what is benefit, that it is vertical when it can be horizontal? To make it vertical again: just return \rothead. Added in again (this time last) edited answer – Zarko Jul 8 '17 at 21:37
  • @user6875880, and what then? Are you not capable add yourself? At least this can be exercise for you, isn't it? – Zarko Jul 8 '17 at 22:12
  • @user6875880 Your comments sound like "make it all for me" instead of "tell me how I can make it". Please be aware that we mostly prefer the last. – Schweinebacke Jul 9 '17 at 7:03
  • @Zarko Sorry for that. I just thought the answer should be for what the question exactly asked so I can accept it and it becomes reference for others. – user6875880 Jul 9 '17 at 10:03
2

I propose to use tabularx and no \resizebox. The vertical rules are put as separators between columns, so I have only 12 columns. Also, I took the liberty to change the look of the rotated column heads,: a rotation of 40°, so their height is smaller:

\documentclass[compsoc, conference, letterpaper, 10pt, times]{IEEEtran}
\ifCLASSOPTIONcompsoc
  % IEEE Computer Society needs nocompress option
  % requires cite.sty v4.0 or later (November 2003)
  \usepackage[nocompress]{cite}
\else
  % normal IEEE
  \usepackage{cite}
\fi
\ifCLASSINFOpdf
\else
\fi

\usepackage{graphicx}

\usepackage[table, svgnames]{xcolor}

\usepackage{array}
\usepackage{booktabs}
\usepackage{multirow}
\newcommand{\head}[1]{\textnormal{\textbf{#1}}}
\newcommand{\normal}[1]{\multicolumn{1}{l}{#1}}
\usepackage{amssymb}% http://ctan.org/pkg/amssymb
\usepackage{pifont}% http://ctan.org/pkg/pifont
\newcommand{\cmark}{\ding{51}}%
\newcommand{\xmark}{\ding{55}}%
\newcommand*\rot[1][90]{\rotatebox{90}}
\newcommand*\myrot[1]{\rotatebox[origin=l]{40}{#1}}
\usepackage{tabularx}
\newcolumntype{C}{ >{\centering\arraybackslash}X}

\begin{document}
\title{Test Document}

% make the title area
\maketitle

\section{Introduction}
This is an introduction.


\begin{table*}[!htb]
  \setlength\extrarowheight{2pt}\centering
  \caption{A Table}
  \begin{tabularx}{0.8\textwidth} { l|*{3}{CCC|}*{2}{C}|@{}}
    \hline
    \multicolumn{1}{c}{A}
           & \multicolumn{3}{c}{B}
           & \multicolumn{3}{c}{C}
           & \multicolumn{3}{c}{D}
           & \multicolumn{2}{c}{E}
    \\
    \cmidrule(lr){1-1}
    \cmidrule(lr){2-4}
    \cmidrule(lr){5-7}
    \cmidrule(lr){8-10}
    \cmidrule(lr){11-12}
           & \myrot{Col. 1} & \myrot{Col. 2} & \myrot{Col. 3}
           & \myrot{Col. 1} & \myrot{Col. 2} & \myrot{Col. 3}
           & \myrot{Col. 1} & \myrot{Col. 2} & \myrot{Col. 3}
           & \myrot{Col. 1} & \myrot{Col. 2}
    \\ \hline
    \rowcolor[gray]{.9}Text1
           & \cmark & & & & \cmark & & & \cmark & & & \cmark \\\hline
    Text2 & & \cmark & & & \cmark & & & \cmark & & & \cmark \\\hline
    \rowcolor[gray]{.9}
    Text3 & \cmark & & & & \cmark & & & \cmark & & & \cmark \\
    \hline
    Text4 & \cmark & & & & \cmark & & & \cmark & & & \cmark \\
    \hline
    \rowcolor[gray]{.9}
    Text5 & {} & \cmark & & \cmark & & & \cmark & & & & \cmark \\
    \hline
    Text6 & \cmark & & & \cmark & & & & \cmark & & & \cmark \\
    \hline
    \rowcolor[gray]{.9}
    Text7 & \cmark & & & \cmark & & & \cmark & & & \cmark & \\
    \hline
    Text8 & \cmark & & & & \cmark & & & \cmark & & & \cmark \\
    \hline
    \rowcolor[gray]{.9}
    Text9 & & & \cmark & \cmark & \cmark & & & \cmark & & & \cmark \\
    \hline
    Text10 & & \cmark & & & & \cmark & & \cmark & & & \cmark \\
    \hline
  \end{tabularx}
\end{table*}

\end{document}

enter image description here

If you want a rotation of 90°, replace in the table body\myrot with \rot to obtain this:

enter image description here

  • Thanks. But such columns text does not fit my need. I need it vertical as I posted. – user6875880 Jul 8 '17 at 20:20
  • @user6875880: Just replace \myrot with \rot. Please see the updated answer. – Bernard Jul 8 '17 at 20:37

Not the answer you're looking for? Browse other questions tagged or ask your own question.