Blank lines in tabular environment

I have a problem. I am making a table in the tabular environment; it has multirows and multicolumns and cell colours and all the usual haberdashery.

However, there are lines missing in the table (e.g. at the edges of particular cells) and I can't seem to fix them.

Here is my MWE:

\documentclass[12pt,letterpaper,twoside,openright]{book}
\usepackage[margin=1.0in]{geometry}

\usepackage{multirow}
\usepackage{booktabs}

\usepackage{hhline}

\usepackage[table]{xcolor}
\usepackage{rotating}
\usepackage[para]{threeparttable}

\usepackage[font=footnotesize,labelfont=bf]{caption}
\usepackage{color, colortbl}

\begin{document}

\begin{table}
\centering
\captionsetup{font=large}
\caption{caption}
\begin{threeparttable}
\begin{tabular}{|c|c|c|c|c|c|}
\hline
\parbox[t]{2mm}{\multirow{6}{*}{\rotatebox[origin=c]{90}{Response 2}}}
& Not tested & 0 & 0 & 0 & 2 \\ \hhline{~|-|-|-|-|-|}
& Nil & 1 & 1 & 0 & 0 \\ \hhline{~|-|-|-|-|-|}
& Inhibited & \cellcolor{green!25}6 & \cellcolor{blue!25}7$^{\dagger}$ & 2 & 1 \\ \hhline{~|-|-|-|-|-|}
& Excited & \cellcolor{red!25}20$^\ast$ & \cellcolor{yellow!25}3 & 0 & 0 \\ \hhline{~|-|-|-|-|-|}
& Total & Excited & Inhibited & Nil & Not tested \\ \hhline{~|-|-|-|-|-|}
& \multicolumn{5}{c}{Response 1} \\ \hhline{|-|-|-|-|-|-|}
\end{tabular}
\begin{tablenotes}
\footnotesize
\item[$\ast$] \textcolor{red}{footnote 1} \\
\item[$\dagger$] \textcolor{blue}{footnote 2}
\end{tablenotes}
\end{threeparttable}
\end{table}

\end{document}


As you can see the far left hand line on the table has little breaks in it, and the bottom right hand corner is not showing a border!!

Thanks,

L

• Welcome to TeX.SX! Your table will be punished by the holy table inquisition for too much lines ;-) – user31729 Aug 22 '14 at 10:47
• The missing edges on the coloured cells are a pdf viewer issue -- zoom in and you will see them (in printing they appear)...\multicolumn{5}{c|}{Response 1} will provide the missing vertical line ;-) But again, there are too much (vertical) lines inside the table. – user31729 Aug 22 '14 at 10:50

You have omitted to give pipe symbol in line no. 31 where |c| must appear so as to remove the error of unlinked bottom right corner of the table. Line no.28,29,30 must contain \hhline{|~|-|-|-|-|-|} in the last

Correct code

\documentclass[12pt,letterpaper,twoside,openright]{book}
\usepackage[margin=1.0in]{geometry}

\usepackage{multirow}
\usepackage{booktabs}

\usepackage{hhline}

\usepackage[table]{xcolor}
\usepackage{rotating}
\usepackage[para]{threeparttable}

\usepackage[font=footnotesize,labelfont=bf]{caption}
\usepackage{color, colortbl}

\begin{document}

\begin{table}
\centering
\captionsetup{font=large}
\caption{caption}
\begin{threeparttable}
\begin{tabular}{|c|c|c|c|c|c|}
\hline
\parbox[t]{2mm}{\multirow{6}{*}{\rotatebox[origin=|c]{90}{Response 2}}}
& Not tested & 0 & 0 & 0 & 2 \\ \hhline{~-|-|-|-|-|}
& Nil & 1 & 1 & 0 & 0 \\ \hhline{~-|-|-|-|-|}
& Inhibited & \cellcolor{green!25}6 & \cellcolor{blue!25}7$^{\dagger}$ & 2 & 1 \\ \hhline{|~|-|-|-|-|-|}
& Excited & \cellcolor{red!25}20$^\ast$ & \cellcolor{yellow!25}3 & 0 & 0 \\ \hhline{|~|-|-|-|-|-|}
& Total & Excited & Inhibited & Nil & Not tested \\ \hhline{|~|-|-|-|-|-|}
& \multicolumn{5}{|c|}{Response 1} \\ \hhline{-|-|-|-|-|-|}
\end{tabular}
\begin{tablenotes}
\footnotesize
\item[$\ast$] \textcolor{red}{footnote 1} \\
\item[$\dagger$] \textcolor{blue}{footnote 2}
\end{tablenotes}
\end{threeparttable}
\end{table}

