我如何获得这样的表格?

我如何获得这样的表格?

我如何获得这样的表格输出?我尝试关注这个论坛中的几个帖子。但还是忍不住问了这个问题。帮帮我吧,伙计们!!提前谢谢 :)

表 3.1

答案1

siunitx例如,使用包中的“列说明符”将数字在小数点处对齐S

\documentclass{article}
\usepackage{siunitx}

\begin{document}
\newcommand*{\mytablehead}[1]{%
  \renewcommand*{\arraystretch}{1.5}%
  \bfseries
  \begin{tabular}{@{}c@{}}#1\end{tabular}%
}
\renewcommand*{\arraystretch}{1.2}
\begin{tabular}{|c|S|S|S|S|}
  \hline
  \multicolumn{1}{|c|}{\mytablehead{\mbox{}\\Specimen No.}}&
  \multicolumn{2}{c|}{\mytablehead{With End-effect-\\Correction}}&
  \multicolumn{2}{c|}{\mytablehead{Without End-effect-\\Correction}}\\
  \cline{2-5}
  & \multicolumn{1}{c|}{Sa(\si{\micro\metre})}
  & \multicolumn{1}{c|}{Sz(\si{\micro\metre})}
  & \multicolumn{1}{c|}{Sa(\si{\micro\metre})}
  & \multicolumn{1}{c|}{Sz(\si{\micro\metre})} \\
  \hline
  1 & 6.41 & 42.9 & 6.46 & 43.86 \\
  \hline
  2 & 5.04 & 36.07 & 5.74 & 52.16 \\
  \hline
  3 & 7.45 & 48.23 & 7.62 & 48.22 \\
  \hline
  4 & 5.93 & 44.74 & 6.5 & 48.1 \\
  \hline
  5 & 7.38 & 46.66 & 6.94 & 43.7 \\
  \hline
  Average & 6.442 & 43.72 & 6.652 & 47.208 \\
  \hline
\end{tabular}
\end{document}

结果

没有过多线条的变体:

\documentclass{article}
\usepackage{booktabs}
\usepackage{siunitx}

\begin{document}
\newcommand*{\mytablehead}[2]{%
  \multicolumn{#1}{c}{%
    \bfseries
    \begin{tabular}{@{}c@{}}#2\end{tabular}%
  }%
}
\renewcommand*{\arraystretch}{1.2}
\begin{tabular}{cSSSS}
  \toprule
  \mytablehead{1}{\mbox{}\\Specimen No.}&
  \mytablehead{2}{With End-effect-\\Correction}&
  \mytablehead{2}{Without End-effect-\\Correction}\\
  & \multicolumn{1}{c}{Sa(\si{\micro\metre})}
  & \multicolumn{1}{c}{Sz(\si{\micro\metre})}
  & \multicolumn{1}{c}{Sa(\si{\micro\metre})}
  & \multicolumn{1}{c}{Sz(\si{\micro\metre})} \\
  \midrule
  1 & 6.41 & 42.9 & 6.46 & 43.86 \\
  2 & 5.04 & 36.07 & 5.74 & 52.16 \\
  3 & 7.45 & 48.23 & 7.62 & 48.22 \\
  4 & 5.93 & 44.74 & 6.5 & 48.1 \\  
  5 & 7.38 & 46.66 & 6.94 & 43.7 \\
  Average & 6.442 & 43.72 & 6.652 & 47.208 \\
  \bottomrule
\end{tabular}
\end{document}

结果

相关内容