我正在为我的论文创建文档,该论文由三章组成。其中一章中有longtables
。在将该章作为撰写时article
,我找到了一种解决方案,使表格具有标题和说明(均在内caption
)。这是我的代码的一部分(表格较长,因此使用longtable
是合理的):
\documentclass[a4paper]{article}
\usepackage{longtable,array}
\usepackage[justification=centering]{caption}
\usepackage{cellspace}
\usepackage{booktabs}
\usepackage{varwidth}
\usepackage[a4paper,margin=25mm]{geometry}
\usepackage{multirow}
\usepackage{multicol}
\setlength{\parskip}{\baselineskip}
\setlength{\tabcolsep}{4pt}
\setlength\cellspacetoplimit{5pt}
\setlength\cellspacebottomlimit{5pt}
\newenvironment{outdent}
{\begin{list}{}{\leftmargin-0cm\rightmargin\leftmargin}\centering\item\relax}
{\end{list}\ignorespacesafterend}
\begin{document}
\begin{footnotesize}
\begin{longtable}{m{3cm}m{3cm}@{}m{3cm}@{}m{3cm}@{}m{2.1cm}@{}}
\caption{Binary ESG Variables \newline \smallskip \newline \footnotesize This table shows the means of the binary ESG variables for the full period (2002-2017) and for two subperiods (2002-2007 and 2008-2017), the growth rate from one subperiod to the other and the overall mean for all of them in the last row.}
\label{descbin}\\
\toprule
Variable & Mean (2002-2017) & Mean (2002-2007) & Mean (2008-2017) & Mean Growth \\
\hline
\midrule[\heavyrulewidth] % make this rule as thick as \toprule
\endfirsthead
\toprule
\multicolumn{5}{l}{\small\sl continued from previous page}\\ \hline
Variable & Mean (2002-2017) & Mean (2002-2007) & Mean (2008-2017) & Mean Growth \\
\hline
\midrule[\heavyrulewidth] % make this rule as thick as \toprule
\endhead
\bottomrule
\multicolumn{5}{r}{\small\sl continued on next page} \\ \hline
\endfoot
\bottomrule
\endlastfoot
\hline \multicolumn{5}{|c|}{Panel A: Environmental variables} \\
\hline CO2EmT & 0.38992 & 0.27250 & 0.46037 & 68.95\% \\
CO2DirEm & 0.28134 & 0.15358 & 0.35800 & 133.11\% \\
CO2IndEm & 0.25803 & 0.10909 & 0.34739 & 218.44\% \\
FlaNG & 0.00729 & 0.00616 & 0.00796 & 29.28\% \\
OzDepSub & 0.03486 & 0.02730 & 0.03939 & 44.32\% \\
NOxEm & 0.14152 & 0.12901 & 0.14902 & 15.51\% \\
SOxEm & 0.13392 & 0.11698 & 0.14409 & 23.18\% \\
VOCEm & 0.07476 & 0.06650 & 0.07972 & 19.88\% \\
WasTot & 0.25446 & 0.18339 & 0.29710 & 62.00\% \\
NhazWas & 0.12237 & 0.07164 & 0.15280 & 113.30\% \\
WasRecT & 0.19662 & 0.12476 & 0.23973 & 92.15\% \\
HazWas & 0.13412 & 0.09565 & 0.15720 & 64.34\% \\
WatDis & 0.07482 & 0.05188 & 0.08858 & 70.72\% \\
WatPolEm & 0.06320 & 0.04405 & 0.07470 & 69.57\% \\
ISOEMSCP & 0.11375 & 0.05814 & 0.14711 & 153.02\% \\
EnvExp & 0.16774 & 0.10902 & 0.20297 & 86.18\% \\
EnvProv & 0.08972 & 0.04083 & 0.11906 & 191.61\% \\
CO2S3 & 0.13229 & 0.02050 & 0.19937 & 872.33\% \\
CoffCre & 0.02412 & 0.00274 & 0.03694 & 1246.67\% \\
ENVRDExp & 0.04883 & 0.04708 & 0.04987 & 5.92\% \\
EnUTot & 0.30960 & 0.18363 & 0.38519 & 109.76\% \\
IndEnU & 0.01168 & 0.01225 & 0.01134 & -7.42\% \\
WWTot & 0.30248 & 0.23085 & 0.34545 & 49.65\% \\
FWWTot & 0.16238 & 0.06121 & 0.22309 & 264.49\% \\
WatRec & 0.05536 & 0.02169 & 0.07556 & 248.41\% \\ \hline
\end{longtable}
\end{footnotesize}
\end{document}
当我尝试在文档中编译这种类型的表格时,问题出现了,report
因为我必须生成一个表格列表并在列表中。
\documentclass[11 pt,twoside]{report}
\usepackage{longtable,array}
\usepackage[justification=centering]{caption}
\usepackage{cellspace}
\usepackage{booktabs}
\usepackage{varwidth}
\usepackage[a4paper,margin=25mm]{geometry}
\usepackage{multirow}
\usepackage{multicol}
\setlength{\parskip}{\baselineskip}
\setlength{\tabcolsep}{4pt}
\setlength\cellspacetoplimit{5pt}
\setlength\cellspacebottomlimit{5pt}
\newenvironment{outdent}
{\begin{list}{}{\leftmargin-0cm\rightmargin\leftmargin}\centering\item\relax}
{\end{list}\ignorespacesafterend}
\begin{document}
\listoftables
\begin{footnotesize}
\begin{longtable}{m{3cm}m{3cm}@{}m{3cm}@{}m{3cm}@{}m{2.1cm}@{}}
\caption{Binary ESG Variables \newline \smallskip \newline \footnotesize This table shows the means of the binary ESG variables for the full period (2002-2017) and for two subperiods (2002-2007 and 2008-2017), the growth rate from one subperiod to the other and the overall mean for all of them in the last row.}
\label{descbin}\\
\toprule
Variable & Mean (2002-2017) & Mean (2002-2007) & Mean (2008-2017) & Mean Growth \\
\hline
\midrule[\heavyrulewidth] % make this rule as thick as \toprule
\endfirsthead
\toprule
\multicolumn{5}{l}{\small\sl continued from previous page}\\ \hline
Variable & Mean (2002-2017) & Mean (2002-2007) & Mean (2008-2017) & Mean Growth \\
\hline
\midrule[\heavyrulewidth] % make this rule as thick as \toprule
\endhead
\bottomrule
\multicolumn{5}{r}{\small\sl continued on next page} \\ \hline
\endfoot
\bottomrule
\endlastfoot
\hline \multicolumn{5}{|c|}{Panel A: Environmental variables} \\
\hline CO2EmT & 0.38992 & 0.27250 & 0.46037 & 68.95\% \\
CO2DirEm & 0.28134 & 0.15358 & 0.35800 & 133.11\% \\
CO2IndEm & 0.25803 & 0.10909 & 0.34739 & 218.44\% \\
FlaNG & 0.00729 & 0.00616 & 0.00796 & 29.28\% \\
OzDepSub & 0.03486 & 0.02730 & 0.03939 & 44.32\% \\
NOxEm & 0.14152 & 0.12901 & 0.14902 & 15.51\% \\
SOxEm & 0.13392 & 0.11698 & 0.14409 & 23.18\% \\
VOCEm & 0.07476 & 0.06650 & 0.07972 & 19.88\% \\
WasTot & 0.25446 & 0.18339 & 0.29710 & 62.00\% \\
NhazWas & 0.12237 & 0.07164 & 0.15280 & 113.30\% \\
WasRecT & 0.19662 & 0.12476 & 0.23973 & 92.15\% \\
HazWas & 0.13412 & 0.09565 & 0.15720 & 64.34\% \\
WatDis & 0.07482 & 0.05188 & 0.08858 & 70.72\% \\
WatPolEm & 0.06320 & 0.04405 & 0.07470 & 69.57\% \\
ISOEMSCP & 0.11375 & 0.05814 & 0.14711 & 153.02\% \\
EnvExp & 0.16774 & 0.10902 & 0.20297 & 86.18\% \\
EnvProv & 0.08972 & 0.04083 & 0.11906 & 191.61\% \\
CO2S3 & 0.13229 & 0.02050 & 0.19937 & 872.33\% \\
CoffCre & 0.02412 & 0.00274 & 0.03694 & 1246.67\% \\
ENVRDExp & 0.04883 & 0.04708 & 0.04987 & 5.92\% \\
EnUTot & 0.30960 & 0.18363 & 0.38519 & 109.76\% \\
IndEnU & 0.01168 & 0.01225 & 0.01134 & -7.42\% \\
WWTot & 0.30248 & 0.23085 & 0.34545 & 49.65\% \\
FWWTot & 0.16238 & 0.06121 & 0.22309 & 264.49\% \\
WatRec & 0.05536 & 0.02169 & 0.07556 & 248.41\% \\ \hline
\end{longtable}
\end{footnotesize}
\end{document}
出现以下内容:
1.2 二元 ESG 变量 下表显示了整个时期(2002-2017 年)和两个子时期(2002-2007 年和 2008-2017 年)的二元 ESG 变量的平均值、从一个子时期到另一个子时期的增长率以及最后一行中所有变量的总体平均值。 . . . . . . . . . . . . . 14
我怎样才能让表格具有标题和说明文字,但只显示标题?
答案1
您可以使用 caption 命令的可选参数来仅在表格列表中显示简短的标题:
\caption[<short caption for the lot>]{<long caption used with the table>}
或者使用\caption*
描述性文本的命令:
\caption{<Short caption>}
\label{descbin}\\
\caption*{\footnotesize <descriptive text>}\\
下面是完整的 MWE,演示了后一种变体的使用:
\documentclass[11 pt,twoside]{report}
\usepackage{longtable,array}
\usepackage[justification=centering]{caption}
\usepackage{cellspace}
\usepackage{booktabs}
\usepackage{varwidth}
\usepackage[a4paper,margin=25mm]{geometry}
\usepackage{multirow}
\usepackage{multicol}
\setlength{\parskip}{\baselineskip}
\setlength{\tabcolsep}{4pt}
\setlength\cellspacetoplimit{5pt}
\setlength\cellspacebottomlimit{5pt}
\newenvironment{outdent}
{\begin{list}{}{\leftmargin-0cm\rightmargin\leftmargin}\centering\item\relax}
{\end{list}\ignorespacesafterend}
\begin{document}
\listoftables
\begin{footnotesize}
\begin{longtable}{m{3cm}m{3cm}@{}m{3cm}@{}m{3cm}@{}m{2.1cm}@{}}
\caption{Binary ESG Variables}
\label{descbin}\\
\caption*{\footnotesize This table shows the means of the binary ESG variables for the full period (2002-2017) and for two subperiods (2002-2007 and 2008-2017), the growth rate from one subperiod to the other and the overall mean for all of them in the last row.}\\
\toprule
Variable & Mean (2002-2017) & Mean (2002-2007) & Mean (2008-2017) & Mean Growth \\
\hline
\midrule[\heavyrulewidth] % make this rule as thick as \toprule
\endfirsthead
\toprule
\multicolumn{5}{l}{\small\sl continued from previous page}\\ \hline
Variable & Mean (2002-2017) & Mean (2002-2007) & Mean (2008-2017) & Mean Growth \\
\hline
\midrule[\heavyrulewidth] % make this rule as thick as \toprule
\endhead
\bottomrule
\multicolumn{5}{r}{\small\sl continued on next page} \\ \hline
\endfoot
\bottomrule
\endlastfoot
\hline \multicolumn{5}{|c|}{Panel A: Environmental variables} \\
\hline CO2EmT & 0.38992 & 0.27250 & 0.46037 & 68.95\% \\
CO2DirEm & 0.28134 & 0.15358 & 0.35800 & 133.11\% \\
CO2IndEm & 0.25803 & 0.10909 & 0.34739 & 218.44\% \\
FlaNG & 0.00729 & 0.00616 & 0.00796 & 29.28\% \\
OzDepSub & 0.03486 & 0.02730 & 0.03939 & 44.32\% \\
NOxEm & 0.14152 & 0.12901 & 0.14902 & 15.51\% \\
SOxEm & 0.13392 & 0.11698 & 0.14409 & 23.18\% \\
VOCEm & 0.07476 & 0.06650 & 0.07972 & 19.88\% \\
WasTot & 0.25446 & 0.18339 & 0.29710 & 62.00\% \\
NhazWas & 0.12237 & 0.07164 & 0.15280 & 113.30\% \\
WasRecT & 0.19662 & 0.12476 & 0.23973 & 92.15\% \\
HazWas & 0.13412 & 0.09565 & 0.15720 & 64.34\% \\
WatDis & 0.07482 & 0.05188 & 0.08858 & 70.72\% \\
WatPolEm & 0.06320 & 0.04405 & 0.07470 & 69.57\% \\
ISOEMSCP & 0.11375 & 0.05814 & 0.14711 & 153.02\% \\
EnvExp & 0.16774 & 0.10902 & 0.20297 & 86.18\% \\
EnvProv & 0.08972 & 0.04083 & 0.11906 & 191.61\% \\
CO2S3 & 0.13229 & 0.02050 & 0.19937 & 872.33\% \\
CoffCre & 0.02412 & 0.00274 & 0.03694 & 1246.67\% \\
ENVRDExp & 0.04883 & 0.04708 & 0.04987 & 5.92\% \\
EnUTot & 0.30960 & 0.18363 & 0.38519 & 109.76\% \\
IndEnU & 0.01168 & 0.01225 & 0.01134 & -7.42\% \\
WWTot & 0.30248 & 0.23085 & 0.34545 & 49.65\% \\
FWWTot & 0.16238 & 0.06121 & 0.22309 & 264.49\% \\
WatRec & 0.05536 & 0.02169 & 0.07556 & 248.41\% \\ \hline
\end{longtable}
\end{footnotesize}
\end{document}
除此之外,我还建议使用l
、c
和r
type 列(正如 Red-Cloud 也展示的那样在他们的回答中) 使用这些列类型,表格中的空白会更少,最后一列的对齐方式会更加美观。为了进一步提高可读性,您还可以删除%
最后一列中的所有出现,而是将此信息添加到列标题中。
答案2
请尝试以下操作。不过,我修改了您的表格,使其具有正常字体大小:
\documentclass{report}
\usepackage{libertinus}
\usepackage[svgnames,table,cmyk]{xcolor}
\usepackage{longtable,booktabs}
\begin{document}
\begingroup
\let\NumberLine\numberline
\def\numberline#1{\NumberLine{}}
\listoftables
\endgroup
\chapter{foo}
\section{Blah blah}
\begin{longtable}{ @{} l c c c r @{}}
\caption{Binary ESG Variables \newline \smallskip \newline \footnotesize This table shows the means of the
binary ESG variables for the full period (2002-2017) and for two subperiods (2002-2007 and 2008-2017), the
growth rate from one subperiod to the other and the overall mean for all of them in the last row.}
\label{descbin}\\ \toprule
Variable & Mean & Mean & Mean & Mean \\
& (2002-2017) & (2002-2007) & (2008-2017) & Growth \\
\hline
\midrule[\heavyrulewidth] % make this rule as thick as \toprule
\endfirsthead
\toprule
\multicolumn{5}{l}{\small\sl continued from previous page}\\ \hline
Variable & Mean & Mean & Mean & Mean \\
& (2002-2017) & (2002-2007) & (2008-2017) & Growth \\
\hline
\midrule[\heavyrulewidth] % make this rule as thick as \toprule
\endhead
\bottomrule
\multicolumn{5}{r}{\small\sl continued on next page} \\ \hline
\endfoot
\bottomrule
\endlastfoot
\hline \multicolumn{5}{|c|}{Panel A: Environmental variables} \\
\hline CO2EmT & 0.38992 & 0.27250 & 0.46037 & 68.95\% \\
CO2DirEm & 0.28134 & 0.15358 & 0.35800 & 133.11\% \\
CO2IndEm & 0.25803 & 0.10909 & 0.34739 & 218.44\% \\
FlaNG & 0.00729 & 0.00616 & 0.00796 & 29.28\% \\
OzDepSub & 0.03486 & 0.02730 & 0.03939 & 44.32\% \\
NOxEm & 0.14152 & 0.12901 & 0.14902 & 15.51\% \\
SOxEm & 0.13392 & 0.11698 & 0.14409 & 23.18\% \\
VOCEm & 0.07476 & 0.06650 & 0.07972 & 19.88\% \\
WasTot & 0.25446 & 0.18339 & 0.29710 & 62.00\% \\
NhazWas & 0.12237 & 0.07164 & 0.15280 & 113.30\% \\
WasRecT & 0.19662 & 0.12476 & 0.23973 & 92.15\% \\
HazWas & 0.13412 & 0.09565 & 0.15720 & 64.34\% \\
WatDis & 0.07482 & 0.05188 & 0.08858 & 70.72\% \\
WatPolEm & 0.06320 & 0.04405 & 0.07470 & 69.57\% \\
ISOEMSCP & 0.11375 & 0.05814 & 0.14711 & 153.02\% \\
EnvExp & 0.16774 & 0.10902 & 0.20297 & 86.18\% \\
EnvProv & 0.08972 & 0.04083 & 0.11906 & 191.61\% \\
CO2S3 & 0.13229 & 0.02050 & 0.19937 & 872.33\% \\
CoffCre & 0.02412 & 0.00274 & 0.03694 & 1246.67\% \\
ENVRDExp & 0.04883 & 0.04708 & 0.04987 & 5.92\% \\
EnUTot & 0.30960 & 0.18363 & 0.38519 & 109.76\% \\
IndEnU & 0.01168 & 0.01225 & 0.01134 & -7.42\% \\
WWTot & 0.30248 & 0.23085 & 0.34545 & 49.65\% \\
FWWTot & 0.16238 & 0.06121 & 0.22309 & 264.49\% \\
WatRec & 0.05536 & 0.02169 & 0.07556 & 248.41\% \\ \hline
\end{longtable}
\end{document}