I'm trying to put a very long table in a latex document, it works the table is in more than a page but its header is not following the content size.

The code is the following:
\begin{longtable}[c]{|l|l|l|l|l|}
\caption{Long table caption.\label{long}}\\
\hline
\multicolumn{5}{| c |}{Begin of Table}\
\hline
\textbf{Chave} & \textbf{X} & \textbf{X} & \textbf{X} & \textbf{X}\
\hline
\endfirsthead
\hline
\multicolumn{5}{|c|}{Continuation of Table \ref{long}}\
\hline
\textbf{Chave} & \textbf{X} & \textbf{X} & \textbf{X} & \textbf{X}\
\hline
\endhead
\hline
\endfoot
\hline
\multicolumn{5}{|c|}{End of Table}\
\hline\hline
\endlastfoot
X & X & X & X & X \ \hline
X & X & X & X & X \ \hline
X & X & X & X & X \ \hline
X & X & X & X & X \ \hline
....
....
\end{longtable}
Could someone help-me? Thank you all folks
xltabular˛environemnt (combination oftabularxandlongtable, or newlongtblrdefined in thetabularraypackage. But this is not addressed in your question. – Zarko Jul 12 '21 at 19:06xltabularyou can see in https://tex.stackexchange.com/questions/593830/table-with-many-columns-xltabular/593834#593834 – Zarko Jul 12 '21 at 19:12\resizeboxwith tables, it can't work at all withlongtableand withtabularit does not give errors but can not produce good results. – David Carlisle Jul 12 '21 at 22:11https://tex.stackexchange.com/questions/604768/how-to-resize-the-longtable-in-latex– user2535338 Jul 12 '21 at 22:42