表格注释与文本宽度不对齐

表格注释与文本宽度不对齐

我遇到了以下问题。我使用 threeparttable 和 tablenotes 来做笔记。不幸的是,笔记与文本宽度不对齐:

请注意,下面的表格超出了页面范围

我该如何修复这个问题?

\documentclass[a4paper, 12pt, twoside = false,        
    BCOR=10mm, toc=bibliography, listof=totoc]{scrartcl}
\usepackage[left=3cm,right=3.5cm,top=2.5cm,bottom=2.75cm]{geometry} 
\usepackage{multirow}
\usepackage[hang]{footmisc}
\usepackage{float}
\usepackage{lipsum}
\usepackage{placeins}
\usepackage{threeparttable}
\usepackage{multicol}
\usepackage{subcaption}
\usepackage{booktabs}
\usepackage{adjustbox}
\usepackage{tabularx}
\usepackage{amsmath}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[english]{babel}
\usepackage{graphicx}
\usepackage{caption}
\usepackage{subcaption}
\begin{document}
\begin{table}[H]
    \centering
    \caption{Caption}
        \begin{threeparttable}
            \begin{adjustbox}{width=1\textwidth}
            \begin{tabular}{@{}lccccccccccc@{}}
                \toprule
                & $\alpha=0$ & $\alpha=1.05$ & $\alpha=1.10$ & $\alpha=1.15$ & $\alpha=1.20$ & $\alpha=1.25$ & $\alpha=1.30$ & $\alpha=1.35$ & $\alpha=1.40$ & $\alpha=1.45$ & $\alpha=1.50$  \\ 
                \midrule
                $\mathcal{AA}$  & 0 &0.239& 0.262 &0.379 &0.423 &0.552 &0.591 &0.623 &3.338& 0.127& 0.4339 \\
                $\mathcal{BB}$ & 10 &  33.4 &23.0& 1.5& 2.0 &2.2& 24.8& 26.33 &26.38 &12.63& 8.5 \\
                \bottomrule
            \end{tabular}
                \end{adjustbox}
            \begin{tablenotes}[para, flushleft]
                \footnotesize \emph{Note:} \lipsum[1]           
        \end{tablenotes}
        \end{threeparttable}
\end{table}
\end{document}

答案1

避免重复信息:所有那些无用的信息\alpha=都是导致问题的主要根源。

通过显示第一列中的窄条目,表格可以适合文本宽度。

您可能希望根据第一列的宽度设置\small或。但是\footnotesize绝不比例表。

\documentclass[
  a4paper,
  12pt,
  twoside = false,        
  BCOR=10mm,
  toc=bibliography,
  listof=totoc,
  captions=tableheading,
]{scrartcl}
\usepackage[left=3cm,right=3.5cm,top=2.5cm,bottom=2.75cm]{geometry} 
\usepackage[T1]{fontenc}

\usepackage{threeparttable}
\usepackage{array}
\usepackage{booktabs}
\usepackage{amsmath}
\usepackage{caption}
\captionsetup[table]{position=top}

\usepackage{lipsum}

\begin{document}
\begin{table}[htp]

\setlength{\tabcolsep}{0pt}

\begin{threeparttable}
\caption{Caption}

\begin{tabular*}{\textwidth}{@{\extracolsep{\fill}}l*{11}{>{$}c<{$}}}
\toprule
& \multicolumn{11}{c}{Values of $\alpha$} \\
\cmidrule{2-12}
& 0 & 1.05 & 1.10 & 1.15 & 1.20 & 1.25 & 1.30 & 1.35 & 1.40 & 1.45 & 1.50  \\ 
\midrule
$\mathcal{AA}$  & 0 &0.239& 0.262 &0.379 &0.423 &0.552 &0.591 &0.623 &3.338& 0.127& 0.4339 \\
$\mathcal{BB}$ & 10 &  33.4 &23.0& 1.5& 2.0 &2.2& 24.8& 26.33 &26.38 &12.63& 8.5 \\
\bottomrule
\end{tabular*}

\begin{tablenotes}[para, flushleft]
\footnotesize \emph{Note:} \lipsum[1]           
\end{tablenotes}
\end{threeparttable}

