4

resulting table

Using the code given below, I am getting a black line over the word "Methods" due to hhline. How shall I remove this black line or make it of same color as the background color so that it is not visible?

\documentclass{article}
  \usepackage{hhline}
 \usepackage[table]{xcolor}
   \usepackage{array}
 \usepackage{hhline}
  \usepackage{multirow}
  \definecolor{babyblue}{rgb}{0.54, 0.81, 0.94}
   \definecolor{aliceblue}{rgb}{0.94, 0.97, 1.0}
    \begin{document}
    \begin{table}[]
    \centering
    \setlength\arrayrulewidth{1.3pt}
        \footnotesize\setlength{\tabcolsep}{2.7 pt}
    \renewcommand{\arraystretch}{1.4}
    \begin{tabular}{|c|c|c|c|c|c|c|}
        \hline
        \cellcolor{aliceblue}  & \multicolumn{2}{c|}{\cellcolor{babyblue}ISE} & \multicolumn{2}{c|}{\cellcolor{babyblue}IAE} & \multicolumn{2}{c|}{\cellcolor{babyblue}ITAE} \\ \hhline{-|-|-|-|-|-|-|} \cline{2-7} 
            \multirow{-2}{*}{\cellcolor{aliceblue} Methods}
        & \cellcolor{aliceblue}-20\%       & \cellcolor{aliceblue}+20\%     & \cellcolor{aliceblue}-20\%       & \cellcolor{aliceblue}+20\%      & \cellcolor{aliceblue}-20\%       & \cellcolor{aliceblue}+20\%       \\ \hhline{-|*6-}
        \rowcolor{babyblue}ABC                                                           & 0.5645      & 0.63     & 1.8       & 1.8      & 6.1       & 6.6       \\ \hhline{-|*6-}
        \rowcolor{aliceblue}XYZ                                                            & 2.1       & 2.3      & 0.881       & 9.82      & 9.2       & 28.9       \\ \hhline{-|*6-}
        \rowcolor{babyblue}MNO                                                                & 0.68      & 0.97     & 1.62       & 1.61      & 8.9       & 8.2       \\ \hhline{-|*6-}
        \rowcolor{aliceblue} PQR                                                                 & 0.65       & 0.753     & 2.064       & 2.231      & 28.04       & 28.56       \\ \hhline{-|*6-}
    \end{tabular}
    \end{table}
   \end{document}
ShJ
  • 891
  • 1
    your question is closely related to https://tex.stackexchange.com/questions/65231/cellcolor-overwrites-partial-horizontal-lines-cline, actually, it is duplicate to it. – Zarko Feb 28 '19 at 22:10

4 Answers4

5

You need to change your used command \hhline{-|-|-|-|-|-|-|} to \hhline{|~|-|-|-|-|-|-|} (see the ~ at the first position marking there should be no line).

So the following MWE

\documentclass{article}

\usepackage{hhline}
\usepackage[table]{xcolor}
\usepackage{array}
\usepackage{multirow}

\definecolor{babyblue}{rgb}{0.54, 0.81, 0.94}
\definecolor{aliceblue}{rgb}{0.94, 0.97, 1.0}


\begin{document}

\begin{table}[]
  \centering
  \setlength\arrayrulewidth{1.3pt}
  \footnotesize\setlength{\tabcolsep}{2.7 pt}
  \renewcommand{\arraystretch}{1.4}
  \begin{tabular}{|c|c|c|c|c|c|c|}
    \hline
    \cellcolor{aliceblue}  & \multicolumn{2}{c|}{\cellcolor{babyblue}ISE} & \multicolumn{2}{c|}{\cellcolor{babyblue}IAE} & \multicolumn{2}{c|}{\cellcolor{babyblue}ITAE} \\ 
   \hhline{|~|-|-|-|-|-|-|} % <==========================================
    \multirow{-2}{*}{\cellcolor{aliceblue}Methods}
        & \cellcolor{aliceblue}-20\%       & \cellcolor{aliceblue}+20\%     & \cellcolor{aliceblue}-20\%        & \cellcolor{aliceblue}+20\%      & \cellcolor{aliceblue}-20\%       & \cellcolor{aliceblue}+20\%        \\ \hhline{-|*6-}
    \rowcolor{babyblue}ABC                                                           & 0.5645      & 0.63     & 1.8       & 1.8      & 6.1       & 6.6       \\ \hhline{-|*6-}
    \rowcolor{aliceblue}XYZ                                                            & 2.1       & 2.3      & 0.881       & 9.82      & 9.2       & 28.9       \\ \hhline{-|*6-}
    \rowcolor{babyblue}MNO                                                                & 0.68      & 0.97     & 1.62       & 1.61      & 8.9       & 8.2       \\ \hhline{-|*6-}
    \rowcolor{aliceblue} PQR                                                                 & 0.65       & 0.753     & 2.064       & 2.231      & 28.04       & 28.56       \\ \hhline{-|*6-}
  \end{tabular}
