[Tex/LaTex] Complicated footnote within longtable environment

footnoteslongtable

I have a footnote that explains color coding within a complicated longtable. I would like this footnote to appear on all pages of the longtable. However, the way I have it now, the footnote itself is within a longtable of its own.

Is there any other way I can typeset this footnote and have it appear on all pages of the longtable? Any ideas would be most welcome.

Please see code and snapshot below for a minimum working example for what I have right now:

\documentclass[6pt]{article}
\usepackage[portrait, total={5.45in, 8.5in}, top=1.25in, bottom=1.25in, right=1.25in, left=1.5in, centering]{geometry}
\usepackage{longtable}
\usepackage{bm}
\usepackage[table]{xcolor}
\usepackage[none]{hyphenat}
\usepackage[T1]{fontenc}
\usepackage[default]{cantarell}
\usepackage{booktabs}
\usepackage{array}
\definecolor{tableShade2}{HTML}{F1F5FA}
\definecolor{tableShade}{HTML}{FAFAFD}
\definecolor{tableShade3}{HTML}{dddddd}
\definecolor{tableShade4}{HTML}{C2A5CF}
\definecolor{tableShade5}{HTML}{E7D4E8}
\definecolor{tableShade6}{HTML}{A1D99B}
\definecolor{tableShade7}{HTML}{D9F0D3}
\definecolor{tableShade1}{HTML}{FFEDA0}