\end{table}

\end{document}

请注意该caption=tableheadings选项,以便标题与表格有适当的间距。

在此处输入图片描述

答案2

不确定为什么会发生这种情况(很明显,threeparttable在缩放之前可以看到原始宽度)。可以将表格保存在一个框中并使用它:

\documentclass[a4paper]{scrartcl}
\usepackage{lipsum}
\usepackage{threeparttable}
\usepackage{booktabs}
\usepackage{adjustbox}
\usepackage{tabularx}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[english]{babel}
\newsavebox{\test}
\begin{document}
\begin{table}
    \centering
    \caption{Caption}
    \begin{lrbox}{\test}
          \begin{adjustbox}{width=1\textwidth}
            \begin{tabular}{@{}lccccccccccc@{}}
                \toprule
                & $\alpha=0$ & $\alpha=1.05$ & $\alpha=1.10$ & $\alpha=1.15$ & $\alpha=1.20$ & $\alpha=1.25$ & $\alpha=1.30$ & $\alpha=1.35$ & $\alpha=1.40$ & $\alpha=1.45$ & $\alpha=1.50$  \\ 
                \midrule
                $\mathcal{AA}$  & 0 &0.239& 0.262 &0.379 &0.423 &0.552 &0.591 &0.623 &3.338& 0.127& 0.4339 \\
                $\mathcal{BB}$ & 10 &  33.4 &23.0& 1.5& 2.0 &2.2& 24.8& 26.33 &26.38 &12.63& 8.5 \\
                \bottomrule
            \end{tabular}
          \end{adjustbox}
          \end{lrbox}
          \begin{threeparttable}
            \usebox{\test}
            \begin{tablenotes}[para, flushleft]
                \footnotesize \emph{Note:} \lipsum[1]           
        \end{tablenotes}
        \end{threeparttable}
\end{table}
\end{document}

(我删除了很多与问题不相关的包)

答案3

不建议缩放表格。 在你的情况下,表格变得难以阅读。 为什么不旋转这么宽的表格:

\documentclass[a4paper,% not needed, because default
12pt,
twoside = false,% not needed, because default
%BCOR=10mm,% Does not make sense, because overwritten by geometry
toc=bibliography, listof=totoc]{scrartcl}
\usepackage[left=3cm,right=3.5cm,top=2.5cm,bottom=2.75cm]{geometry}
\usepackage{lipsum}
\usepackage{float}
\usepackage{threeparttable}
\usepackage{booktabs}
\usepackage{amsmath}
\usepackage[utf8]{inputenc}% not needed since LaTeX 2018/04/01
\usepackage[T1]{fontenc}
\usepackage[english]{babel}
\usepackage{caption}
\usepackage{siunitx}
\usepackage{pdflscape}
\usepackage{scrhack}
\usepackage{showframe}% visualize the text area
\begin{document}
\begin{landscape}
\begin{table}[H]
    \caption{Caption}
    \centering
    \begin{threeparttable}
            \begin{tabular}{@{}lS[table-format=2.0]*{9}{S[table-format=2.3]}S[table-format=1.4]@{}}
                \toprule
                & {$\alpha=0$} & {$\alpha=1.05$} & {$\alpha=1.10$} & {$\alpha=1.15$} & {$\alpha=1.20$} & {$\alpha=1.25$} & {$\alpha=1.30$} & {$\alpha=1.35$} & {$\alpha=1.40$} & {$\alpha=1.45$} & {$\alpha=1.50$} \\ 
                \midrule
                $\mathcal{AA}$  & 0 &0.239& 0.262 &0.379 &0.423 &0.552 &0.591 &0.623 &3.338& 0.127& 0.4339 \\
                $\mathcal{BB}$ & 10 &  33.4 &23.0& 1.5& 2.0 &2.2& 24.8& 26.33 &26.38 &12.63& 8.5 \\
                \bottomrule
            \end{tabular}
            \begin{tablenotes}[para, flushleft]
                \footnotesize \emph{Note:} \lipsum[1]           
        \end{tablenotes}
        \end{threeparttable}
\end{table}
\end{landscape}
\end{document}

使用景观表

