表格、格式化

表格、格式化

正在與這張桌子作鬥爭,感謝任何幫助。多謝

 \documentclass[a4paper,12pt]{report}
\usepackage{multirow}
\usepackage{siunitx,booktabs}%for table decimals number
\usepackage[export]{adjustbox} \begin{table}[!htbp]
\centering
\begin{tabular}{>{\bfseries}l 
               S[table-format=-1.2(2)] 
                S[table-format=table-format=1.1e1] } 
\toprule 
  {\textbf{Approach}} & $\boldsymbol{\beta}$ & $\boldsymbol{\chi^{2}}$ \\
   \midrule
1   &  -0.61(17)        & Inf. \\
2   &  -0.60(17)        & Inf. \\
3   &  -0.59(18)        & 3$\times$10$^6$\\ 
4   &  -0.56(20)        & Inf. \\
\bottomrule
\end{tabular}
\caption[]
 \label{}
\end{table}
\FloatBarrier

答案1

我不會在標題中使用粗體:\bm{\beta}\beta是兩個不同的數學實體。

另外,第一列不必是粗體。第三列只有一個數字,可以只用c, 來\num表示數字;如果這只是未刪節的版本,您應該將非數字條目括起來。

\documentclass[a4paper,12pt]{report}

\usepackage{amsmath,bm}
\usepackage{siunitx,booktabs}%for table decimals number


\begin{document}

\begin{table}[!htbp]
\centering

\begin{tabular}{
  >{\bfseries}l 
  S[table-format=-1.2(2)] 
  c
}
\toprule 
Approach & {$\bm{\beta}$} & $\bm{\chi^{2}}$ \\
\midrule
1   &  -0.61(17)        & Inf. \\
2   &  -0.60(17)        & Inf. \\
3   &  -0.59(18)        & \num{3e6} \\ 
4   &  -0.56(20)        & Inf. \\
\bottomrule
\end{tabular}
\caption{A caption}
\label{label}
\end{table}

\begin{table}[!htbp]
\centering

\begin{tabular}{
  l 
  S[table-format=-1.2(2)] 
  c
}
\toprule 
Approach & {$\beta$} & $\chi^{2}$ \\
\midrule
1   &  -0.61(17)        & Inf. \\
2   &  -0.60(17)        & Inf. \\
3   &  -0.59(18)        & \num{3e6} \\ 
4   &  -0.56(20)        & Inf. \\
\bottomrule
\end{tabular}
\caption{A caption}
\label{label2}
\end{table}

\begin{table}[!htbp]
\centering

\begin{tabular}{
  l 
  S[table-format=-1.2(2)] 
  S[table-format=1.0e1]
}
\toprule 
Approach & {$\beta$} & $\chi^{2}$ \\
\midrule
1   &  -0.61(17)        & {Inf.} \\
2   &  -0.60(17)        & {Inf.} \\
3   &  -0.59(18)        & 3e6 \\ 
4   &  -0.56(20)        & {Inf.} \\
\bottomrule
\end{tabular}
\caption{A caption}
\label{label3}
\end{table}

\end{document}

在此輸入影像描述

答案2

這應該是您的表並且可以編譯:

\documentclass[a4paper,12pt]{report}
\usepackage{multirow}
\usepackage{siunitx}
\usepackage{booktabs}
\usepackage{amsmath}

\begin{document}
\begin{table}[!htbp]
\centering
\begin{tabular}{>{\bfseries}c % I think centred column looks better here
               S[table-format=-1.2(2)] 
                S[table-format=1.1e1] } 
\toprule 
  Approach & $\boldsymbol{\beta}$ & $\boldsymbol{\chi^{2}}$ \\
   \midrule
1   &  -0.61(17)        & {Inf.} \\
2   &  -0.60(17)        & {Inf.} \\
3   &  -0.59(18)        & 3e6 \\ 
3   &  -0.59(18)        & 3.0e6 \\ % for comparison
4   &  -0.56(20)        & {Inf.} \\
\bottomrule
\end{tabular}
\caption{test}
\label{tab:test}
\end{table}
\end{document}

在此輸入影像描述 有什麼不如你所願的嗎?

答案3

在此輸入影像描述

\documentclass[a4paper,12pt]{report}
\usepackage{amsmath}
\usepackage{booktabs}
\usepackage{siunitx}

\begin{document}
    \begin{table}[htbp]
    \centering
\caption[]{My nice table}
    \label{tab:mytable}
\begin{tabular}{>{\bfseries}l
                S[table-format=-1.2(2)]
                S[table-format= 1.0e1] }
    \toprule
Approach    & {$\boldsymbol{\beta}$}    & {$\boldsymbol{\chi^{2}}$}  \\
   \midrule
1           &  -0.61(17)                & {Inf.}                    \\
2           &  -0.60(17)                & {Inf.}                    \\
3           &  -0.59(18)                & 3e6                       \\
4           &  -0.56(20)                & {Inf.}                    \\
    \bottomrule
\end{tabular}
    \end{table}

or

    \begin{table}[htbp]
\sisetup{separate-uncertainty}%
    \centering
\caption[]{My nice table again}
    \label{tab:mytable}
\begin{tabular}{>{\bfseries}c
                S[table-format=-1.2(2)]
                S[table-format= 1.0e1] }
    \toprule
Approach    & {$\boldsymbol{\beta}$}    & {$\boldsymbol{\chi^{2}}$}  \\
   \midrule
1           &  -0.61(17)                & {Inf.}                    \\
2           &  -0.60(17)                & {Inf.}                    \\
3           &  -0.59(18)                & 3e6                       \\
4           &  -0.56(20)                & {Inf.}                    \\
    \bottomrule
\end{tabular}
    \end{table}
\end{document}

相關內容