使用 KOMA 脚本正确地将 threeparttable 旁边的标题顶部对齐

使用 KOMA 脚本正确地将 threeparttable 旁边的标题顶部对齐

没有 ,事情看起来也很好threeparttable

不带三部分表

取消注释 threeparttable 和 tablenotes 会导致标题上升到上一段。

使用 threeparttable

\documentclass{scrbook}                                                                                                                               
%                                                                                                                                                     
\usepackage[english]{babel}                                                                                                                           
\usepackage{caption}                                                                                                                                  
\usepackage{threeparttable}                                                                                                                           
\usepackage{lipsum}                                                                                                                                   
%                                                                                                                                                     
\KOMAoptions{captions=topbeside}                                                                                                                      
\setcapindent*{0pt}%                                                                                                                                  
\begin{document}                                                                                                                                      

\chapter{Crapper}                                                                                                                                     

\lipsum[1]                                                                                                                                            

\begin{table}[h]%                                                                                                                                     
  \label{tab:psource:final-params}%                                                                                                                   
  \begin{captionbeside}{This is the captions which should be top aligned}[l]%                                                            
      \raisebox{\dimexpr0.5\baselineskip-0.5\totalheight\relax}{%                                                                                     
      %\begin{threeparttable}                                                                                                                         
        \begin{tabular}{cccc}                                                                                                                         
          \hline                                                                                                                                      
          Test & Test & Test & Test \\                                                                                                                
          Test & Test & Test & Test\tnote{1} \\                                                                                                       
          Test & Test & Test & Test \\                                                                                                                
          Test & Test & Test & Test \\                                                                                                                
          Test & Test & Test & Test\tnote{2} \\                                                                                                       
          \hline                                                                                                                                      
        \end{tabular}                                                                                                                                 
      %  \begin{tablenotes}                                                                                                                           
      %    \item[1]{Test note}                                                                                                                        
      %    \item[2]{Test note}                                                                                                                        
      %    \end{tablenotes}                                                                                                                           
      %\end{threeparttable}%                                                                                                                          
  }%                                                                                                                                                  
  \end{captionbeside}                                                                                                                                 
\end{table}                                                                                                                                           

\end{document}                                                                                                                                        

答案1

不需要;在的可选参数中\raisebox使用(顶部对齐) ,并且(从ttabular\firsthlinearray包)而不是第一个\hline

\documentclass{scrbook}                                                                                                                               
%                                                                                                                                                     
\usepackage[english]{babel}                                                                                                                           
\usepackage{caption}                                                                                                                                  
\usepackage{threeparttable,array}                                                                                                                           
\usepackage{lipsum}                                                                                                                                   
%                                                                                                                                                     
\KOMAoptions{captions=topbeside}                                                                                                                      
\setcapindent*{0pt}%                                                                                                                                  

\begin{document}                                                                                                                                      

\chapter{Test}                                                                                                                                     

\lipsum[1]                                                                                                                                            
\begin{table}%                                                                                                                                     
  \label{tab:psource:final-params}%                                                                                                                   
  \begin{captionbeside}{This is the caption which is now top aligned}[l]%                                                            
      \begin{threeparttable}
        \begin{tabular}[t]{cccc}                                                                                                                         
          \firsthline                                                                                                                                      
          Test & Test & Test & Test \\                                                                                                                
          Test & Test & Test & Test\tnote{1} \\                                                                                                       
          Test & Test & Test & Test \\                                                                                                                
          Test & Test & Test & Test \\                                                                                                                
          Test & Test & Test & Test\tnote{2} \\                                                                                                       
          \hline                                                                                                                                      
        \end{tabular}                                                                                                                                 
        \begin{tablenotes}                                                                                                                           
          \item[1]{Test note}                                                                                                                        
          \item[2]{Test note}                                                                                                                        
          \end{tablenotes}                                                                                                                           
      \end{threeparttable}%                                                                                                                          
  \end{captionbeside}                                                                                                                                 
\end{table}                                                                                                                                           

\end{document} 

在此处输入图片描述

如果您决定将该booktabs包用于您的表格(我建议这样做),那么就需要做一些额外的工作:在下面的例子中,我定义了一个混合了和\firsttoprule功能的命令:\firsthline\toprule

\documentclass{scrbook}                                                                                                                               
%                                                                                                                                                     
\usepackage[english]{babel}                                                                                                                           
\usepackage{caption}                                                                                                                                  
\usepackage{threeparttable,array,booktabs}                                                                                                                           
\usepackage{lipsum}                                                                                                                                   
%                                                                                                                                                     
\KOMAoptions{captions=topbeside}                                                                                                                      
\setcapindent*{0pt}%                                                                                                                                  

\makeatletter
\newcommand\firsttoprule{%
  \multicolumn1c{%
    \global\backup@length\ht\@arstrutbox
    \global\advance\backup@length\dp\@arstrutbox
    \global\advance\backup@length\arrayrulewidth
     \raise\extratabsurround\copy\@arstrutbox
    }\\[-\backup@length]\toprule
}
\makeatother


\begin{document}                                                                                                                                      

\chapter{Test}

\lipsum[1]                                                                                                                                            
\begin{table}[h]%                                                                                                                                     
  \label{tab:psource:final-params}%                                                                                                                   
  \begin{captionbeside}{This is the caption which is now top aligned}[l]%                                                            
      \begin{threeparttable}[t]                                                                                                                    
        \begin{tabular}[t]{cccc}                                                                                                                         
          \firsttoprule                                                                                                                                      
          Test & Test & Test & Test \\                                                                                                                
          Test & Test & Test & Test\tnote{1} \\                                                                                                       
          Test & Test & Test & Test \\                                                                                                                
          Test & Test & Test & Test \\                                                                                                                
          Test & Test & Test & Test\tnote{2} \\                                                                                                       
          \bottomrule                                                                                                                                     
        \end{tabular}                                                                                                                                 
        \begin{tablenotes}                                                                                                                           
          \item[1]{Test note}                                                                                                                        
          \item[2]{Test note}                                                                                                                        
          \end{tablenotes}                                                                                                                           
      \end{threeparttable}%                                                                                                                          
  \end{captionbeside}                                                                                                                                 
\end{table}                                                                                                                                           

\end{document}                 

在此处输入图片描述

相关内容