# Table with broken horizontal line

I'm trying to make a table that looks like: So far, I have this:

\documentclass[letterpaper]{article}
\usepackage{tabu}
\usepackage[table]{xcolor}

\begin{document}
\begin{tabu} to 0.2\textwidth{XXX}
\cellcolor{blue!25} A & \cellcolor{red!25} B & \cellcolor{blue!25} C \\[-1pt]\tabucline[1pt blue]{1-1}\tabucline[1pt green]{3-3}
\cellcolor{green!25} D & \cellcolor{red!25} E & \cellcolor{green!25} F
\end{tabu}
\end{document}


However, this results in the following table: How can I move the green line up and eliminate the whitespace between the rows?

• Is mandatory use of tabu package for this table? – juanuni Jul 30 '17 at 6:04

LaTeX tabu environment is implemented using \halign TeX primitive, so \noalign primitive works. Use \noalign{\vskip-1pt} between first and second usage of \tabucline macro.

It looks like using assembler code inside C++ source code, but it works.

Maybe somebody doesn't like such mix of TeX primitives and LaTeX. The pure pdfTeX solution (without LaTeX) is here:

\def\Black{\pdfliteral{0 g 0 G}}
\def\defcolor#1#2{\def#1{\pdfliteral{#2 rg #2 RG}}}
\defcolor\lBlue  {.66 .66 1}
\defcolor\lRed   {1 .66 .66}
\defcolor\lGreen {.66 1 .66}
\defcolor\Blue   {0 0 1}
\defcolor\Green  {0 1 0}

\def\tab#1#2#3#4#5#6{\par
\hbox to\tabwidth{\rlap{\hbox to\tabwidth{#1\dorule#3\dorule#5\dorule}}%
\Black\rlap{ #2}\hfil\rlap{ #4}\hfil\rlap{ #6}\hfil}
\nointerlineskip}
\def\itab#1#2#3{\hbox to\tabwidth{#1\doruleA#2\doruleA#3\doruleA\Black}
\nointerlineskip}
\def\tabwidth{0.2\hsize}

\tab  \lBlue {A} \lRed{B} \lBlue {C}
\itab \Blue      \lRed    \Green
\tab  \lGreen{D} \lRed{E} \lGreen{F}

\bye

• Thanks! I'm currently generating these tables with a script anyways so \noalign seems to be a bit easier to use. – DoctorSelar Jul 30 '17 at 15:26
• Thank you so much! I was searching for this!!! – JenyaKh Nov 11 '19 at 20:09

I try this adding a new colored row but unfortunately I only get tabu add vertical space to rows. Then I get this non-ellegant trick without tabu package:

\documentclass[letterpaper]{article}
\usepackage[table]{xcolor}

\usepackage{colortbl}

\begin{document}
\begin{tabular}{ccc}
\cellcolor{blue!25}A & \cellcolor{red!25}B & \cellcolor{blue!25} C\\
\vspace{-3.8mm}\cellcolor{blue} & \cellcolor{red!25} & \cellcolor{green} \\
\cellcolor{green!25} D & \cellcolor{red!25}E & \cellcolor{green!25} F
\end{tabular}

\end{document}