Perhaps this is, what the OP requests, but I could not test any feature, since the example by the OP is fragmented. I changed to tcolorbox
with no rounded corners and switched off the box rules. In order to demonstrate the colorbox at all, I used a yellow background colour.
\documentclass[12pt,a4paper]{article}
\usepackage{longtable}
\setlength{\LTpre}{0pt}
\setlength{\LTpost}{-6pt}
\usepackage{array}
\usepackage[applemac]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage[UKenglish]{babel}
\usepackage[UKenglish]{isodate}
\usepackage{geometry}
\usepackage{booktabs}
\usepackage{array}
\usepackage{lscape}
\usepackage{siunitx}
\usepackage{parskip}
\usepackage{xcolor}
\usepackage{tcolorbox}%
\definecolor{lightgray}{gray}{0.98}
\usepackage[skip=2pt,font=scriptsize]{caption}
\newcommand{\oneS}{\ensuremath{{}^{\textstyle *}}}
\newcommand{\twoS}{\ensuremath{{}^{\textstyle **}}}
\tcbuselibrary{breakable}
\begin{document}%
\newgeometry{left=1.5cm,right=1.5cm,top=1.8cm,bottom=1.8cm}
\begin{landscape}
\scriptsize
\thispagestyle{empty}
\scriptsize
%\begingroup\setlength{\fboxsep}{0pt} >>> NOT WORKING returns "Missing \endgroup inserted" error
%\colorbox{lightgray}{
\begin{tcolorbox}[boxrule=0pt,colback=yellow,oversize=1cm,arc=0mm,auto outer arc, breakable]
\begin{longtable}{%
l S[table-format=-1.4] S[table-format=-1.4] S[table-format=-3.2] S[table-format=-5.2]
S[table-format= 7.2] S[table-format=-3.2] S[table-format=-3.2] S[table-format=-3.2]
S[table-format=-3.2] @{\hspace{0.8cm}} r r r r }
\caption{Summary statistics} \label{fig:sumstat} \\
\toprule
{Future i.e. underlying asset} & \multicolumn{5}{l}{Daily returns on long-only
positions} & \multicolumn{4}{l}{Ljung-Box } & \multicolumn{2}{l}{Avg. vol. (\$ mil.)}
& \multicolumn{2}{l}{Avg. open interest} \\
\cmidrule(r){2-6} \cmidrule(r){7-10} \cmidrule(r){11-12} \cmidrule(r){13-14}
& {Mean (\%)} & {Std. (\%)} & {Skew. (\%)} & {Kurt. (\%)} & {Jarque-Bera} & {(5)} &
{(20)} & {(60)} & {(120)} & {2000} & {2014} & {2000} & {2014} \\
\midrule
\endfirsthead
\toprule
{Future i.e. underlying asset} & \multicolumn{5}{l}{Daily returns on long-only
positions} & \multicolumn{4}{l}{Ljung-Box } & \multicolumn{2}{l}{Avg. vol. (\$ mil.)}
& \multicolumn{2}{l}{Avg. open interest} \\
\cmidrule(r){2-6} \cmidrule(r){7-10} \cmidrule(r){11-12} \cmidrule(r){13-14}
& {Mean (\%)} & {Std. (\%)} & {Skew. (\%)} & {Kurt. (\%)} & {Jarque-Bera} & {(5)}
& {(20)} & {(60)} & {(120)} & {2000} & {2014} & {2000} & {2014} \\
\midrule
\endhead
\bottomrule \multicolumn{14}{r}{\emph{Continued on next page}}
\endfoot
\bottomrule
\endlastfoot
Frozen Concentrated Orange Juice & -0.0184 & 1.8845 & -8.68 & 764.51
\twoS & 3170.82 \twoS & 20.61 \twoS & 43.77 \twoS & 98.60 \twoS
& 150.82 \oneS & 43 & 37 & 25727 & 16991 \\
\end{longtable}
\end{tcolorbox}%
% }\endgroup >>> NOT WORKING returns "Missing \endgroup inserted"error
\thispagestyle{empty}
\end{landscape}
\restoregeometry
\end{document}%
The screen shot shows a version, where I copied the last table line to blow up the table for next page, but for sake of shortness, I do not post this repetion in this example here.
Edit -- Update
As the OP requested:
A more tight colorbox around the table, with a grey background colour, in order to keep the post small, I will only give the change -- replace this in my above example.
In the preamble use
\usepackage{caption}
At the relevant place just before \begin{longtable}
use for the tightest tcolorbox
around the table itself.
\captionof{table}{Summary statistics} \label{fig:sumstat}
\begin{tcolorbox}[left=2pt,top=0pt,boxrule=0pt,bottom=0pt,boxsep=0pt,colback=gray,arc=0mm,auto outer arc, breakable]
It's not clear that there is really an issue to be solved, it is only an issue for tables if you think there is an issue about tables. Most of the points that you raise could also be made about "paragraphs" or "lists", at some point you have to have some structural information as well as words.
It is easy to have an environment that defaults the column spec, consider for example the amsmath matrix
which is more or less just array
with a default supplied preamble of *{20}{c}
so you could define
\newenvironment{mytab}[1][*{50}{c}]{%
\begin{tabular}{#1}}{%
\end{tabular}}
which makes the column specifications optional, defaulting to all centred. Unlike matrices though where a global default is commonly useful, in my experience a global table default is almost never useful, tables usually have varied column types, some textual, some numeric to be aligned on decimal points, etc. However if in a particular document you have a lot of tables all taking the same form you could use a definition as above, replacing *{50}{c}
by say >{\bfseries}l *{2}{D..{3.2}} p{3cm}
if all your tables have a bold left aligned column, two numeric columns and a final column of note paragraphs.
It's hard to guess how you could automate rules in general, If you always want a top and bottom rule you could change your definition to
\newenvironment{mytab}[1][*{50}{c}]{%
\begin{tabular}{#1}\toprule}{%
\\\bottomrule\end{tabular}}
But the position of \midrule
is rather like the position of words and numbers in the table, effectively it's data that must be entered in each case. Perhaps you only want \midrule
after the heading in which case you could use
\newcommand\endhead{\\\midrule}
so your tables would then look like
\begin{mytab}
\hd{type}&\hd{A}&\hd{B}&\hd{Notes}\endhead
zzz&1.2&3.4& zz zz zzzzz\\
zzz&1.2&3.4& zz zz zzzzz\\
\end{tab}
Using a heading command \hd
that could be defined as
\newcommand\hd[1]{%
\multicolumn{1}{c}{\bfseries\begin{tabular}{@{}c@{}}#1\end{tabular}}
To give bold, centred, potentially multi-line table headings. Color could be added to this command as well if you want coloured tables, there is no need for explicit colours in the table.
Best Answer
You can use two longtables, but arrange that they share the same column widths:
If you need more than two, you need the weird code before each except the last, making in each case
\LT@<thistable>
be defined to be\LT@<the last>
table>