6

When I use a \usepackage{colortbl} a space between \hline\hline in \longtable dissapears. I haven't find any solution how to put the space back, so I hope you'll help me to find it.

\begin{longtable}{|l|l|l|l|c|r|r|r|}
        \caption{{ABD}}
        \label{tab:SO}\\
\hline
        \multicolumn{1}{|l|}{{SO} - 01} & \multicolumn{7}{ c| }{AD}\\
    \hline\hline
        \multicolumn{4}{|l|}{Popis} & MJ & AD & AD & CD\\
    \hline
        \multicolumn{4}{|l|}{AD }& $3$ & 37000 & 0,32& 11\,800   \\
    \hline
\end{longtable} 
1

2 Answers 2

10

enter image description here

colortbl loads a load of code at \begin{document} checking for longtable and ensuring compatibility. If you stop it doing that then things work better. I blame the package authors of the colortbl and longtable packages for not communicating.

\documentclass{article}
\usepackage{color}
\makeatletter
\let\xx@begindocumenthook\@begindocumenthook
\let\xxhline\hline
\let\xx@xhline\@xhline
\usepackage{colortbl}
\let\hline\xxhline
\let\@xhline\xx@xhline
\let\@begindocumenthook\xx@begindocumenthook
\makeatother
\usepackage{longtable}
\begin{document}\color{black}
\begin{longtable}{|l|l|l|l|c|r|r|r|}
        \caption{{ABD}}
        \label{tab:SO}\\
\hline
        \multicolumn{1}{|l|}{{SO} - 01} & \multicolumn{7}{ c| }{AD}\\
    \hline\hline
        \multicolumn{4}{|l|}{Popis} & M J & AD & AD & CD\\
    \hline
        \multicolumn{4}{|l|}{AD }& $3$ & 37000 & 0,32& 11\,800   \\
    \hline
\end{longtable} 
\end{document}
2
  • Haven't the authors of colortbl and longtable got a chance to talk to each other yet? :-D Jokes aside, I've run into this very issue recently, and the fix doesn't seem to work any more with TeXlive 2022.
    – campa
    Jul 14, 2022 at 19:53
  • @campa by coincidence I'm looking at colortbl after many years, looking at adopting the xcolor table extension github.com/davidcarlisle/dpctex/commits/main Jul 14, 2022 at 21:30
1

The colortbl package redefines the \LT@@hline macro just after the \begin{document}, and the first \ifx compares the macro \hline with the macro \LT@next. But the macro \hline (inside a 'longtable' environment) expands to:

\noalign{\ifnum 0=‘}\fi\penalty\@M\futurelet\@let@token\LT@@hline

So the correct is to compare the macro \hline and \@let@token.

A workaround is to prepend \let\LT@next\@let@token to definition of \LT@@hline, after the \begin{document}.

\documentclass{article}
\usepackage{colortbl,longtable}
\begin{document}
    \makeatletter
    \let\LT@@hline@bkp\LT@@hline
    \def\LT@@hline{\let\LT@next\@let@token\LT@@hline@bkp}
    \makeatother
    
    \begin{longtable}{|l|l|l|l|c|r|r|r|}
        \caption{{ABD}}
        \label{tab:SO}\\
        \hline
        \multicolumn{1}{|l|}{{SO} - 01} & \multicolumn{7}{ c| }{AD}\\
        \hline\hline
        \multicolumn{4}{|l|}{Popis} & M J & AD & AD & CD\\
        \hline
        \multicolumn{4}{|l|}{AD }& $3$ & 37000 & 0,32& 11\,800   \\
        \hline
    \end{longtable}
\end{document}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .