页面中的表格对齐方式奇怪

页面中的表格对齐方式奇怪

有人能帮我一下吗?告诉我为什么table:S1table:S3参见下图)不在页面中央,就像table:S2?我在这里画了个空白。这是

MWE 的最终结果

以下是我用来制作此文档的 MWE:

\documentclass{book}

% *****************************************************************************
%                                    Preamble
% *****************************************************************************

% Additional Packages
\usepackage[T1]{fontenc} % to deal with those pesky ASCII symbols!
\usepackage{siunitx} % use this package module for SI units
\usepackage{booktabs}
\usepackage{enumitem}
\usepackage{threeparttable}
\usepackage{lipsum}
\usepackage[version=4]{mhchem}

% *****************************************************************************
% *****************************************************************************
%                                 End of Preamble
% *****************************************************************************
% *****************************************************************************
\begin{document} % Fun time!


% --> Custom commands <--

\newcommand{\tn}[1]{\textsuperscript{#1}}
\newcommand{\TN}[1]{\makebox[0pt][l]{\tn{#1}}}

% -- End of custom commands --

% ==> Case in point <==

\section{My first fully compiled MWE in TeX!}   


    \lipsum[1] % Generating dummy text!


    \begin{threeparttable}[!htbp]
        \caption{Experimentally determined spectroscopic parameters of the detected rotamer of PG}
        \label{table:S1} % should go after \caption
        \centering
        \sisetup{table-align-text-post=false}
        \begin{tabular}{@{\extracolsep{\fill}} l S[table-format=4.1(2)] S[table-format=3.4(2)] S[table-format=3.4(2)] }
            \toprule
            & A \tnote{a} & B & C \\        
            \midrule
            \ce{^{13}C} (1)& 3075.3 (31)\tnote{b}& 733.2825 (30)& 697.0386 (27) \\ 
            \ce{^{13}C} (2)& 3086.3 (15) & 736.5933 (22)& 699.4114 (17) \\ 
            \ce{^{13}C} (4)& 3055.3 (22) & 736.9399 (26)& 698.2864 (24) \\ 
            \ce{^{13}C} (5)& 3064.7 (23) & 731.8158 (29)& 693.8030 (27) \\ 
            \ce{^{13}C} (6)& 3085.0 (27) & 728.5381 (35)& 692.0961 (30) \\ 
            \ce{^{13}C} (7)& 3052.6 (32) & 732.9437 (36)& 694.8316 (36) \\ 
            \ce{^{13}C} (8)& 3056.3 (35) & 737.5525 (40)& 699.6777 (51) \\ 
            \ce{^{15}N}    & 3042.1 (12) & 733.0221 (15)& 697.1036 (21) \\ 
            \bottomrule
        \end{tabular}
        \begin{tablenotes}[flushleft]\footnotesize
            \item[a] $A$, $B$, and $C$ are the rotational constants (in \si{MHz});
            $\chi_{aa}$, $\chi_{bb}$, and $\chi_{cc}$ are elements of the $^{14}$N nuclear quadrupole coupling tensor (in \si{MHz}).
            \item[b] Standard errors indicated in parentheses in units of the last digit.
        \end{tablenotes}
    \end{threeparttable} 

\begin{table}[!htbp]
    \centering
    \caption{Observed frequencies and residuals (in \si{MHz}) for the observed transitions of \ce{^{13}C} (\ce{C_{10}}) isotopic species of phenylglycinol.}
    \label{table:S2}
    \sisetup{table-align-text-post=false}
    \begin{tabular}{@{\hspace{\tabcolsep}\extracolsep{\fill}} cccccc S[table-format=5.4] S[table-format=1.4] }
        \toprule
{J\textasciiacute}         &
{K\textasciiacute$_{-1}$}  &
{K\textasciiacute$_{+1}$}  &
{J\textacutedbl}           &
{K\textacutedbl$_{-1}$}    &
{K\textacutedbl$_{+1} $}   &
{$ \nu_{obs} $}            &
{$ \nu_{obs} - \nu_{cal} $} \\  
        \midrule
        5   & 1 & 5 & 4 & 1 & 4 &  7084.9419    &  0.0170 \\
        5   & 0 & 5 & 4 & 0 & 4 &  7173.7289    &  0.0526 \\
        5   & 2 & 4 & 4 & 2 & 3 &  7182.1213    &  0.0253 \\
        5   & 1 & 4 & 4 & 1 & 3 &  7277.2026    & -0.0193 \\
        6   & 0 & 6 & 5 & 0 & 5 &  8603.3344    &  0.0928 \\
        6   & 2 & 5 & 5 & 2 & 4 &  8617.6872    &  0.0424 \\
        6   & 1 & 5 & 5 & 1 & 4 &  8731.3175    &  0.0139 \\
        7   & 0 & 7 & 6 & 0 & 6 & 10030.0312    & -0.0240 \\
        7   & 2 & 6 & 6 & 2 & 5 & 10052.6810    & -0.0383 \\
        7   & 1 & 6 & 6 & 1 & 5 & 10184.6218    &  0.0138 \\
        8   & 0 & 7 & 7 & 0 & 7 & 11453.7239    & -0.0258 \\
        8   & 2 & 7 & 7 & 2 & 6 & 11487.1502    & -0.0909 \\        
        \bottomrule
    \end{tabular}
\end{table}     

\begin{table}[!htbp]
    \centering
    \caption{Experimentally determined spectroscopic parameters of the detected rotamer of PG}
    \label{table:S3} % should go after \caption
    \sisetup{table-align-text-post=false}
    \begin{tabular}{@{\hspace{\tabcolsep}\extracolsep{\fill}} c S[table-format=4.1(2)] S[table-format=3.4(2)] S[table-format=3.4(2)] }
        \toprule
        & A \tn{a} & B & C \\       
        \midrule
        \ce{^{13}C} (1)& 3075.3 (31)\tn{b}& 733.2825 (30)& 697.0386 (27) \\ 
        \ce{^{13}C} (2)& 3086.3 (15) & 736.5933 (22)& 699.4114 (17) \\ 
        \ce{^{13}C} (4)& 3055.3 (22) & 736.9399 (26)& 698.2864 (24) \\ 
        \ce{^{13}C} (5)& 3064.7 (23) & 731.8158 (29)& 693.8030 (27) \\ 
        \ce{^{13}C} (6)& 3085.0 (27) & 728.5381 (35)& 692.0961 (30) \\ 
        \ce{^{13}C} (7)& 3052.6 (32) & 732.9437 (36)& 694.8316 (36) \\ 
        \ce{^{13}C} (8)& 3056.3 (35) & 737.5525 (40)& 699.6777 (51) \\ 
        \ce{^{15}N}    & 3042.1 (12) & 733.0221 (15)& 697.1036 (21) \\ 
        \bottomrule
    \end{tabular}
    \raggedright\footnotesize
    \begin{enumerate}[label=\tn{\alph*},leftmargin=*]
        \item $A$, $B$, and $C$ are the rotational constants (in \si{MHz});
        $\chi_{aa}$, $\chi_{bb}$, and $\chi_{cc}$ are elements of the $^{14}$N nuclear quadrupole coupling tensor (in \si{MHz}).
        \item Standard errors indicated in parentheses in units of the last digit.
    \end{enumerate}
\end{table} 

\end{document}

多谢!

更新- 毕竟,这个问题还是有道理的!正确的 LaTeX 代码格式也是必要的!显然,一个空行可以带来很大的不同!到目前为止,这是我的幼稚结论。

我自己就经历过很多失败,并且我了解到如果你没有经历很多失败,那么你可能就没有发挥出你应该有的创造力 - 你没有发挥你的想象力。 - J. Backus

答案1

  • 第一个表未居中(水平),因为您没有将threeparttable环境嵌入环境内table。然后,移动\centering指令外部环境threeparttable

  • 要理解为什么第三个表没有居中,有必要了解\centering\raggedright(以及\raggedleft)的工作原理。本质上,它们可以完成它们的工作在段落末尾\end{tabular}。在您的代码中,和之间没有空行,也没有其他类型的段落分隔符\raggedright。您可以(应该能够?)猜测\raggedright,而不是才是\centering(逻辑)段落末尾的有效内容。

这三个表格位于同一页上,均水平居中。

在此处输入图片描述

\documentclass{book}
\usepackage[margin=1in,letterpaper]{geometry}
\usepackage{array} % for \newcolumntype macro
\newcolumntype{C}{>{$}c<{$}}
\usepackage{siunitx}
\usepackage{booktabs}
\usepackage{enumitem}
\usepackage{threeparttable}
\usepackage[version=4]{mhchem}
\usepackage[skip=0.333\baselineskip]{caption}

\begin{document} 

\newcommand{\tn}[1]{\textsuperscript{#1}}
\newcommand{\TN}[1]{\makebox[0pt][l]{\tn{#1}}}

\begin{table}[h!]
\centering % Now placed *before* \begin{threeparttable}

\begin{threeparttable}[!htbp]

\caption{Experimentally determined spectroscopic parameters of the detected rotamer of PG}
\label{table:S1}

\sisetup{table-align-text-post=false}
\begin{tabular}{@{} l S[table-format=4.1(2)] 
                      S[table-format=3.4(2)] 
                      S[table-format=3.4(2)] @{}}
\toprule
     & {$A$\,\tnote{a}} & {$B$} & {$C$} \\        
\midrule
     \ce{^{13}C} (1)& 3075.3 (31)\tnote{b}& 733.2825 (30)& 697.0386 (27) \\ 
     \ce{^{13}C} (2)& 3086.3 (15) & 736.5933 (22)& 699.4114 (17) \\ 
     \ce{^{13}C} (4)& 3055.3 (22) & 736.9399 (26)& 698.2864 (24) \\ 
     \ce{^{13}C} (5)& 3064.7 (23) & 731.8158 (29)& 693.8030 (27) \\ 
     \ce{^{13}C} (6)& 3085.0 (27) & 728.5381 (35)& 692.0961 (30) \\ 
     \ce{^{13}C} (7)& 3052.6 (32) & 732.9437 (36)& 694.8316 (36) \\ 
     \ce{^{13}C} (8)& 3056.3 (35) & 737.5525 (40)& 699.6777 (51) \\ 
     \ce{^{15}N}    & 3042.1 (12) & 733.0221 (15)& 697.1036 (21) \\ 
\bottomrule
\end{tabular}

\begin{tablenotes}[flushleft]
\footnotesize
\item[a] $A$, $B$, and $C$ are the rotational constants (in \si{\mega\hertz}).
$\chi_{aa}$, $\chi_{bb}$, and $\chi_{cc}$ are elements of the $^{14}$N nuclear 
quadrupole coupling tensor (in \si{\mega\hertz}).
\item[b] Standard errors indicated in parentheses in units of the last digit.
\end{tablenotes}
\end{threeparttable} 
\end{table}

\begin{table}[!h]
\centering
\caption{Observed frequencies and residuals (in \si{MHz}) for the observed transitions of \ce{^{13}C} (\ce{C_{10}}) isotopic species of phenylglycinol.}
\label{table:S2}
\sisetup{table-align-text-post=false}
\begin{tabular}{@{} CCCCCC S[table-format= 5.4] 
                           S[table-format=-1.4] @{}}
\toprule
J' & K'_{-1} & K'_{+1} & J'' & K''_{-1} & K''_{+1} 
& {$\nu_{\mathrm{obs}}$} 
& {$\nu_{\mathrm{obs}} - \nu_{\mathrm{cal}}$} \\  
\midrule
  5   & 1 & 5 & 4 & 1 & 4 &  7084.9419    &  0.0170 \\
  5   & 0 & 5 & 4 & 0 & 4 &  7173.7289    &  0.0526 \\
  5   & 2 & 4 & 4 & 2 & 3 &  7182.1213    &  0.0253 \\
  5   & 1 & 4 & 4 & 1 & 3 &  7277.2026    & -0.0193 \\
  6   & 0 & 6 & 5 & 0 & 5 &  8603.3344    &  0.0928 \\
  6   & 2 & 5 & 5 & 2 & 4 &  8617.6872    &  0.0424 \\
  6   & 1 & 5 & 5 & 1 & 4 &  8731.3175    &  0.0139 \\
  7   & 0 & 7 & 6 & 0 & 6 & 10030.0312    & -0.0240 \\
  7   & 2 & 6 & 6 & 2 & 5 & 10052.6810    & -0.0383 \\
  7   & 1 & 6 & 6 & 1 & 5 & 10184.6218    &  0.0138 \\
  8   & 0 & 7 & 7 & 0 & 7 & 11453.7239    & -0.0258 \\
  8   & 2 & 7 & 7 & 2 & 6 & 11487.1502    & -0.0909 \\        
\bottomrule
\end{tabular}
\end{table}     

\begin{table}[!htbp]
\centering
\caption{Experimentally determined spectroscopic parameters of the detected rotamer of PG}
\label{table:S3}

\sisetup{table-align-text-post=false}
\begin{tabular}{@{} l S[table-format=4.1(2)] 
                      S[table-format=3.4(2)] 
                      S[table-format=3.4(2)] @{}}
\toprule
  & {$A$\,\tn{a}} & {$B$} & {$C$} \\       
\midrule
  \ce{^{13}C} (1)& 3075.3 (31)\tn{b}& 733.2825 (30)& 697.0386 (27) \\ 
  \ce{^{13}C} (2)& 3086.3 (15) & 736.5933 (22)& 699.4114 (17) \\ 
  \ce{^{13}C} (4)& 3055.3 (22) & 736.9399 (26)& 698.2864 (24) \\ 
  \ce{^{13}C} (5)& 3064.7 (23) & 731.8158 (29)& 693.8030 (27) \\ 
  \ce{^{13}C} (6)& 3085.0 (27) & 728.5381 (35)& 692.0961 (30) \\ 
  \ce{^{13}C} (7)& 3052.6 (32) & 732.9437 (36)& 694.8316 (36) \\ 
  \ce{^{13}C} (8)& 3056.3 (35) & 737.5525 (40)& 699.6777 (51) \\ 
  \ce{^{15}N}    & 3042.1 (12) & 733.0221 (15)& 697.1036 (21) \\ 
\bottomrule
\end{tabular}

\raggedright % leave the preceding line blank!
\footnotesize
\begin{enumerate}[label=\tn{\alph*},leftmargin=*]
\item $A$, $B$, and $C$ are the rotational constants (in \si{MHz}). 
$\chi_{aa}$, $\chi_{bb}$, and $\chi_{cc}$ are elements of the $^{14}$N nuclear 
quadrupole coupling tensor (in \si{\mega\hertz}).
\item Standard errors indicated in parentheses in units of the last digit.
\end{enumerate}
\end{table} 

\end{document}

相关内容