[Tex/LaTex] Space between \hline\hline in `longtable`

longtablespacingtables

I'm trying to use one longtable in my thesis while all others are created with table and tabular environment.
I tried to find help visiting this link. But there only one type of table (longtable) is used.

The first lines (between %and %) in my preamble are copied from the link above. If I don't use them the code works but at the same time there's no space between the \hline\hline anymore. If I only use the longtable or put the longtable first, the code can be compiled.
But the order represented in this extract represents the order in my thesis.

If I don't use the colortbl respectively xcolor with the option table it works fine. But I don't know how I can color my rows without using this package. But I need the space between the two lines to separate different categories.

Thanks for your help.

\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}
%
\usepackage[table]{xcolor}
%
\usepackage{subcaption}
%
\usepackage{tabularx}
\usepackage{multirow}
\usepackage{multicol}
\usepackage{listings,color}
%
\begin{document}\color{black}
%
\begin{table}[H]
\centering
\begin{tabular}{|l|r|r|}
\hline
\rowcolor{lightgray}
\textbf{Component} & \multicolumn{1}{c|}{\textbf{Flight segment [\%]}} & \multicolumn{1}{c|}{\textbf{Passenger segment [\%]}} \\ \hline
1 & 20 & 80 \\ \hline \hline
2 & 10 & 90 \\ \hline
\end{tabular}
\caption{Caption 2}
\end{table}
%
\begin{center}
\begin{longtable}{|p{5cm}|c|p{4cm}|}
\hline
\rowcolor{lightgray}
\textbf{Mass component} & \multicolumn{1}{c|}{\textbf{Techfactor}} & \multicolumn{1}{c|}{\textbf{Reason}} \\ \hline
A lot of text & a lot of text & a lot of text \\ \hline
A lot of text & a lot of text & a lot of text \\ \hline
A lot of text & a lot of text & a lot of text \\ \hline \hline
A lot of text & a lot of text & a lot of text \\ \hline
A lot of text & a lot of text & a lot of text \\ \hline \hline
A lot of text & a lot of text & a lot of text \\ \hline
\caption{Caption 1}
\end{longtable}
\end{center}
%
Text text text.
%

% 
\end{document}

Best Answer

  • If the problem is only drawing \hline\hline in a long table, then a simple solution would be hhline{===} (in the case of the table with three columns) from package hhline
  • off topic:
    • It is sufficient to load xcolor paclage exclusively, which is supersede of color package and its option table calls colortbl;
    • Long table is default centered, so encapulating it in \begin{center} ... \end{center} is superfluous;
    • Captions, especially in the case of long tables, should be on the top of them, not at the bottom;

enter image description here

\documentclass{article}

\usepackage{longtable, makecell, multirow, tabularx}
\renewcommand\theadfont{\normalsize\bfseries}
\usepackage{hhline}
%
\usepackage[table]{xcolor}
%
\usepackage{subcaption}
%
\usepackage{multicol}
\usepackage{listings}
%
\begin{document}
%
\begin{longtable}{|p{5cm}|c|p{4cm}|}
    \caption{Caption 1}                       \\
   \hline
\rowcolor{lightgray}
\thead{Mass component}  & \thead{Techfactor} &  \thead{Reason}  \\
    \hline
A lot of text & a lot of text & a lot of text \\ \hline
A lot of text & a lot of text & a lot of text \\ \hline
A lot of text & a lot of text & a lot of text \\
    \hhline{===}
A lot of text & a lot of text & a lot of text \\ \hline
A lot of text & a lot of text & a lot of text \\
    \hhline{===}
A lot of text & a lot of text & a lot of text \\ \hline
\end{longtable}
%
Text text text.
%
\end{document}