\pagestyle{empty}
\renewcommand{\familydefault}{\sfdefault}
\renewcommand{\arraystretch}{1.25}
\usepackage{arydshln}
\newcolumntype{x}[1]{>{\raggedright}p{#1}}
\arrayrulecolor{tableShade3}
\setlength{\tabcolsep}{4pt}
\begin{document}

\begin{center}
\scriptsize{\textbf{A longtable with two groups}}\end{center}
\setlength\LTleft{0in}
\setlength\LTright{1.25in}
\setlength\LTpre{-0.3cm}
\setlength\LTpost{0in}
\rowcolors{1}{tableShade2}{white}\scriptsize
\newcommand{\CTPanel}[1]{%
\multicolumn{1}{>{\columncolor{white}}r|}{#1}}
\centering
\begin{longtable}{lp{0.3cm}!{\color{tableShade3}\vrule}
               p{0.3cm}!{\color{tableShade3}\vrule}
               p{0.3cm}!{\color{tableShade3}\vrule}
               p{0.3cm}!{\color{tableShade3}\vrule}
               p{0.3cm}!{\color{tableShade3}\vrule}
               p{0.3cm}!{\color{tableShade3}\vrule}
               p{0.3cm}!{\color{tableShade3}\vrule}
               p{0.3cm}!{\color{tableShade3}\vrule}
               p{0.3cm}!{\color{white}\vrule width 4pt}
               p{0.3cm}!{\color{white}\vrule}
               p{0.3cm}!{\color{white}\vrule}
               p{0.3cm}!{\color{white}\vrule}
               p{0.3cm}!{\color{white}\vrule}
               p{0.3cm}!{\color{white}\vrule}
               p{0.3cm}!{\color{white}\vrule}
               p{0.3cm}!{\color{white}\vrule}
               p{0.3cm}!{\color{white}\vrule}
               p{0.3cm}!{\color{white}\vrule}}
\hiderowcolors
&\multicolumn{9}{c}{First Group}&\multicolumn{9}{c}{Second Group}\\\cmidrule(lr){2-10}\cmidrule(lr){11-19}
something&\multicolumn{2}{c}{AB} & \multicolumn{3}{c}{ABCD} &                         
\multicolumn{4}{c}{ABCD EFGH}&\multicolumn{2}{c}{AB} & \multicolumn{3}{c}{ABCD} & \multicolumn{4}{c}{ABCD EFGH}\\\cmidrule(lr){2-3}\cmidrule(lr){4-6}\cmidrule(lr){7-10}\cmidrule(lr){11-12}\cmidrule(lr){13-15}\cmidrule(lr){16-19}
Characteristics & + & - & I & II & III & $L^{A}$ & $L^{B}$ & $H^{+}$ & TN & + & - & I & II & III & $L^{A}$ & $L^{B}$ & $H^{+}$ & TN\\
\specialrule{0.01em}{0.1em}{0em}
\endhead
\specialrule{0.01em}{0em}{0em}
\endfoot
\multicolumn{5}{l}{\textbf{The first subheading}}\\
\showrowcolors
some variable &+&+&-&+&+&-&-&-&-&-&+&+&-&-&+&+&-&-\\
some other variable &+&+&-&+&+&-&-&-&-&-&+&+&-&-&+&+&-&-\\
some other variable &+&+&-&+&+&-&-&-&-&-&+&+&-&-&+&+&-&-\\
fourth variable &+&+&-&+&+&-&-&-&-&-&+&+&-&-&+&+&-&-\\
fifth variable &+&+&-&+&+&-&-&-&-&-&+&+&-&-&+&+&-&-\\
yet other variable &+&+&-&+&+&-&-&-&-&-&+&+&-&-&+&+&-&-\\
\end{longtable}
\scriptsize
%Complicated legend begins
\begin{longtable}{llllll}
\addlinespace[1.6em]
\hiderowcolors
\multicolumn{6}{l}{\textbf{LEGEND}}\\
{\cellcolor{tableShade4}${\bm+^m}$}&: Monotonic Increase, Significant&
{\cellcolor{tableShade6}${\bm-^m}$}&: Monotonic Decrease, Significant&
{\cellcolor{tableShade1}${\bm*}$}&: Non-linear, Significant \\

{\cellcolor{tableShade4}${\bm+}$}&: Increase, Significant&
{\cellcolor{tableShade6}${\bm-}$}&: Decrease, Significant&
{\cellcolor{tableShade1}${\bm\pm}$}&: Mixed, Significant    {\cellcolor{tableShade5}$+^m$}&: Monotonic Increase&
{\cellcolor{tableShade7}$-^m$}&: Monotonic Decrease&
{\cellcolor{tableShade2}$\pm$}&: Mixed    {\cellcolor{tableShade5}$+$}&: Increase&
{\cellcolor{tableShade7}$-$}&: Decrease&
-&: Not computed\\
\addlinespace[1em]
\multicolumn{6}{l}{AB: ABbreviation}\\
\end{longtable}
\end{document}

MWE of longtable with complicated legend

Final solution from D.Carlisle's accepted answer and comments below.

\endhead
 %Complicated legend begins at the top of longtable in the \endfoot area
\noalign{\raggedright
\scriptsize
{
\begin{tabular}{llllll}
\hiderowcolors
\multicolumn{6}{l}{\textbf{LEGEND}}\\
{\cellcolor{tableShade4}${\bm+^m}$}&: Monotonic Increase, Significant&
{\cellcolor{tableShade6}${\bm-^m}$}&: Monotonic Decrease, Significant&
{\cellcolor{tableShade1}${\bm*}$}&: Non-linear, Significant \\    
{\cellcolor{tableShade4}${\bm+}$}&: Increase, Significant&
{\cellcolor{tableShade6}${\bm-}$}&: Decrease, Significant&
{\cellcolor{tableShade1}${\bm\pm}$}&: Mixed, Significant\\    
{\cellcolor{tableShade5}$+^m$}&: Monotonic Increase&
{\cellcolor{tableShade7}$-^m$}&: Monotonic Decrease&
{\cellcolor{tableShade2}$\pm$}&: Mixed\\        
{\cellcolor{tableShade5}$+$}&: Increase&
{\cellcolor{tableShade7}$-$}&: Decrease&
-&: Not computed\\
\addlinespace[1em]
\multicolumn{6}{l}{AB: ABbreviation}\\
\end{tabular}
}
\endfoot

It works and the legend is now flush left with the table!

An addition to this problem is when you do not specify the LTleft and LTright lengths in your longtable preamble. In this case, the \noalign trick above does not work. Here's the solution, all thanks to David Carlisle's incredibly useful comments in TeX, LaTeX and Friends chat:

Try:

\multicolumn{8}{@{}p {6in}}
{\raggedright
\begin{tabular}{llllll}
\hiderowcolors
\addlinespace[2pt]
\multicolumn{6}{@{}l}{Variables with as asterisk(*) have corresponding continuous forms. Please also see Table x.x for summary from the analyses using these continuous forms.}\\
\multicolumn{6}{@{}l}{\textbf{LEGEND}}\\
{\cellcolor{tableShade4}${\bm+^m}$}&: Monotonic Increase, Significant&
{\cellcolor{tableShade6}${\bm-^m}$}&: Monotonic Decrease, Significant&
{\cellcolor{tableShade1}${\bm*}$}&: Non-linear, Significant \\   
{\cellcolor{tableShade4}${\bm+}$}&: Increase, Significant&
{\cellcolor{tableShade6}${\bm-}$}&: Decrease, Significant&
{\cellcolor{tableShade1}${\bm\pm}$}&: Mixed, Significant    {\cellcolor{tableShade5}$+^m$}&: Monotonic Increase&
{\cellcolor{tableShade7}$-^m$}&: Monotonic Decrease&
{\cellcolor{tableShade2}$\pm$}&: Mixed    {\cellcolor{tableShade5}$+$}&: Increase&
{\cellcolor{tableShade7}$-$}&: Decrease&
-&: Not computed\\
\end{tabular}
}

Notice how @{} in the multicolumn specification removes the space before the content starts in a cell. So it forces the legend to start at the wall of the longtable and ensures that the small tabular also does not introduce any extra space on the left.The legend now appears flush left with wherever the table edge might be.

Many thanks!

Best Answer

enter image description here

\documentclass[6pt]{article}
\usepackage[portrait, total={5.45in, 8.5in}, top=1.25in, bottom=1.25in, right=1.25in, left=1.5in, centering]{geometry}
\usepackage{longtable}
\usepackage{bm}
\usepackage[table]{xcolor}
\usepackage[none]{hyphenat}
\usepackage[T1]{fontenc}
%\usepackage[default]{cantarell}
\usepackage{booktabs}
\usepackage{array}
\definecolor{tableShade2}{HTML}{F1F5FA}
\definecolor{tableShade}{HTML}{FAFAFD}
\definecolor{tableShade3}{HTML}{dddddd}
\definecolor{tableShade4}{HTML}{C2A5CF}
\definecolor{tableShade5}{HTML}{E7D4E8}
\definecolor{tableShade6}{HTML}{A1D99B}
\definecolor{tableShade7}{HTML}{D9F0D3}
\definecolor{tableShade1}{HTML}{FFEDA0}

\pagestyle{empty}
\renewcommand{\familydefault}{\sfdefault}
\renewcommand{\arraystretch}{1.25}
\usepackage{arydshln}
\newcolumntype{x}[1]{>{\raggedright}p{#1}}
\arrayrulecolor{tableShade3}
\setlength{\tabcolsep}{4pt}
\begin{document}

\begin{center}
\scriptsize{\textbf{A longtable with two groups}}\end{center}
\setlength\LTleft{0in}
\setlength\LTright{1.25in}
\setlength\LTpre{-0.3cm}
\setlength\LTpost{0in}
\rowcolors{1}{tableShade2}{white}\scriptsize
\newcommand{\CTPanel}[1]{%
\multicolumn{1}{>{\columncolor{white}}r|}{#1}}
\centering
\begin{longtable}{lp{0.3cm}!{\color{tableShade3}\vrule}
               p{0.3cm}!{\color{tableShade3}\vrule}
               p{0.3cm}!{\color{tableShade3}\vrule}
               p{0.3cm}!{\color{tableShade3}\vrule}
               p{0.3cm}!{\color{tableShade3}\vrule}
               p{0.3cm}!{\color{tableShade3}\vrule}
               p{0.3cm}!{\color{tableShade3}\vrule}
               p{0.3cm}!{\color{tableShade3}\vrule}
               p{0.3cm}!{\color{white}\vrule width 4pt}
               p{0.3cm}!{\color{white}\vrule}
               p{0.3cm}!{\color{white}\vrule}
               p{0.3cm}!{\color{white}\vrule}
               p{0.3cm}!{\color{white}\vrule}
               p{0.3cm}!{\color{white}\vrule}
               p{0.3cm}!{\color{white}\vrule}
               p{0.3cm}!{\color{white}\vrule}
               p{0.3cm}!{\color{white}\vrule}
               p{0.3cm}!{\color{white}\vrule}}
\hiderowcolors
&\multicolumn{9}{c}{First Group}&\multicolumn{9}{c}{Second Group}\\\cmidrule(lr){2-10}\cmidrule(lr){11-19}
something&\multicolumn{2}{c}{AB} & \multicolumn{3}{c}{ABCD} &                         
\multicolumn{4}{c}{ABCD EFGH}&\multicolumn{2}{c}{AB} & \multicolumn{3}{c}{ABCD} & \multicolumn{4}{c}{ABCD EFGH}\\\cmidrule(lr){2-3}\cmidrule(lr){4-6}\cmidrule(lr){7-10}\cmidrule(lr){11-12}\cmidrule(lr){13-15}\cmidrule(lr){16-19}
Characteristics & + & - & I & II & III & $L^{A}$ & $L^{B}$ & $H^{+}$ & TN & + & - & I & II & III & $L^{A}$ & $L^{B}$ & $H^{+}$ & TN\\
\specialrule{0.01em}{0.1em}{0em}
\endhead
\noalign{
\scriptsize
%Complicated legend begins
\begin{tabular}{llllll}
\addlinespace[1.6em]
\hiderowcolors
\multicolumn{6}{l}{\textbf{LEGEND}}\\
{\cellcolor{tableShade4}${\bm+^m}$}&: Monotonic Increase, Significant&
{\cellcolor{tableShade6}${\bm-^m}$}&: Monotonic Decrease, Significant&
{\cellcolor{tableShade1}${\bm*}$}&: Non-linear, Significant \\
{\cellcolor{tableShade4}${\bm+}$}&: Increase, Significant&
{\cellcolor{tableShade6}${\bm-}$}&: Decrease, Significant&
{\cellcolor{tableShade1}${\bm\pm}$}&: Mixed, Significant\\
{\cellcolor{tableShade5}$+^m$}&: Monotonic Increase&
{\cellcolor{tableShade7}$-^m$}&: Monotonic Decrease&
{\cellcolor{tableShade2}$\pm$}&: Mixed\\
{\cellcolor{tableShade5}$+$}&: Increase&
{\cellcolor{tableShade7}$-$}&: Decrease&
-&: Not computed\\
\addlinespace[1em]
\multicolumn{6}{l}{AB: ABbreviation}\\
\end{tabular}
}
\endfoot
\specialrule{0.01em}{0em}{0em}
\multicolumn{5}{l}{\textbf{The first subheading}}\\
\showrowcolors
some variable &+&+&-&+&+&-&-&-&-&-&+&+&-&-&+&+&-&-\\
some other variable &+&+&-&+&+&-&-&-&-&-&+&+&-&-&+&+&-&-\\
some other variable &+&+&-&+&+&-&-&-&-&-&+&+&-&-&+&+&-&-\\
\newpage
fourth variable &+&+&-&+&+&-&-&-&-&-&+&+&-&-&+&+&-&-\\
fifth variable &+&+&-&+&+&-&-&-&-&-&+&+&-&-&+&+&-&-\\
yet other variable &+&+&-&+&+&-&-&-&-&-&+&+&-&-&+&+&-&-\\
\end{longtable}
\end{document}
Related Question