# Creating a table with a vertically separated header row and \hhline produces horizontal line distortion

I want to create a table which marks some cells either with $\times$ or they simply stay empty. I have two header rows of which I would like to separate the first header row visually. I use \hhline{~======} to get this visual separation. I resorted to using this additinoal package because I found, that a double \hline does not seem to work correctly with \multicolumn{1}{c|}{}.

After finally having found a solution, I now get the problem, that the horizontal lines produced by \hhline are weirdly distorted:

Here's my minimal working example:

\documentclass{article}
\usepackage[utf8]{inputenc}

\usepackage{hhline}

\begin{document}

\begin{table}[h]
\centering
\begin{tabular}{|l|c|c|c|c|c|c|c|c|}
\cline{2-7}
\multicolumn{1}{c|}{}
& $T_1$    & $T_2$    & $T_3$    & $T_4$    & $T_5$    & $T_6$    \\
\hhline{~ = = = = = =}
\multicolumn{1}{c|}{}
& $r_1$    & $r_2$    & $r_3$    & $r_4$    & $r_5$    & $r_6$    \\
\hline
$t_1$ &          & $\times$ &          & $\times$ & $\times$ &          \\
\hline
$t_2$ & $\times$ &          & $\times$ &          &          &          \\
\hline
$t_3$ &          & $\times$ &          &          &          &          \\
\hline
$t_4$ & $\times$ &          &          & $\times$ & $\times$ & $\times$ \\
\hline
$t_5$ &          & $\times$ & $\times$ &          &          & $\times$ \\
\hline
$t_6$ &          &          &          & $\times$ & $\times$ & $\times$ \\
\hline
\end{tabular}
\end{table}
\end{document}



For me, it seems like an anti aliasing issue but I'm probably doing something wrong on my side. I would be glad if someone could point me to a fix or to an alternative solution that looks the same as it does now. Thank you.

• Welcome to TeX.SX! The rules here are built up by copies of smaller units. This is probably about the best you can do with this type of syntax. A different approach could be to use tikz, cf. tex.stackexchange.com/q/204358/15925 for example. The other extreme is to drop the vertical rules as suggested by the bookmarks package. Nov 10, 2021 at 16:56
• When I replace \hhline{~------} with ͵\hhline{~ :=:=:=:=:=:=:} and I measure the distance between the two horizontal lines at several points, I find exactly 2pt at each point. Maybe what you observe is just an optical effect? Or a problem with the pdf viewer? B.t.w., you should use \hhline also for the following lines, to avoid holes in the outer vertical lines. Nov 10, 2021 at 17:04

With {NiceTabular} of nicematrix, you will have a perfect output in all PDF viewers at all levels of zoom because the rules are drawn with the graphical layer PGF/Tikz (and not by concatenation of small characters).

\documentclass{article}

\usepackage{nicematrix}

\begin{document}

\begin{table}[h]
\centering
\begin{NiceTabular}{|l|c|c|c|c|c|c|}[corners]
\Hline
& $T_1$    & $T_2$    & $T_3$    & $T_4$    & $T_5$    & $T_6$    \\
\Hline
\Hline
& $r_1$    & $r_2$    & $r_3$    & $r_4$    & $r_5$    & $r_6$    \\
\Hline
$t_1$ &          & $\times$ &          & $\times$ & $\times$ &          \\
\Hline
$t_2$ & $\times$ &          & $\times$ &          &          &          \\
\Hline
$t_3$ &          & $\times$ &          &          &          &          \\
\Hline
$t_4$ & $\times$ &          &          & $\times$ & $\times$ & $\times$ \\
\Hline
$t_5$ &          & $\times$ & $\times$ &          &          & $\times$ \\
\Hline
$t_6$ &          &          &          & $\times$ & $\times$ & $\times$ \\
\Hline
\end{NiceTabular}
\end{table}
\end{document}


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

As you can see, the vertical rules are not broken by the double horizontal rule (that's by design in nicematrix).

If you prefer to have the vertical rules borken (as with the standard behaviour of the tabulars in LaTeX), it's possible but a bit more complicated:

\documentclass{article}

\usepackage{nicematrix,tikz}

\begin{document}

\begin{table}[h]
\centering
\newcolumntype{I}{!{\vrule}}
\begin{NiceTabular}{lIcIcIcIcIcIcI}[corners]
\Hline
& $T_1$    & $T_2$    & $T_3$    & $T_4$    & $T_5$    & $T_6$    \\
\Hline
\Hline
& $r_1$    & $r_2$    & $r_3$    & $r_4$    & $r_5$    & $r_6$    \\
\Hline
$t_1$ &          & $\times$ &          & $\times$ & $\times$ &          \\
\Hline
$t_2$ & $\times$ &          & $\times$ &          &          &          \\
\Hline
$t_3$ &          & $\times$ &          &          &          &          \\
\Hline
$t_4$ & $\times$ &          &          & $\times$ & $\times$ & $\times$ \\
\Hline
$t_5$ &          & $\times$ & $\times$ &          &          & $\times$ \\
\Hline
$t_6$ &          &          &          & $\times$ & $\times$ & $\times$ \\
\Hline
\CodeAfter \tikz \draw (3-|1) -- (last-|1) ;
\end{NiceTabular}
\end{table}
\end{document}