# longtable caption is floating over longtable

I am attempting to use longtables since my table will span several pages. The problem I have now is that the captions are floating over top of the table making it difficult to read the table. I want the caption below the table for each page it is on, but am not sure how to accomplish that.

\usepackage{longtable}
\section{System}
\begin{longtable}[H]
\begin{center}
\rowcolors{2}{gray!15}{white}
\begin{tabular}{|p{0.20\linewidth}|p{0.80\linewidth}|}
\hline
\rowcolor{cyan}
\textbf{field} & \textbf{value}
\\ \hline
website & http://www.funtoo.org \\ \hline
\end{tabular}
\end{center}
\caption{Funtoo Details}
\label{Funtoo Details}
\end{longtable}

• Obviously, this is not the table that has too many rows in it, but just serves as an example of the problem. Jul 15, 2016 at 3:17
• Please make your code snippet compilable! Inside longtable you do not need tabular, please check the documentation with texdoc longtable ... Welcome to TeX.SE! Jul 15, 2016 at 3:45

Do take some time to master the structure (and syntax) of longtable environments:

• Don't use tabular environments inside a longtable environment. Really: don't do it.
• Don't use center environments inside a longtable environment -- it's automatically centered (assuming it's not wider than \linewidth by design or accident...)
• The full width of your tabular is not \linewidth but \linewidth + 4\tabcolsep + 3\arrayrulewidth. That's not the intention, is it?
• A longtable doesn't float -- the [H] positioning specifier doesn't do anything at all (other than clutter up the code)

The following may be a useful starting point for further refinements. Note how (a) I've separated out the header, the footer, and the body of the longtable and (b) provided calculations for the usable widths of the two columns.

\documentclass{article}
\usepackage{longtable,url}
\begin{document}
\section{System}

\begin{longtable}{|p{\dimexpr0.2\linewidth-2\tabcolsep-1.5\arrayrulewidth\relax}|
p{\dimexpr0.8\linewidth-2\tabcolsep-1.5\arrayrulewidth\relax}|}
\hline
%\rowcolor{cyan}
\textbf{field} & \textbf{value}\\
\hline
%% define the footer
\hline
\multicolumn{1}{c}{}\\ % blank line
\caption{Funtoo Details}
\label{Funtoo Details}
\endfoot
%% body of table
website & \url{http://www.funtoo.org} \\
website & \url{http://www.funtoo.org} \\
website & \url{http://www.funtoo.org} \\
website & \url{http://www.funtoo.org} \\
website & \url{http://www.funtoo.org} \\
\end{longtable}
\end{document}

• Thanks, that worked. I had all of those things because I converted directly from my table usage. Now, I'd like to re-add the colors I had, but that is a minor detail. Jul 15, 2016 at 10:37
• I re-added the colors, so that worked perfectly for me. Jul 16, 2016 at 2:02