I spend some hours today trying to find a longtable implementation which does not throw warnings when there is a \hline on its top header. For example:
So far the only table I could find out which was able to not throw warnings when there is a \hline on its top, was the table presented by @Bernard as an answer on the question How to auto adjust my last table column width, and why is there Underfull \vbox badness on this table?
This bellow is modification to that table, which I think is better to understand its code as I grouped related things together:
\documentclass[10pt,a5paper,twoside]{memoir}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[brazil]{babel}
\usepackage{ragged2e}
\usepackage[showframe,pass]{geometry}
\usepackage{ltablex}
\keepXColumns
\begin{document}
\frenchspacing
\setlength\extrarowheight{2pt}
\begin{tabularx}{\linewidth}{|>{\RaggedRight}p{3cm}|>{\arraybackslash}X|}
\caption{Formatação do texto}
\label{tab:a_table_formatacao_de_texto} \\
\hline
\endfirsthead
\multicolumn{2}{c}{\tablename~\thetable: Formatação do texto (continued)} \\
\hline
\endhead
\hline
\multicolumn{2}{r}{\footnotesize to be continued}
\endfoot
\hline
\endlastfoot
Cor & Branco - \\ \hline
Formato do papel & A5 \\ \hline
Gramatura & 75 \\ \hline
Cabeçalho & 0,7 \\ \hline
Impressão & Frente e verso \\ \hline
Margens & Espelhadas: superior 2, Inferior: 1,5 \\ \hline
Cabeçalho & 0,7 \\ \hline
Rodapé & 0,7 \\ \hline
Paginação & Externa \\ \hline
Alinhamento vertical & Superior \\ \hline
Cabeçalho & 0,7 \\ \hline
Alinhamento do texto & Justificado \\ \hline
Cor & Branco - \\ \hline
Formato do papel & A5 \\ \hline
Cabeçalho & 0,7 \\ \hline
Gramatura & 75 \\ \hline
Impressão & Frente e verso \\ \hline
Margens & Espelhadas: superior 2, Inferior: 1,5 \\ \hline
Rodapé & 0,7 \\ \hline
Paginação & Externa \\ \hline
Alinhamento vertical & Superior \\ \hline
Alinhamento do texto & Justificado \\ \hline
\end{tabularx}
\end{document}
This table version is throwing no warnings/badboxes at all and has correctly its header with lines on its upper side:
However as learned on the question Why my longtable is throwing Underfull \vbox (badness 10000) several longtables as:
\documentclass[10pt,a5paper,twoside]{memoir}
\usepackage{lmodern}
\usepackage{ragged2e}
\usepackage{longtable}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[main=english]{babel}
% \usepackage[showframe,pass]{geometry}
\begin{document}
\begin{longtable}{ | >{\RaggedRight}p{3cm} | >{\RaggedRight}p{5.0cm} | }
\hline % <====== This is the line causing the warning
Cor & Branco \\
\hline
\end{longtable} \end{document}
Are causing bad boxes warnings if there is a \hline on its top:
Underfull \vbox (badness 10000) detected at line 21
[]
But their warning is fixed by commenting out the line \hline % <====== This is the line causing the warning, however the table is rendered without its top line:
Why these longtables are throwing the bad box warning when there is a \hline on its top?



\hline \endfirsthead, there's no bad box. – Bernard Aug 23 '17 at 01:19\hline\endheadif you don't need a different one for the first page. – cfr Aug 23 '17 at 02:48