# Gap under top border of table while using \hhline

I am using the code below to generate a table. But there is some gap after the first border line. It seems the gap will disappear if I change all the \hhline to \hline or \cline in the table. I am wondering what the problem is and how to remove this gap while still using \hhline? Thanks. (PS: I have to use \hhline to avoid the borders of certain colored cells being covered by the color.)

\documentclass{article}

\usepackage{amsmath}\allowdisplaybreaks
\usepackage{amssymb}
\usepackage{mathrsfs}
\usepackage{bm}
%\usepackage{algorithm}
%\usepackage{algorithmic}
\usepackage{color}
\usepackage{url}
\usepackage{graphicx}
\usepackage{cite}
\usepackage[shortlabels]{enumitem}
\usepackage[nodisplayskipstretch]{setspace}\doublespacing
\usepackage{hyperref}
\usepackage[table]{xcolor}
\usepackage{multirow}
\usepackage{makecell}
\usepackage{tablefootnote}
\usepackage{subfigure}
\usepackage{hhline}
\usepackage[many]{tcolorbox}
\usepackage{arydshln}

\begin{document}
\begin{table}[!htbp]
\renewcommand{\arraystretch}{1.5}
\small
\centering
\begin{tabular}{|c|c|c|c|c|}
\hline
& a & b & c & d\\
\hhline{=====}
\multirow{8}{*}{\rotatebox[origin=c]{90}{YES}} & a & b & c & d\\
\hhline{~----}
& a & \cellcolor{gray!20}b & c & d\\
\hhline{~----}
& a & b & c & d\\
\Xcline{2-5}{1.5pt}
& a & b & c & d\\
\hhline{~----}
& a & b & c & d\\
\Xcline{2-5}{1.5pt}
& a & b & c & d\\
\hhline{~----}
& a & b & c & d\\
\hhline{~----}
& a & b & c & d\\
\hline
\end{tabular}\label{table:1}
\end{table}
\end{document}


UPDATE:

When I comment out the package arydshln, the gap disappears. There seems to be some conflict here. But I have to use arydshln to draw some dashed line, e.g. \cdashline{1-2}. Is there any way to resolve this? Thanks.

• please edit your example to be a complete small document that makes the image shown, I guessed \usepackage{hhline,graphicx,multirow,colortbl,xcolor} but that still leaves undefined commands so it's impossible to even start to debug Nov 6 '17 at 22:30
• I have edited to include all the packages used. It seems there is some package after adding which the gap would appear. Nov 6 '17 at 22:41
• That is so weird. I have just copied and run the code posted on my laptop. It indeed produces a gap. I am using Kile 2.1.3. Nov 6 '17 at 22:50
• I think I have found the crux. When I comment out the package arydshln, the gap disappears. But I have to use arydshln to draw some dashed line, e.g. \cdashline{1-2}. Nov 6 '17 at 22:57
• Sorry The last version does give the gap (my error) Nov 6 '17 at 22:57

Some weird interaction with arydshln here I just add some negative space to close the gap and add an invisible 0-width rule to lengthen the visible rules in the first row,

\documentclass{article}

\usepackage{color}
\usepackage{url}
\usepackage{graphicx}
\usepackage[table]{xcolor}
\usepackage{multirow}
\usepackage{makecell}

\usepackage{arydshln}
\usepackage{hhline}

\begin{document}
\begin{table}[!htbp]
\renewcommand{\arraystretch}{1.5}
\small
\centering
\begin{tabular}{|c|c|c|c|c|}
\hline\noalign{\vskip-4pt}
\rule{0pt}{14pt} & a & b & c & d\\
\hhline{=====}
\multirow{8}{*}{\rotatebox[origin=c]{90}{YES}} & a & b & c & d\\
\hhline{~----}
& a & \cellcolor{gray!20}b & c & d\\
\hhline{~----}
& a & b & c & d\\
\Xcline{2-5}{1.5pt}
& a & b & c & d\\
\hhline{~----}
& a & b & c & d\\
\Xcline{2-5}{1.5pt}
& a & b & c & d\\
\hhline{~----}
& a & b & c & d\\
\hhline{~----}
& a & b & c & d\\
\hline
\end{tabular}\label{table:1}
\end{table}
\end{document}

• Thanks for the solution. But it seems some adjustment would be needed to make a "perfect" position of the top border. Also, the border may touch the text in the table first than the vertical border, which does not look good. I guess I will just give up arydshln and try to find some alternative to \cdashline. Nov 6 '17 at 23:29