使用小数点和比率符号(冒号:)将列与数字对齐

使用小数点和比率符号(冒号:)将列与数字对齐

我想通过小数和冒号 (:) 比例符号实现对齐,类似于下面代码中显示的内容,而不是图中显示的内容。我也欢迎任何有关一般表格美学的建议。谢谢

\documentclass{article}
\documentclass{article}
\usepackage[abbreviations=true,per-mode=symbol]{siunitx}
\usepackage{booktabs}
\usepackage{makecell}
\usepackage{caption}
\begin{document}

\begin{table}[!t]
\caption{Focus as a Ratio of the Total}
\centering
\begin{tabular}{ >{\bfseries}c S[table-format=2.2] }
\toprule
\thead{ID} & {\thead{Ratio\\ {[Focus : Total]} }} \\
\midrule
1    &{1 :  18.7}\\
2    &{1 :   0.2}\\
3    &{1 : 105.6}\\
4    &{1 :  58.7}\\
5    &{1 :   0  }\\
6    &{1 :   1.5}\\
\bottomrule
\end{tabular}
\end{table}

\end{document}

比例图像

答案1

使用最少的视觉格式:

\documentclass{article}
\usepackage[abbreviations=true,per-mode=symbol]{siunitx}
\usepackage{booktabs}
\usepackage{makecell}
\usepackage{caption}

\begin{document}

\begin{table}[!htp]
\caption{Focus as a Ratio of the Total}
\centering
\begin{tabular}{
  >{\bfseries}c
  >{\enspace}c
  @{${}:{}$\hspace{-\tabcolsep}}
  S[table-format=3.1]
}
\toprule
\thead{ID} & \multicolumn{2}{c}{\thead{Ratio \\\relax [Focus${}:{}$Total]}} \\
\midrule
1 & 1 &  18.7 \\
2 & 1 &   0.2 \\
3 & 1 & 105.6 \\
4 & 1 &  58.7 \\
5 & 1 &   0   \\
6 & 1 &   1.5 \\
\bottomrule
\end{tabular}
\end{table}

\end{document}

在此处输入图片描述

答案2

以下是包含三列的可能性:

\documentclass{article}
\usepackage[abbreviations=true,per-mode=symbol]{siunitx}
\usepackage{booktabs}
\usepackage{makecell}
\usepackage{caption}

\begin{document}

\begin{table}[!t]
\caption{Focus as a Ratio of the Total}
\centering
\begin{tabular}{ >{\bfseries}c>{1}r!{$ : \!$} S[table-format=3.1, table-number-alignment=left] }
\toprule
\thead{ID} & \multicolumn{2}{r}{\thead{Ratio\\ {[Focus : Total]}}} \\
\midrule
1 & & 18.7 \\
2 & & 0.2 \\
3 & & 105.6 \\
4 & & 58.7 \\
5 & & 0 \\
6 & & 1.5 \\
\bottomrule
\end{tabular}
\end{table}

\end{document} 

在此处输入图片描述

相关内容