I have a particularly long table which spread across pages. I want a horizontal line to come at the end of the table at each page. The problem is when I use "\hline \endfoot" a horizontal line also appears after the caption. Is there a way to fix that? I don't want the horizontal line to appear after the caption.
\documentclass{report}
\usepackage[utf8]{inputenc}
\usepackage[table,xcdraw]{xcolor}
\usepackage{blindtext}
\usepackage{multirow}
\usepackage[a4paper]{geometry}
\usepackage{tabularx}
\usepackage{longtable}
\usepackage{array}
\usepackage{ragged2e}
\usepackage{setspace}
\geometry{a4paper,tmargin=3.5cm, bmargin=2.5cm, lmargin=1.5cm, rmargin=1.5cm, headheight=3em, headsep=1.5cm, footskip=1cm}
\usepackage{color, colortbl}
\definecolor{mColor1}{rgb}{0.9,0.9,0.9}
\usepackage{tgbonum}
\usepackage{pdflscape}
\usepackage{enumitem}
\usepackage[myheadings]{fullpage}
\usepackage{fancyhdr}
\usepackage{lastpage}
\usepackage{graphicx, wrapfig, subcaption, setspace, booktabs}
\usepackage[T1]{fontenc}
\usepackage[font=small, labelfont=bf]{caption}
\usepackage{fourier}
\usepackage[protrusion=true, expansion=true]{microtype}
\usepackage[english]{babel}
\usepackage{sectsty}
\usepackage{url, lipsum}
\newcommand{\HRule}[1]{\rule{\linewidth}{#1}}
\onehalfspacing
\setcounter{tocdepth}{5}
\setcounter{secnumdepth}{5}
\begin{document}
\begin{landscape}
\begin{longtable}{| p{2.5cm} | p{2.2cm} | p{2cm} |p{2cm} |p{2.5cm} |p{3.8cm} |p{4cm} |p{3cm}|} \hline\rowcolor{mColor1} Form Filename&Date&Status&Charge ID&Amount&Charge is on&ROI&Certificate Filename \endhead \hline
\endfoot Form 8-190706.do&-&Modification&80006325&500,000,000&Furniture, Plant Machinery, Book debts, Stock in trade&-&-\\Form 8-190706.do&-&Modification&80006325&500,000,000&Furniture, Plant Machinery, Book debts, Stock in trade&-&-\\Form 8-190706.do&-&Modification&80006325&500,000,000&Furniture, Plant Machinery, Book debts, Stock in trade&-&-\\Form 8-190706.do&-&Modification&80006325&500,000,000&Furniture, Plant Machinery, Book debts, Stock in trade&-&-\\Form 8-190706.do&-&Modification&80006325&500,000,000&Furniture, Plant Machinery, Book debts, Stock in trade&-&-\\Form 8-190706.do&-&Modification&80006325&500,000,000&Furniture, Plant Machinery, Book debts, Stock in trade&-&-\\Form 8-190706.do&-&Modification&80006325&500,000,000&Furniture, Plant Machinery, Book debts, Stock in trade&-&-\\Form 8-190706.do&-&Modification&80006325&500,000,000&Furniture, Plant Machinery, Book debts, Stock in trade&-&-\\Form 8-190706.do&-&Modification&80006325&500,000,000&Furniture, Plant Machinery, Book debts, Stock in trade&-&-\\Form 8-190706.do&-&Modification&80006325&500,000,000&Furniture, Plant Machinery, Book debts, Stock in trade&-&-\\Form 8-190706.do&-&Modification&80006325&500,000,000&Furniture, Plant Machinery, Book debts, Stock in trade&-&-\\Form 8-190706.do&-&Modification&80006325&500,000,000&Furniture, Plant Machinery, Book debts, Stock in trade&-&-\\Form 8-190706.do&-&Modification&80006325&500,000,000&Furniture, Plant Machinery, Book debts, Stock in trade&-&-\\Form 8-190706.do&-&Modification&80006325&500,000,000&Furniture, Plant Machinery, Book debts, Stock in trade&-&-\\Form 8-190706.do&-&Modification&80006325&500,000,000&Furniture, Plant Machinery, Book debts, Stock in trade&-&-\\Form 8-190706.do&-&Modification&80006325&500,000,000&Furniture, Plant Machinery, Book debts, Stock in trade&-&-\\Form 8-190706.do&-&Modification&80006325&500,000,000&Furniture, Plant Machinery, Book debts, Stock in trade&-&-\\Form 8-190706.do&-&Modification&80006325&500,000,000&Furniture, Plant Machinery, Book debts, Stock in trade&-&-\\Form 8-190706.do&-&Modification&80006325&500,000,000&Furniture, Plant Machinery, Book debts, Stock in trade&-&-\\Form 8-190706.do&-&Modification&80006325&500,000,000&Furniture, Plant Machinery, Book debts, Stock in trade&-&-\\Form 8-190706.do&-&Modification&80006325&500,000,000&Furniture, Plant Machinery, Book debts, Stock in trade&-&-\\Form 8-190706.do&-&Modification&80006325&500,000,000&Furniture, Plant Machinery, Book debts, Stock in trade&-&-\\Form 8-190706.do&-&Modification&80006325&500,000,000&Furniture, Plant Machinery, Book debts, Stock in trade&-&-\\Form 8-190706.do&-&Modification&80006325&500,000,000&Furniture, Plant Machinery, Book debts, Stock in trade&-&-\\Form 8-190706.do&-&Modification&80006325&500,000,000&Furniture, Plant Machinery, Book debts, Stock in trade&-&-\\Form 8-190706.do&-&Modification&80006325&500,000,000&Furniture, Plant Machinery, Book debts, Stock in trade&-&-\\Form 8-190706.do&-&Modification&80006325&500,000,000&Furniture, Plant Machinery, Book debts, Stock in trade&-&-\\Form 8-190706.do&-&Modification&80006325&500,000,000&Furniture, Plant Machinery, Book debts, Stock in trade&-&-\\Form 8-190706.do&-&Modification&80006325&500,000,000&Furniture, Plant Machinery, Book debts, Stock in trade&-&-\\Form 8-190706.do&-&Modification&80006325&500,000,000&Furniture, Plant Machinery, Book debts, Stock in trade&-&-\\Form 8-190706.do&-&Modification&80006325&500,000,000&Furniture, Plant Machinery, Book debts, Stock in trade&-&-\\Form 8-190706.do&-&Modification&80006325&500,000,000&Furniture, Plant Machinery, Book debts, Stock in trade&-&-\\Form 8-190706.do&-&Modification&80006325&500,000,000&Furniture, Plant Machinery, Book debts, Stock in trade&-&-\\Form 8-190706.do&-&Modification&80006325&500,000,000&Furniture, Plant Machinery, Book debts, Stock in trade&-&-\\Form 8-190706.do&-&Modification&80006325&500,000,000&Furniture, Plant Machinery, Book debts, Stock in trade&-&-\\Form 8-190706.do&-&Modification&80006325&500,000,000&Furniture, Plant Machinery, Book debts, Stock in trade&-&-\\Form 8-190706.do&-&Modification&80006325&500,000,000&Furniture, Plant Machinery, Book debts, Stock in trade&-&-\\Form 8-190706.do&-&Modification&80006325&500,000,000&Furniture, Plant Machinery, Book debts, Stock in trade&-&-\\Form 8-190706.do&-&Modification&80006325&500,000,000&Furniture, Plant Machinery, Book debts, Stock in trade&-&-\\Form 8-190706.do&-&Modification&80006325&500,000,000&Furniture, Plant Machinery, Book debts, Stock in trade&-&-\\Form 8-190706.do&-&Modification&80006325&500,000,000&Furniture, Plant Machinery, Book debts, Stock in trade&-&-\\Form 8-190706.do&-&Modification&80006325&500,000,000&Furniture, Plant Machinery, Book debts, Stock in trade&-&-\\Form 8-190706.do&-&Modification&80006325&500,000,000&Furniture, Plant Machinery, Book debts, Stock in trade&-&-\\Form 8-190706.do&-&Modification&80006325&500,000,000&Furniture, Plant Machinery, Book debts, Stock in trade&-&-\\Form 8-190706.do&-&Modification&80006325&500,000,000&Furniture, Plant Machinery, Book debts, Stock in trade&-&-\\Form 8-190706.do&-&Modification&80006325&500,000,000&Furniture, Plant Machinery, Book debts, Stock in trade&-&-\\Form 8-190706.do&-&Modification&80006325&500,000,000&Furniture, Plant Machinery, Book debts, Stock in trade&-&-\\\hline \caption{hello}\end{longtable}
\end{landscape}
\end{document}
Best Answer
Your problem here is that you wrote command
\caption{...}
at the end of the table.A
longtable
has a special structure you should use. Please read the documentation (usetexdoc longtable
on your terminal/console)!Just add after command
\endfoot
the following code:to get what you want.
After some pretty printing and deleted not used packages here you get the following MWE
with the resulting last table page:
EDIT:
To get a better result I suggest some changings in your table.
\endfirsthead
. In the code for the\endfoot
you can add a notice that table is to be continued ... See for more informations the documentation oflongtable
(for example withtexdoc longtable
).ragged2e
andarray
you get a command\RaggedRight
which allows a better hyphenating in your table columns. For example use>{\RaggedRight}p{2.5cm}
to get the first column left justified with better hyphenation.\usepackage{booktabs}
you can use the commands\toprule
,\midrule
and\bottomrule
to get nice horizontal rules in your table where needed.Please see the following MWE (code changes marked with
<=========
):you get the following result: