4

I have the following table in LaTeX.

\documentclass{beamer}
\usepackage{multirow}
\usepackage{xcolor,colortbl}

\begin{document}

\begin{frame}
\frametitle{Time}

\begin{table}[]
{\tiny
\centering
\begin{tabular}{||l|l|l|l|l|l|l|l|l|l|l|l|l|l|l|l|l|l|}
\hline
\multicolumn{18}{|l|}{Progress} \\ \hline
\multicolumn{9}{|l|}{\multirow{2}{*}{Ta}} & \multicolumn{9}{l|}{Ses} \\ \cline{10-18} 
\multicolumn{9}{|l|}{}& H & B & A & H & B & A & H & B & A \\ \hline
\multirow{2}{*}{\begin{tabular}[c]{@{}l@{}} 14\end{tabular}} & \multicolumn{8}{l|}{884} &   &   & \cellcolor{black!15}  &   &   &   &   &   &   \\ \cline{2-18} 
& \multicolumn{8}{l|}{L} &   &   & \cellcolor{black!15} &   &   &   &   &   &   \\ \hline
\multirow{4}{*}{\begin{tabular}[c]{@{}l@{}} 15\end{tabular}}  & \multicolumn{8}{l|}{666} &   &   &   & \cellcolor{black!55}  &   &   &   &   &   \\ \cline{2-18} 
& \multicolumn{8}{l|}{650} &   &   &   & \cellcolor{black!55}  &   &   &   &   &   \\ \cline{2-18} 
& \multicolumn{8}{l|}{0X} &   &   &   & \cellcolor{black!55}  &   &   &   &   &   \\ \cline{2-18} 
& \multicolumn{8}{l|}{11} &   &   &   & \cellcolor{black!55}  &   &   &   &   &   \\ \hline
\end{tabular}}
\end{table}

\end{frame}

\end{document}

As you can see below, it produces a table but not what I want. I want to color the cells and still show the horizontal line between them. When I color two consecutive cells, they will look like a single cell.

enter image description here

enter image description here

EDIT: I added the preamble and the zoomed pdf according to the comments.

  • 2
    Could you see what happens when you zoom in? Do the lines appear? – Werner Nov 14 '15 at 23:47
  • 3
    why do many columns \multicolumn{8}{l|}{884} is that really spanning 8 columns? it looks like just one. – David Carlisle Nov 14 '15 at 23:50
  • It would help if you could post a code that is compilable, complete with \documentclass{...}, the required \usepackage's, \begin{document}, and \end{document}. Which package provides \cellcolor? – jarauh Nov 15 '15 at 3:09
  • @jarauh Thanks. I edited the code accordingly. David Carlisle In fact I don't know why there is 8, I just use tablesgenerator.com to generate the table since I don't know how to do it. – Jika Nov 15 '15 at 3:53
  • @Werner It still no line even if I zoom the pdf. – Jika Nov 15 '15 at 3:54
5

The issue you're seeing is to do with the cline command, which is detailed in Section 10 of the colortbl documentation:

If using this package you would probably better using the - rule type in a \hhline argument, rather than \cline.

So, following this guidance, we can load the hhline package and replace

\cline{2-18}

with

\hhline{*{1}{||~}*{17}{|-}}

The output is:

screenshot

For reference, you might also see \cellcolor overwrites table lines and Cellcolor overwrites partial horizontal lines (\cline)

Here's a complete MWE:

% arara: pdflatex
% !arara: indent: {overwrite: yes}
\documentclass{beamer}
\usepackage{multirow}
\usepackage{xcolor,colortbl}
\usepackage{hhline}

\begin{document}

\begin{frame}
    \frametitle{Time}

    \begin{table}[]
        {\tiny
            \centering
            \begin{tabular}{||*{18}{l|}}
                \hline
                \multicolumn{18}{|l|}{Progress} \\ \hline
                \multicolumn{9}{|l|}{\multirow{2}{*}{Ta}} & \multicolumn{9}{l|}{Ses} \\ \cline{10-18}
                \multicolumn{9}{|l|}{}& H & B & A & H & B & A & H & B & A \\ \hline
                \multirow{2}{*}{\begin{tabular}[c]{@{}l@{}} 14\end{tabular}} & \multicolumn{8}{l|}{884} &   &   & \cellcolor{black!15} &                      &   &   &   &   &   \\ \hhline{*{1}{||~}*{17}{|-}}%\cline{2-18}
                                                                             & \multicolumn{8}{l|}{L}   &   &   & \cellcolor{black!15} &                      &   &   &   &   &   \\ \hline
                \multirow{4}{*}{\begin{tabular}[c]{@{}l@{}} 15\end{tabular}} & \multicolumn{8}{l|}{666} &   &   &                      & \cellcolor{black!55} &   &   &   &   &   \\ \hhline{*{1}{||~}*{17}{|-}}%\cline{2-18}
                                                                             & \multicolumn{8}{l|}{650} &   &   &                      & \cellcolor{black!55} &   &   &   &   &   \\ \hhline{*{1}{||~}*{17}{|-}}%\cline{2-18}
                                                                             & \multicolumn{8}{l|}{0X}  &   &   &                      & \cellcolor{black!55} &   &   &   &   &   \\ \hhline{*{1}{||~}*{17}{|-}}%\cline{2-18}
                                                                             & \multicolumn{8}{l|}{11}  &   &   &                      & \cellcolor{black!55} &   &   &   &   &   \\ \hline
            \end{tabular}}
    \end{table}

\end{frame}

\end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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