或者至少通过α =从所有列中删除并在第一列仅添加一次来减少表格标题的宽度:

\documentclass[a4paper,% not needed, because default
12pt,
twoside = false,% not needed, because default
%BCOR=10mm,% Does not make sense, because overwritten by geometry
toc=bibliography, listof=totoc]{scrartcl}
\usepackage[left=3cm,right=3.5cm,top=2.5cm,bottom=2.75cm]{geometry}
\usepackage{lipsum}
\usepackage{float}
\usepackage{threeparttable}
\usepackage{booktabs}
\usepackage{amsmath}
\usepackage[utf8]{inputenc}% not needed since LaTeX 2018/04/01
\usepackage[T1]{fontenc}
\usepackage[english]{babel}
\usepackage{caption}
\usepackage{siunitx}
\usepackage{showframe}% visualize the text area
\begin{document}
\begin{table}[H]
    \caption{Caption}
    \centering
    \begin{threeparttable}
      \scriptsize
            \begin{tabular}{@{}lS[table-format=2.0]*{9}{S[table-format=2.3]}S[table-format=1.4]@{}}
                \toprule
                $\alpha =$  & 0 & 1.05 & 1.10 & 1.15 & 1.20 & 1.25 & 1.30 & 1.35 & 1.40 & 1.45 & 1.50  \\ 
                \midrule
                $\mathcal{AA}$  & 0 &0.239& 0.262 &0.379 &0.423 &0.552 &0.591 &0.623 &3.338& 0.127& 0.4339 \\
                $\mathcal{BB}$ & 10 &  33.4 &23.0& 1.5& 2.0 &2.2& 24.8& 26.33 &26.38 &12.63& 8.5 \\
                \bottomrule
            \end{tabular}
            \begin{tablenotes}[para, flushleft]
                \footnotesize \emph{Note:} \lipsum[1]           
        \end{tablenotes}
        \end{threeparttable}
\end{table}
\end{document}

肖像

答案4

我将使用talltblrtabularray,减少列分隔,并在最后一列将十进制数四舍五入为三位数,并重新组织列标题:

\documentclass{scrartcl}
\usepackage[hmargin={3cm,3.5cm}, vmargin={2.5cm,2.75cm}]{geometry}
%--------------- show page layout. don't use in a real document!
\usepackage{showframe}
\renewcommand\ShowFrameLinethickness{0.15pt}
\renewcommand*\ShowFrameColor{\color{red}}
%
\usepackage{lipsum}             % for dummy text
%---------------------------------------------------------------%

\usepackage[T1]{fontenc}
\usepackage[english]{babel}

\usepackage{ragged2e}
\usepackage{tabularray}
\UseTblrLibrary{amsmath, booktabs, siunitx}


\begin{document}
    \begin{table}[htb]
    \SetTblrStyle{note}{font=\footnotesize\RaggedRight}
\begin{talltblr}[
caption = {Caption},
  label = {tlltblr},
remark{Note} = {\lipsum[66]}
                ]{colsep  = 3pt,
                  colspec = {@{}   Q[l, mode=math]
                                   Q[c, si={table-format=2.0}]
                              *{9}{X[c, si={table-format=2.3}]}
                                   X[c, si={table-format=1.4}]
                              @{}},
                  row{1}  = {guard, mode=math}
                  } 
%
    \toprule
\SetCell[r=2]{}
                & \SetCell[c=11]{c} \alpha
                                &               &               &               &       
                &               &               &               &               &               &               \\
    \midrule
                & 0      & 1.05   & 1.10   & 1.15   & 1.20
                & 1.25   & 1.30   & 1.35   & 1.40   & 1.45   & 1.50   \\
    \midrule
\mathcal{AA}    &  0            &  0.239        &  0.262        &  0.379        &  0.423         
                &  0.552        &  0.591        &  0.623        &  3.338        &  0.127    & 0.4339            \\
\mathcal{BB}    & 10            & 33.4          & 23.0          &  1.5          &  2.0 
                &  2.2          & 24.8          & 26.33         & 26.38         & 12.63     & 8.5               \\
    \bottomrule
\end{talltblr}
    \end{table}
\end{document}

在此处输入图片描述

相关内容