I have a probably quite specific LaTeX problem using tables, due to the needed specification of the table, which are (mainly):
- I need support for multiple pages
- I need a lot of multicolumns
- I need colored cells
- I need the possibility to control page breaks in the table (This means, I have blocks of rows that have to stay together [see MWE])
- I need partial table rules and want to see them ;-)
I used a specific cline version first (included in the MWE), which adds the page breaking control, but \cline is not compatible with colortbl ( Cellcolor overwrites partial horizontal lines (\cline) ). So I changed to \hhline, but now I have lost page break control, which is important.
So my main question is: Is it possible to use \hhline and have control of the page breaks at the same time?
I know it probably has to do with a penality, but I don't know how I may add it, or if it is even possible.
P.S.: I know that \hhline produces unwanted white lines, but there is a way to fix it ( \hhline adds white line where no line is intended ). I just left it out of the MWE to keep it smaller.
This is my MWE:
\documentclass[10pt,a7paper,oneside]{scrartcl}
\usepackage{longtable,tabu}
\usepackage{multirow}
\usepackage{xcolor,colortbl}
\usepackage{hhline}
% No-break cline version
\makeatletter
\def\@cline#1-#2\@nil{%
\omit
\@multicnt#1%
\advance\@multispan\m@ne
\ifnum\@multicnt=\@ne\@firstofone{&\omit}\fi
\@multicnt#2%
\advance\@multicnt-#1%
\advance\@multispan\@ne
\leaders\hrule\@height\arrayrulewidth\hfill
\cr
\noalign{\nobreak\vskip-\arrayrulewidth}}
\makeatother
% Shortcut
\newcommand{\cc}[1]{\cellcolor{#1}}
\begin{document}
\begin{longtabu} to \textwidth {|X|X|X|}
\hline
\multicolumn{3}{|l|}{\cc{yellow}Main Entry} \\*
\hhline{|~|-|-|}
% No break control :(
{\cc{yellow}} & {\cc{red}Sub} & {\cc{red}Val} \\* \hhline{|~|-|-|}
{\cc{yellow}} & {\cc{red}Sub} & {\cc{red}Val} \\* \hhline{|~|-|-|}
{\cc{yellow}} & {\cc{red}Sub} & {\cc{red}Val} \\* \hhline{|~|-|-|}
{\cc{yellow}} & {\cc{red}Sub} & {\cc{red}Val} \\* \hhline{|~|-|-|}
{\cc{yellow}} & {\cc{red}Sub} & {\cc{red}Val} \\ \hline
\multicolumn{3}{|l|}{\cc{yellow}Main Entry} \\*
\cline{2-3}
% Break control, but no rules :(
{\cc{yellow}} & {\cc{red}Sub} & {\cc{red}Val} \\* \cline{2-3}
{\cc{yellow}} & {\cc{red}Sub} & {\cc{red}Val} \\* \cline{2-3}
{\cc{yellow}} & {\cc{red}Sub} & {\cc{red}Val} \\* \cline{2-3}
{\cc{yellow}} & {\cc{red}Sub} & {\cc{red}Val} \\* \cline{2-3}
{\cc{yellow}} & {\cc{red}Sub} & {\cc{red}Val} \\ \hline
\multicolumn{3}{|l|}{\cc{yellow}Main Entry} \\*
\cline{2-3}
{\cc{yellow}} & {\cc{red}Sub} & {\cc{red}Val} \\* \cline{2-3}
{\cc{yellow}} & {\cc{red}Sub} & {\cc{red}Val} \\* \cline{2-3}
{\cc{yellow}} & {\cc{red}Sub} & {\cc{red}Val} \\* \cline{2-3}
{\cc{yellow}} & {\cc{red}Sub} & {\cc{red}Val} \\* \cline{2-3}
{\cc{yellow}} & {\cc{red}Sub} & {\cc{red}Val} \\ \hline
& & \kill % Needed for correct table calculation
\end{longtabu}
\end{document}