长桌和自动间距

长桌和自动间距

我将 longtable 环境与 siunitx 包结合使用,用于 10 列中的 3 列。不幸的是,编译时不会自动调整这三列的间距。使用 table-column-width 时,带有注释的顶行的间距不会相应调整。请查看我的代码(摘录)和下面的输出,首先不使用 table-column-width 命令,然后使用相应的命令。

\documentclass[11pt,a4paper,oneside]{article}
\usepackage{setspace} 
\onehalfspacing

\usepackage[round]{natbib}
\usepackage{array}
\usepackage{pdflscape}
\usepackage{longtable}
\usepackage[group-separator={.}]{siunitx}
\usepackage{booktabs,multirow} 
\renewcommand{\thetable}{\Roman{table}}

\usepackage[english]{babel}

\usepackage[margin=1in]{geometry}
\usepackage[small,bf,labelsep=period]{caption}

% -------------------------------------------------------------------
\begin{document}

\newpage
\begin{landscape}
{\small\begin{longtable}{lccccccS[table-format=2.4, table-column-width=60pt]S[table-format=1.4,  table-column-width=60pt]S[table-format=1.4,  table-column-width=60pt]}
\caption[Significant contributions]{Significant contributions} \label{tab:contributionscharacteristics} \\ 
\multicolumn{10}{p{.9\linewidth}}{Lorem ipsum dolor sit amet, consectetur adipiscing elit. In pharetra lobortis elit nec consectetur. Nulla accumsan lacus a diam varius, eget eleifend augue egestas. Nulla porttitor lacus turpis, in elementum tortor pellentesque sit amet. Mauris interdum ante ac velit fermentum, sed faucibus nisi elementum. Duis pretium lacinia nunc, quis maximus lectus facilisis id. Aliquam ornare dapibus risus, sed congue quam eleifend id. Donec vel fringilla lacus. Aenean blandit viverra quam, nec imperdiet ante volutpat ut. Mauris non dapibus eros. Suspendisse luctus feugiat tortor, quis consectetur metus facilisis vitae. Aenean imperdiet est sodales arcu ultrices lacinia. Duis nunc augue, egestas nec lacus ac, egestas porttitor nibh. Donec sed lorem sit amet ipsum vulputate consectetur in ut lorem. Nunc mattis luctus magna. } \\ 
\\
\hline
\rule{0pt}{3ex}  
 \multirow{2}{*} {{Author(s) and country of analysis}}&\multicolumn{2}{c} {{Sample}} & \multicolumn{2}{c} {{Event}} & \multirow{2}{*} {{Weighting}} & \multirow{2}{*} {{Type\textsuperscript{b}}} & \multicolumn{3}{c}{\hspace{15pt}{Key results}} \\
& \multicolumn{1}{c}{Period} & \multicolumn{1}{c}{Size} & \multicolumn{1}{c}{Window}\textsuperscript{a} & \multicolumn{1}{c}{Date}\textsuperscript{b} &  & & \multicolumn{1}{c}{BHAR}& \multicolumn{1}{c}{Alphas}& \multicolumn{1}{c}{CTAR}\\
\hline \\ [-2ex]
\endfirsthead
\multicolumn{10}{c}%
{\small{{\bfseries \tablename\ \thetable.{}} Significant contributions (continued)}} \\ [1ex]
\hline
\endhead
\hline \multicolumn{10}{r}{{Continued on next page}} \\
\endfoot
\endlastfoot
\cite{Loughran1997}, US & 1970-1989 & 234 & $[+1, +60]$ & Co&  EW & C &     0.3050\textsuperscript{1,2}* & & \\
& &300 &  &  & EW & S & -0.2400\textsuperscript{1,2}*** & & \\
\cite{Mitchell2000}, US & 1961-1993 & 1,029 & $[+1, +36]$ & Co & EW & S & -0.0840\textsuperscript{1}*** & -0.0900\textsuperscript{7}*** &  -0.0828\textsuperscript{4}*** \\
&  &  &  &  &  VW & S & -0.0530\textsuperscript{1}***& -0.0432\textsuperscript{7}*&   -0.0468\textsuperscript{4}***\\
&  & 1,039  &  &  &  EW & NC & 0.0640\textsuperscript{1}**& -0.0144\textsuperscript{7}*&  -0.0252\textsuperscript{4}\\
\hline
\end{longtable}
}
\end{landscape}

