如何防止表格中的一半间距?

如何防止表格中的一半间距?

我已经用书签和往常一样。然后我不得不在其中一个表格中添加一些注释,所以我尝试了 TSX 上讨论的所有解决方案,其中ctabs三部分表看起来可行。然后我改用规定的 1.5 间距。

Booktabs 表没有改变,但两个具有注释支持的环境都发生了改变。

我该如何防止行距发生这种变化?

设置 onehalfspacing 后的不同表格环境

\documentclass[fontsize=12pt]{scrreprt}
  \KOMAoption{captions}{tableheading}
  \usepackage[onehalfspacing]{setspace} 
  \addtokomafont{caption}{\small}
  \addtokomafont{captionlabel}{\bfseries}

\usepackage{tikz}
\usepackage{libertine}
\usepackage{booktabs}
\usepackage{longtable}
\usepackage{ctable}
\usepackage[referable]{threeparttablex}
\setTableNoteFont{\footnotesize}

\begin{document}

\ctable[caption=ctable]{lll}
{
    \tnote[†]{Groucho}
    \tnote[‡]{Harpo}
    \tnote[§]{Zeppo}
}
{                                                   \FL
    One\tmark[†]& Two           & Three             \ML
    foo         & bar\tmark[‡]  & baz               \NN
    alpha       & beta          & gamma\tmark[§]    \LL
}

\begin{table}
  \caption{booktabs}
  \begin{center}
    \begin{tabular}{lll}
  \toprule
    One     & Two   & Three \\
  \midrule
    foo     & bar   & baz   \\
    alpha   & beta  & gamma \\
  \bottomrule
    \end{tabular}
  \end{center}
\end{table}


\begin{ThreePartTable}
    \begin{TableNotes}
        \item[†] \label{tn:groucho} Groucho
        \item[‡] \label{tn:harpo} Harpo
        \item[§] \label{tn:zeppo} Zeppo
    \end{TableNotes}
    \begin{longtable}{l l l}
        \caption{ThreePartTable}\\
        \toprule
            One\tnotex{tn:groucho}  & Two   & Three \\
        \midrule
        \endhead
        \endfoot
        \bottomrule
        \insertTableNotes
        \endlastfoot
            foo     & bar\tnotex{tn:harpo}  & baz                       \\
            alpha   & beta                  & gamma\tnotex{tn:zeppo}    \\
    \end{longtable}
\end{ThreePartTable}

\end{document}

答案1

只需将您的表嵌套在singlespacing环境中:

\documentclass[fontsize=12pt]{scrreprt}
  \KOMAoption{captions}{tableheading}
  \usepackage[onehalfspacing]{setspace}
  \addtokomafont{caption}{\small}
  \addtokomafont{captionlabel}{\bfseries}

\usepackage{tikz}
\usepackage{libertine}
\usepackage{booktabs}
\usepackage{longtable}
\usepackage{ctable}
\usepackage[referable]{threeparttablex}
\setTableNoteFont{\footnotesize}
\usepackage{lipsum} 

\begin{document}


\lipsum[1]

\begin{singlespacing}
\ctable[caption=ctable, pos = htb]{lll}
{
    \tnote[†]{Groucho}
    \tnote[‡]{Harpo}
    \tnote[§]{Chico}
}
{ \FL
    One\tmark[†]& Two & Three \ML
    foo & bar\tmark[‡] & baz \NN
    alpha & beta & gamma\tmark[§] \LL
}

\begin{table}[!htb]
  \caption{booktabs}
  \begin{center}
    \begin{tabular}{lll}
  \toprule
    One & Two & Three \\
  \midrule
    foo & bar & baz \\
    alpha & beta & gamma \\
  \bottomrule
    \end{tabular}
  \end{center}
\end{table}


\begin{ThreePartTable}
    \begin{TableNotes}
        \item[†] \label{tn:groucho} Groucho
        \item[‡] \label{tn:harpo} Harpo
        \item[§] \label{tn:chico} Chico
    \end{TableNotes}
    \begin{longtable}{l l l}
        \caption{ThreePartTable}\\
        \toprule
            One\tnotex{tn:groucho} & Two & Three \\
        \midrule
        \endhead
        \endfoot
        \bottomrule
        \insertTableNotes
        \endlastfoot
            foo & bar\tnotex{tn:harpo} & baz \\
            alpha & beta & gamma\tnotex{tn:chico} \\
    \end{longtable}
\end{ThreePartTable}
\end{singlespacing}

\lipsum[2]

\end{document} 

在此处输入图片描述

答案2

它并不是booktabs对行间空间做了什么,而是setspace修复了行间空间tablefigure使用单倍行距的环境。

您也可以修复\ctableThreePartTable来执行此操作。此外,您需要保存 的含义\tnotectable因为threeparttablex它会默默地重新定义它。

\documentclass[fontsize=12pt]{scrreprt}
  \KOMAoption{captions}{tableheading}
  \usepackage[onehalfspacing]{setspace} 
  \addtokomafont{caption}{\small}
  \addtokomafont{captionlabel}{\bfseries}

\usepackage{tikz}
\usepackage{libertine}
\usepackage{booktabs}
\usepackage{longtable}
\usepackage{letltxmacro}
\usepackage{ctable}
% threeparttablex redefines \tnote
\LetLtxMacro{\ctabletnote}{\tnote}
%%%
\usepackage[referable]{threeparttablex}

\usepackage{xpatch}

\setTableNoteFont{\footnotesize}

\makeatletter
\xpretocmd{\ctable}
  {\begingroup\def\baselinestretch{\setspace@singlespace}\selectfont}
  {}{}
\xapptocmd{\ctable}
  {\endgroup}
  {}{}
\xpretocmd{\ThreePartTable}
  {\def\baselinestretch{\setspace@singlespace}\selectfont}
  {}{}
\makeatother

\begin{document}

\ctable[caption=ctable]{lll}
{
    \ctabletnote[†]{Groucho}
    \ctabletnote[‡]{Harpo}
    \ctabletnote[§]{Zeppo}
}
{                                                   \FL
    One\tmark[†]& Two           & Three             \ML
    foo         & bar\tmark[‡]  & baz               \NN
    alpha       & beta          & gamma\tmark[§]    \LL
}


\begin{table}
  \caption{booktabs}
  \begin{center}
    \begin{tabular}{lll}
  \toprule
    One     & Two   & Three \\
  \midrule
    foo     & bar   & baz   \\
    alpha   & beta  & gamma \\
  \bottomrule
    \end{tabular}
  \end{center}
\end{table}


\begin{ThreePartTable}
    \begin{TableNotes}
        \item[†] \label{tn:groucho} Groucho
        \item[‡] \label{tn:harpo} Harpo
        \item[§] \label{tn:zeppo} Zeppo
    \end{TableNotes}
    \begin{longtable}{l l l}
        \caption{ThreePartTable}\\
        \toprule
            One\tnotex{tn:groucho}  & Two   & Three \\
        \midrule
        \endhead
        \endfoot
        \bottomrule
        \insertTableNotes
        \endlastfoot
            foo     & bar\tnotex{tn:harpo}  & baz                       \\
            alpha   & beta                  & gamma\tnotex{tn:zeppo}    \\
    \end{longtable}
\end{ThreePartTable}

\end{document}

在此处输入图片描述

相关内容