I have been trying to add caption and label to a long table (not entirely written below) inside the xltabular environment.
After checking Caption on tabular environment, labels with tabular and some other posts, I did this:
\usepackage{xltabular}
\usepackage{caption}
\captionsetup[table]{skip=-10pt}
\captionof{table}{My Table}
\begin{xltabular}{\textwidth}{@{}Y|Y|Y@{}}
0.0 & 0 & 0 \\
1.0 & 1000 & 0 \\
2.0 & 2000 & 0
\end{xltabular}
which kinda works. However, I keep getting yellow warning messages:
Package caption Warning: \captionsetup{type*=...} or \captionof outside box or environment on input line 161.
Package caption Warning: The option 'hypcap=true' will be ignored for this particular \caption on input line 161.
Also, \captionsetup[table]{skip=-10pt} stops working if I use \captionof{table}{My Table} and I need it because the space between the table and the caption is too large.
How can I solve these problems without using table environment (it makes my table start in a new page)?

\captioncommand should be inside thexltabularenvironment. It is not a floating environmen, and it uses the same syntax aslongtable.. – Bernard Apr 29 '20 at 22:13\caption{}. It was just a matter or rearranging things after all, but I could only do it thanks to you... So, thanks, @Bernard! :) – Ashitaka Apr 29 '20 at 22:26\endhead? Since it will repeat also the caption on every page, once it is inside thexltabularenvironment... – Ashitaka Apr 29 '20 at 22:33begin{xltabular}, interpreted as a row. I wish I could specify which rows should be repeated. – Ashitaka Apr 30 '20 at 00:12\captionsetup[longtable]{options}. It should wotk for xltabular, too. Easier if you have more than one xltabular. – Sveinung Apr 30 '20 at 08:37