\end{document}

没有 table-column-width 命令 没有 table-column-width 命令

使用 table-column-width 命令时,可以看到上面带有描述的部分没有很好地对齐 使用 table-column-width 命令时,可以看到上面带有描述的部分没有很好地对齐

答案1

您必须将表格注释标记放在括号中,并将其添加到siunitx列宽计算中。

% arara: pdflatex    

\documentclass[11pt,a4paper,oneside]{article}
\usepackage[english]{babel}
\usepackage{setspace} 
\onehalfspacing
% not needed here... but you should prefer this over color
\usepackage{xcolor}
\usepackage{pdflscape}
\usepackage{longtable}
\usepackage[group-separator={,}]{siunitx}
% if you load booktabs, use it. See \toprule and so on...
% you have been loading the following two packages twice
\usepackage{booktabs,multirow} 
\renewcommand{\thetable}{\Roman{table}}
\usepackage[margin=1in]{geometry}
\usepackage[small,bf,labelsep=period]{caption}
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhf{}
\fancyhead[LE,RO]{\thepage}
\renewcommand{\headrulewidth}{0.2pt}
% just for demo
\usepackage{blindtext}
% should be the last package in most cases
\usepackage[pdftex,bookmarks,colorlinks]{hyperref}

\begin{document}
\begin{landscape}
    {\small\begin{longtable}{@{}lcS[table-format=3.3]ccllS[table-format=-1.4, table-space-text-post = $^{1,2***}$]S[table-format=-1.4, table-space-text-post = $^{7***}$]S[table-format=-1.4, table-space-text-post = $^{4***}$]@{}}
            \caption[Hello]{Hello} \label{tab:contributionscharacteristics}\\
            \multicolumn{10}{p{.98\linewidth}}{\blindtext} \\\addlinespace 
            \toprule
            %\rule{0pt}{3ex} % this is not needed with booktabs and you were inserting some unwanted white space in front of your first cell with this
            \multirow{2}{*}{Author(s) and country of analysis} & \multicolumn{2}{c}{Sample} & \multicolumn{2}{c}{Event} & \multirow{2}{*}{Weighting} & \multirow{2}{*}{Type\textsuperscript{b}} & \multicolumn{3}{c}{Key results} \\\cmidrule(lr){2-3}\cmidrule(lr){4-5}\cmidrule(lr){8-10}
            & Period & {Size} & Window\textsuperscript{a} & Date\textsuperscript{b} & & & {BHAR} & {Alphas} & {CTAR} \\
            \midrule
            \endfirsthead
            {\small{{\bfseries \tablename\ \thetable.{}} Significant contributions (continued)}} \\
            \toprule
            \endhead
            \bottomrule \multicolumn{10}{r}{Continued on next page} \\
            \endfoot
            \endlastfoot
            \cite{Loughran1997}, US & 1970--1989 & 234 & $[+1, +60]$ & Co&  EW & C &     0.3050{$^{1,2*}$} & & \\
            & &300 &  &  & EW & S & -0.2400{$^{1,2***}$} & & \\
            \cite{Mitchell2000}, US & 1961--1993 & 1,029 & $[+1, +36]$ & Co & EW & S & -0.0840{$^{1***}$} & -0.0900{$^{7***}$} &  -0.0828{$^{4***}$} \\
            &  &  &  &  &  VW & S & -0.0530{$^{1***}$} & -0.0432{$^{7*}$}&   -0.0468{$^{4***}$}\\
            &  & 1,039  &  &  &  EW & NC & 0.0640{$^{1**}$} & -0.0144{$^{7*}$}&  -0.0252{$^{4}$}\\
            \bottomrule
        \end{longtable}}
\end{landscape}
\end{document}

在此处输入图片描述

第一列和最后一列被拉长了一点。由于我不知道longtable最终结果会是什么样子,所以我没有对此进行调整。

相关内容