\end{table}
\end{document}

results in the following table:

enter image description here

Because you do not want to get rid of the lines I deleted the second table.

To get rid of the underlaying white line under text "Method" you need to change the command \hhline{|~|-|-|-|-|-|-|} to

\hhline{|>{\arrayrulecolor{aliceblue}}->{\arrayrulecolor{black}}|-|-|-|-|-|-|}

Please see that this code prints the first part of line (marked with - again; ~ adds the white line!) and colored it in the same color the background has.

With the following MWE

\documentclass{article}

\usepackage{hhline}
\usepackage[table]{xcolor}
\usepackage{array}
\usepackage{multirow}
\usepackage{booktabs}

\definecolor{babyblue}{rgb}{0.54, 0.81, 0.94}
\definecolor{aliceblue}{rgb}{0.94, 0.97, 1.0}


\begin{document}

\begin{table}[ht]
  \centering
  \setlength\arrayrulewidth{1.3pt}
  \footnotesize\setlength{\tabcolsep}{2.7 pt}
  \renewcommand{\arraystretch}{1.4}
  \begin{tabular}{|c|c|c|c|c|c|c|}
    \hline
    \cellcolor{aliceblue}  & \multicolumn{2}{c|}{\cellcolor{babyblue}ISE} & \multicolumn{2}{c|}{\cellcolor{babyblue}IAE} & \multicolumn{2}{c|}{\cellcolor{babyblue}ITAE} \\ 
   \hhline{|>{\arrayrulecolor{aliceblue}}->{\arrayrulecolor{black}}|-|-|-|-|-|-|} % <==========================================
    \multirow{-2}{*}{\cellcolor{aliceblue}Methods}
        & \cellcolor{aliceblue}-20\%       & \cellcolor{aliceblue}+20\%     & \cellcolor{aliceblue}-20\%        & \cellcolor{aliceblue}+20\%      & \cellcolor{aliceblue}-20\%       & \cellcolor{aliceblue}+20\%        \\ \hhline{-|*6-}
    \rowcolor{babyblue}ABC                                                           & 0.5645      & 0.63     & 1.8       & 1.8      & 6.1       & 6.6       \\ \hhline{-|*6-}
    \rowcolor{aliceblue}XYZ                                                            & 2.1       & 2.3      & 0.881       & 9.82      & 9.2       & 28.9       \\ \hhline{-|*6-}
    \rowcolor{babyblue}MNO                                                                & 0.68      & 0.97     & 1.62       & 1.61      & 8.9       & 8.2       \\ \hhline{-|*6-}
    \rowcolor{aliceblue} PQR                                                                 & 0.65       & 0.753     & 2.064       & 2.231      & 28.04       & 28.56       \\ \hhline{-|*6-}
  \end{tabular}
\end{table}

\end{document}

you get the result:

better table

Mensch
  • 65,388
  • Horizontal and vertical lines are necessary in this case for me. Yes, that white line should be removed. Either it should be no line or line color should merge with background so that it is not visible. How to do that – ShJ Feb 28 '19 at 19:52
  • 1
    @ShiS To get the \hhline right colored (without withe line behind "Method") use command \hhline{|>{\arrayrulecolor{aliceblue}}->{\arrayrulecolor{black}}|-|-|-|-|-|-|}. See updated answer. – Mensch Feb 28 '19 at 20:24
  • 1
    +1 for answer. however, i would prefer table without colored rows, or exceptional only in table body but without vertical and horizontal lines. well people have different taste (fortunately :-) ) – Zarko Feb 28 '19 at 20:34
  • 1
    @Zarko I thought about using the color for the columns instead the vertical lines. Different taste :-) – Mensch Feb 28 '19 at 20:36
4

i would redesign your table as follows:

enter image description here

