Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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!!

Can someone help me please?

Thanks,

L

share|improve this question
4  
Welcome to TeX.SX! Your table will be punished by the holy table inquisition for too much lines ;-) –  Christian Hupfer Aug 22 at 10:47
2  
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. –  Christian Hupfer Aug 22 at 10:50

2 Answers 2

up vote 2 down vote accepted

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}
share|improve this answer
    
\multicolumn{5}{|c|} adds a most probably unwanted doubled vertical line at the beginning of the 2nd column then –  Christian Hupfer Aug 22 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 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.

I added another way to improve your table:

\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}

\newcommand\colhead[1]{\multicolumn{1}{c}{#1}}

\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{~~|-|-|-|-|}
\addlinespace[3pt]
& \colhead{\bfseries Total} & \colhead{Excited} &\colhead{ Inhibited} & \colhead{Nil }& \colhead{Not tested} \\
\addlinespace
\multicolumn{2}{c}{} & \multicolumn{4}{c}{Response 1}
\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} 

enter image description here

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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