A quick solution would be to use \multicolumn{4}{@{} p{\textwidth} @{}}
\documentclass{book}
\usepackage{tabularx,cellspace,longtable,makecell}
\begin{document}
Dummy text for new page
\newpage
\begingroup
\setcellgapes{5pt}
\makegapedcells
\noindent
\begin{longtable}{|c|c|c|c|}
\caption{Test Table.}
\label{test} \\
\hline
\textbf{No} & \textbf{A} & \textbf{B} & \textbf{C} \\
\hline
\endhead
\multicolumn{4}{@{} p{\textwidth} @{}}{\scriptsize {Source: Source 2000, Source 2001, Source 2002, Source 2003, Source 2004, Source 2005, Source 2006, Source 2007, Source 2008, Source 2009, Source 2010, Source 2011, Source 2012, Source 2013, Source 2014, Source 2015, Source 2016, Source 2017, Source 2018, Source 2019, Source 2020, Source 2021, Source 2022}} \\
\endfoot
\hline
1&A&B&C\\
2&D&E&F\\
1&A&B&C\\
2&D&E&F\\
1&A&B&C\\
2&D&E&F\\
1&A&B&C\\
2&D&E&F\\
1&A&B&C\\
2&D&E&F\\
1&A&B&C\\
2&D&E&F\\
1&A&B&C\\
2&D&E&F\\
1&A&B&C\\
2&D&E&F\\
1&A&B&C\\
2&D&E&F\\
1&A&B&C\\
2&D&E&F\\
1&A&B&C\\
2&D&E&F\\
1&A&B&C\\
2&D&E&F\\
1&A&B&C\\
2&D&E&F\\
1&A&B&C\\
2&D&E&F\\
1&A&B&C\\
2&D&E&F\\
1&A&B&C\\
2&D&E&F\\
1&A&B&C\\
2&D&E&F\\
\hline
\end{longtable}
\endgroup
\end{document}
I would recommend to use the longtblr
environment from tabularray
for this. With that, you can define a remark
for your source, which will only appear on the last page.
\documentclass{book}
\usepackage{tabularray}
\begin{document}
Dummy text for new page
\newpage
\begin{longtblr}[
caption={Test Table.},
label={test},
remark{Source}={Source 2000, Source 2001, Source 2002, Source 2003, Source 2004, Source 2005, Source 2006, Source 2007, Source 2008, Source 2009, Source 2010, Source 2011, Source 2012, Source 2013, Source 2014, Source 2015, Source 2016, Source 2017, Source 2018, Source 2019, Source 2020, Source 2021, Source 2022}
]{
colspec={*{4}{X[c]}}, vlines,
row{1}={font=\bfseries},
rowhead=1,
}
\hline
No & A & B & C \\
\hline
1&A&B&C\\
2&D&E&F\\
1&A&B&C\\
2&D&E&F\\
1&A&B&C\\
2&D&E&F\\
1&A&B&C\\
2&D&E&F\\
1&A&B&C\\
2&D&E&F\\
1&A&B&C\\
2&D&E&F\\
1&A&B&C\\
2&D&E&F\\
1&A&B&C\\
2&D&E&F\\
1&A&B&C\\
2&D&E&F\\
1&A&B&C\\
2&D&E&F\\
1&A&B&C\\
2&D&E&F\\
1&A&B&C\\
2&D&E&F\\
1&A&B&C\\
2&D&E&F\\
1&A&B&C\\
2&D&E&F\\
1&A&B&C\\
2&D&E&F\\
1&A&B&C\\
2&D&E&F\\
1&A&B&C\\
2&D&E&F\\
\hline
\end{longtblr}
\end{document}
Note that tabularray
has better vertical spacing by default. Therefore there is no need to use cellspace
or makecell
package. You can have a look at the tabularray
documentation for more options to customize the layout.
There is however one caveat. The remark
will be typeset on the width of the table, which could be a problem, if your table is narrow. I used the X
column type to artifically enlarge the table. Since this is just an example, I cannot tell if this will be a problem in your actual table.
Edit Remark on every page
If you want the source to appear on every page, you can use the following code (inspired by this post).
\documentclass{book}
\usepackage{tabularx,cellspace,longtable,makecell}
\usepackage{tabularray}
% Notes and remarks on every page
\DefTblrTemplate{firstfoot, middlefoot}{default}{%
\UseTblrTemplate{note}{default}
\UseTblrTemplate{remark}{default}
\UseTblrTemplate{contfoot}{default}
}
\begin{document}
Dummy text for new page
\newpage
\begin{longtblr}[
caption={Test Table.},
label={test},
remark{Source}={Source 2000, Source 2001, Source 2002, Source 2003, Source 2004, Source 2005, Source 2006, Source 2007, Source 2008, Source 2009, Source 2010, Source 2011, Source 2012, Source 2013, Source 2014, Source 2015, Source 2016, Source 2017, Source 2018, Source 2019}
]{
colspec={*{4}{X[c]}}, vlines,
row{1}={font=\bfseries},
rowhead=1,
}
\hline
No & A & B & C \\
\hline
1&A&B&C\\
2&D&E&F\\
1&A&B&C\\
2&D&E&F\\
1&A&B&C\\
2&D&E&F\\
1&A&B&C\\
2&D&E&F\\
1&A&B&C\\
2&D&E&F\\
1&A&B&C\\
2&D&E&F\\
1&A&B&C\\
2&D&E&F\\
1&A&B&C\\
2&D&E&F\\
1&A&B&C\\
2&D&E&F\\
1&A&B&C\\
2&D&E&F\\
1&A&B&C\\
2&D&E&F\\
1&A&B&C\\
2&D&E&F\\
1&A&B&C\\
2&D&E&F\\
1&A&B&C\\
2&D&E&F\\
1&A&B&C\\
2&D&E&F\\
1&A&B&C\\
2&D&E&F\\
1&A&B&C\\
2&D&E&F\\
\hline
\end{longtblr}
\end{document}