\documentclass{article}
\usepackage{siunitx}
\usepackage[table]{xcolor}
\definecolor{babyblue}{rgb}{0.54, 0.81, 0.94}
\definecolor{aliceblue}{rgb}{0.94, 0.97, 1.0}
\usepackage{booktabs, multirow}
\newcommand\mcc[1]{\multicolumn{2}{c}{#1}}

\begin{document}

\begin{table}[htb]
  \centering
  \renewcommand\arraystretch{1.2}
  \rowcolors{2}{white}{aliceblue}
  \begin{tabular}{c *{6}{S} }
    \toprule
        & \mcc{ISE} & \mcc{IAE} & \mcc{ITAE}                \\
    \cmidrule(lr){2-3}\cmidrule(lr){4-5}\cmidrule(lr){6-7}
\multirow{-2.3}{*}{Methods}
        & {$-20\%$} & {$+20\%$}
                    & {$-20\%$} & {$+20\%$}
                                & {$$-20\%$} & {$+20\%$}         \\
    \hline
ABC     & 0.5645    & 0.63  & 1.8   & 1.8   & 6.1   &  6.6  \\
XYZ     & 2.1       & 2.3   & 0.881 & 9.82  & 9.2   & 28.9  \\
MNO     & 0.68      & 0.97  & 1.62  & 1.61  & 8.9   &  8.2  \\
PQR     & 0.65      & 0.753 & 2.064 & 2.231 & 28.04 & 28.56 \\
    \bottomrule
  \end{tabular}
\end{table}
\end{document}
Zarko
  • 296,517
3

Here is a solution for the white line in the \multirow. intead of using \hhline{~|-|-|-|-|-|-|}, I use a full width \hhline , but make the first segment coloured with the background colour of the \multirow.

I also took the liberty to simplify your code, and use the AliceBlue colour from svgnames, as it doesn't seem different from your aliceblue.

\documentclass{article}

\usepackage{hhline}
\usepackage[table, svgnames]{xcolor}
\usepackage{array}
\usepackage{multirow}
\usepackage{booktabs}

\definecolor{babyblue}{rgb}{0.54, 0.81, 0.94}

\begin{document}

\begin{table}[ht]
  \centering
  \setlength\arrayrulewidth{1.3pt}
  \footnotesize\setlength{\tabcolsep}{2.7 pt}
  \renewcommand{\arraystretch}{1.4}
  \begin{tabular}{|c|c|c|c|c|c|c|}
    \hline
    \cellcolor{aliceblue} & \multicolumn{2}{c|}{\cellcolor{babyblue}ISE} & \multicolumn{2}{c|}{\cellcolor{babyblue}IAE} & \multicolumn{2}{c|}{\cellcolor{babyblue}ITAE} \\
   \hhline{|>{\arrayrulecolor{AliceBlue}}->{\arrayrulecolor{black}}|*6{-}} % <==========================================
\rowcolor{AliceBlue} \multirow{-2}{*}{Methods}
        &$ - $20\% & +20\% & $ - $20\% & +20\% & $ - $20\% & +20\% \\ \hhline{-|*6-}
    \rowcolor{babyblue}ABC & 0.5645 & 0.63 & 1.8 & 1.8 & 6.1 & 6.6 \\ \hhline{-|*6-}
    \rowcolor{AliceBlue}XYZ & 2.1 & 2.3 & 0.881 & 9.82 & 9.2 & 28.9 \\ \hhline{-|*6-}
    \rowcolor{babyblue}MNO & 0.68 & 0.97 & 1.62 & 1.61 & 8.9 & 8.2 \\ \hhline{-|*6-}
    \rowcolor{AliceBlue} PQR & 0.65 & 0.753 & 2.064 & 2.231 & 28.04 & 28.56 \\ \hhline{-|*6-}
  \end{tabular}
\end{table}

\end{document} 

enter image description here

leandriis
  • 62,593
Bernard
  • 271,350
0

It's easy to do that table with {NiceTabular} of nicematrix.

\documentclass{article}
\usepackage{xcolor}
\usepackage{nicematrix}
\definecolor{aliceblue}{rgb}{0.94, 0.97, 1.0}
\definecolor{babyblue}{rgb}{0.54, 0.81, 0.94}

\begin{document} \begin{table}[ht] \centering \setlength{\arrayrulewidth}{1.3pt} \footnotesize \setlength{\tabcolsep}{2.7 pt} \renewcommand{\arraystretch}{1.4} \begin{NiceTabular}{ccccccc}[hvlines,color-inside] \rowcolors{babyblue}{aliceblue} \Block[fill=aliceblue]{2-1}{Methods} & \Block{1-2}{ISE} && \Block{1-2}{IAE} && \Block{1-2}{ITAE} \ &$-$20% & +20% & $-$20% & +20% & $-$20% & +20% \ ABC & 0.5645 & 0.63 & 1.8 & 1.8 & 6.1 & 6.6 \ XYZ & 2.1 & 2.3 & 0.881 & 9.82 & 9.2 & 28.9 \ MNO & 0.68 & 0.97 & 1.62 & 1.61 & 8.9 & 8.2 \ PQR & 0.65 & 0.753 & 2.064 & 2.231 & 28.04 & 28.56 \ \end{NiceTabular} \end{table} \end{document}

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

Output of the above code

F. Pantigny
  • 40,250