\end{document}

• \multicolumn{5}{|c|} adds a most probably unwanted doubled vertical line at the beginning of the 2nd column then – user31729 Aug 22 '14 at 11:33
• pipe in front of |c| could be removed. \multicolumn{5}{c|} will solve your problem. The vertical line at the beginning of the second column is covered already. – murugan Aug 22 '14 at 11:42

The little breaks in the left-hand vertical line disappears with a coorect use of \hhline. The missing vertical line problem is solved as said @Christian Hupfer. I also simplified a little your code: it's useless to load color if you load xcolor, and I don't see why you wrap your multirow in a \parbox.

\documentclass[12pt,letterpaper,twoside,openright]{book}
\usepackage[margin=1.0in]{geometry}
\usepackage{hhline}

\usepackage{multirow}
\usepackage{booktabs}

\usepackage[table]{xcolor}
\usepackage{colortbl}
\usepackage{rotating}
\usepackage[para]{threeparttable}

\usepackage[font=footnotesize,labelfont=bf]{caption}

\usepackage{cellspace}
\setlength\cellspacetoplimit{5pt}
\setlength\cellspacebottomlimit{5pt}

\raggedbottom

\begin{document}

\begin{table}[!h]
\centering
\captionsetup{font=large}
\caption{caption}
\begin{threeparttable}
\begin{tabular}{|c|c|c|c|c|c|}
\hline
\multirow{6}{*}{\rotatebox[origin=c]{90}{Response 2}}%
& Not tested & 0 & 0 & 0 & 2 \\
\hhline{|~|-|-|-|-|-|}
& Nil & 1 & 1 & 0 & 0 \\
\hhline{|~|-|-|-|-|-|}
& Inhibited & \cellcolor{green!25}6 & \cellcolor{blue!25}7$^{\dagger}$ & 2 & 1 \\
\hhline{|~|-|-|-|-|-|}
& Excited & \cellcolor{red!25}20$^\ast$ & \cellcolor{yellow!25}3 & 0 & 0 \\
\hhline{|~|-|-|-|-|-|}
& \textbf{Total} & Excited & Inhibited & Nil & Not tested \\
\hhline{|~|-|-|-|-|-|}
& \multicolumn{5}{c|}{Response 1} \\
\hhline{|-|-|-|-|-|-|}
\end{tabular}
\begin{tablenotes}
\footnotesize
\item[$\ast$] \textcolor{red}{footnote 1} \\
\item[$\dagger$] \textcolor{blue}{footnote 2}
\end{tablenotes}
\end{threeparttable}
\end{table}

\begin{table}[!h]
\centering
\captionsetup{font=large, singlelinecheck = false, justification = raggedleft}
\begin{threeparttable}
\caption{caption}
\begin{tabular}{rSr|*{4}{c|}}
\cline{3-6}
\multirow{6}{*}{\rotatebox[origin=c]{90}{Response 2}}%
& Not tested & 0 & 0 & 0 & 2 \\
\hhline{~~|-|-|-|-|}
& Nil & 1 & 1 & 0 & 0 \\
\hhline{~~|-|-|-|-|}
& Inhibited & \cellcolor{green!25}6 & \cellcolor{blue!25}7$^{\dagger}$ & 2 & 1 \\
\hhline{~~-|-|-|-|}
& Excited & \cellcolor{red!25}20$^\ast$ & \cellcolor{yellow!25}3 & 0 & 0 \\
\hhline{~~|-|-|-|-|}
\item[$\ast$] \textcolor{red}{footnote 1} \\
\item[$\dagger$] \textcolor{blue}{footnote 2}