我有一个脚注,解释了复杂长表中的颜色编码。我希望这个脚注出现在长表的所有页面上。但是,按照我现在的做法,脚注本身位于其自己的长表中。
还有其他方法可以排版此脚注并使其出现在长表的所有页面上吗?欢迎提出任何想法。
请参阅下面的代码和快照,了解我目前拥有的最低限度的工作示例:
\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}
最终解决方案来自 D.Carlisle 接受的答案和以下评论。
\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
它起作用了,并且图例现在与表格的左侧齐平!
这个问题的另一个原因是,你没有在 longtable 前言中指定 LTleft 和 LTright 的长度。在这种情况下,\noalign
上面的技巧不起作用。以下是解决方案,这全归功于David Carlisle 在 TeX、LaTeX 和 Friends 聊天中提出的极其有用的评论:
尝试:
\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}
}
请注意多列规范中的 @{} 如何删除单元格中内容开始前的空格。因此,它强制图例从长表的墙壁开始,并确保小表格也不会在左侧引入任何额外空间。图例现在与表格边缘可能所在的位置左侧齐平。
非常感谢!
答案1
\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}