我想简化一下,以更简单的方式生成下表,而不使用包siunitx
。下表给了我一个\hbox
过满的结果,不知道为什么:
\documentclass[border=3mm]{article}
\usepackage{graphicx}
\usepackage{booktabs,multirow}
\usepackage{siunitx}
\usepackage{stackengine}
\begin{document}
\begin{table}[h!]
\begin{center}
\resizebox{\textwidth}{!} {
\begin{tabular}{cc*{2}{S[table-format=-1.3]}
S[table-format= 1.3]
S
S[table-format=-1.3]
S[table-format= 3.3]
S[table-format= 1.3]}
\toprule
& {\stackon{}{$\mathbf{T^{x\vphantom{y}}_{EO}}$}}
& {\stackon{[m]}{$\mathbf{T^{x\vphantom{y}}_{EO}}$}}
& {\stackon{[m]}{$\mathbf{T^y_{EO}}$}}
& {\stackon{[m]}{$\mathbf{T^{z\vphantom{y}}_{EO}}$}}
& {\stackon{[deg]}{$\mathbf{R^{x\vphantom{y}}_{EO}}$}}
& {\stackon{[deg]}{$\mathbf{R^y_{EO}}$}}
& {\stackon{[deg]}{$\mathbf{R^{z\vphantom{y}}_{EO}}$}}
& {\stackon{[px]}{\textbf{RMS}\vphantom{y}}} \\
\midrule
\multirow{4}{*}{\rotatebox[origin=c]{90}{P\textit{n}P-LM}}
& A & 2.748 & -0.135 & 2.175 & 119.232 & 1.368 & -76.261 & 0.240\\
& B & 2.690 & 0.768 & 2.128 & 124.905 & -1.972 & -91.559 & 0.247\\
& C & -1.576 & 1.139 & 2.146 & 120.264 & 1.428 & 98.205 & 0.255\\
& D & -1.575 & -0.122 & 2.165 & 119.634 & -0.818 & 85.313 & 0.231\\
\midrule
\multirow{4}{*}{\rotatebox[origin=c]{90}{EP\textit{n}P}}
& A & 2.722 & -0.161 & 2.345 & 121.639 & 1.828 & -75.974 & 0.463\\
& B & 2.649 & 0.729 & 2.259 & 127.082 & -0.881 & -91.444 & 0.432\\
& C & -1.565 & 1.148 & 2.246 & 121.639 & 1.250 & 98.377 & 0.389\\
& D & -1.547 & -0.077 & 2.238 & 120.951 & 0.199 & 85.428 & 0.372\\
\bottomrule
\end{tabular}
}
\end{center}
\caption{Exterior orientation parameters and corresponding RMS error for all Kinect sensors defined within the chessboard coordinate system.}
\label{tab:rigidParams}
\end{table}
\end{document}
答案1
这里的对齐不需要进行大量工作,因此您可以使用siunitx
“dcolumn
策略”或更简单地使用dcolumn
:
\documentclass{article}
\usepackage{booktabs}
\usepackage{dcolumn}
\usepackage{graphicx}
\usepackage{multirow}
\usepackage{stackengine}
\begin{document}
\begin{tabular}
{
@{}
c
c
D{.}{.}{2.3}
D{.}{.}{2.3}
D{.}{.}{2.3}
D{.}{.}{3.3}
D{.}{.}{2.3}
D{.}{.}{3.3}
D{.}{.}{1.3}
@{}
}
\toprule
& \multicolumn{1}{c}{\stackon{}{$\mathbf{T^{x\vphantom{y}}_{EO}}$}}
& \multicolumn{1}{c}{\stackon{[m]}{$\mathbf{T^{x\vphantom{y}}_{EO}}$}}
& \multicolumn{1}{c}{\stackon{[m]}{$\mathbf{T^y_{EO}}$}}
& \multicolumn{1}{c}{\stackon{[m]}{$\mathbf{T^{z\vphantom{y}}_{EO}}$}}
& \multicolumn{1}{c}{\stackon{[deg]}{$\mathbf{R^{x\vphantom{y}}_{EO}}$}}
& \multicolumn{1}{c}{\stackon{[deg]}{$\mathbf{R^y_{EO}}$}}
& \multicolumn{1}{c}{\stackon{[deg]}{$\mathbf{R^{z\vphantom{y}}_{EO}}$}}
& \multicolumn{1}{c@{}}{\stackon{[px]}{\textbf{RMS}\vphantom{y}}} \\
\midrule
\multirow{4}{*}{\rotatebox[origin=c]{90}{P\textit{n}P-LM}}
& A & 2.748 & -0.135 & 2.175 & 119.232 & 1.368 & -76.261 & 0.240\\
& B & 2.690 & 0.768 & 2.128 & 124.905 & -1.972 & -91.559 & 0.247\\
& C & -1.576 & 1.139 & 2.146 & 120.264 & 1.428 & 98.205 & 0.255\\
& D & -1.575 & -0.122 & 2.165 & 119.634 & -0.818 & 85.313 & 0.231\\
\midrule
\multirow{4}{*}{\rotatebox[origin=c]{90}{EP\textit{n}P}}
& A & 2.722 & -0.161 & 2.345 & 121.639 & 1.828 & -75.974 & 0.463\\
& B & 2.649 & 0.729 & 2.259 & 127.082 & -0.881 & -91.444 & 0.432\\
& C & -1.565 & 1.148 & 2.246 & 121.639 & 1.250 & 98.377 & 0.389\\
& D & -1.547 & -0.077 & 2.238 & 120.951 & 0.199 & 85.428 & 0.372\\
\bottomrule
\end{tabular}
\end{document}
答案2
嗯,通常用于siuntx
设置漂亮的表格...由于所有数字都有相同的小数位数,因此您可以S
通过以下方式替换列类型r
:
\documentclass{article}
\usepackage{graphicx}
\usepackage{booktabs,multirow}
\usepackage{array}
\usepackage{stackengine}
\usepackage{showframe}
\newcommand\mc[1]{\multicolumn{1}{c}{#1}}
\begin{document}
\begin{table}[htb]
\centering
\begin{tabular}{cc*{7}{>{$}r<{$}}}
\toprule
& \stackon{}{$\mathbf{T^{x\vphantom{y}}_{EO}}$}
& \mc{\stackon{[m]}{$\mathbf{T^{x\vphantom{y}}_{EO}}$}}
& \mc{\stackon{[m]}{$\mathbf{T^y_{EO}}$}}
& \mc{\stackon{[m]}{$\mathbf{T^{z\vphantom{y}}_{EO}}$}}
& \mc{\stackon{[deg]}{$\mathbf{R^{x\vphantom{y}}_{EO}}$}}
& \mc{\stackon{[deg]}{$\mathbf{R^y_{EO}}$}}
& \mc{\stackon{[deg]}{$\mathbf{R^{z\vphantom{y}}_{EO}}$}}
& \mc{\stackon{[px]}{\textbf{RMS}\vphantom{y}}} \\
\midrule
\multirow{4}{*}{\rotatebox[origin=c]{90}{P\textit{n}P-LM}}
& A & 2.748 & -0.135 & 2.175 & 119.232 & 1.368 & -76.261 & 0.240\\
& B & 2.690 & 0.768 & 2.128 & 124.905 & -1.972 & -91.559 & 0.247\\
& C & -1.576 & 1.139 & 2.146 & 120.264 & 1.428 & 98.205 & 0.255\\
& D & -1.575 & -0.122 & 2.165 & 119.634 & -0.818 & 85.313 & 0.231\\
\midrule
\multirow{4}{*}{\rotatebox[origin=c]{90}{EP\textit{n}P}}
& A & 2.722 & -0.161 & 2.345 & 121.639 & 1.828 & -75.974 & 0.463\\
& B & 2.649 & 0.729 & 2.259 & 127.082 & -0.881 & -91.444 & 0.432\\
& C & -1.565 & 1.148 & 2.246 & 121.639 & 1.250 & 98.377 & 0.389\\
& D & -1.547 & -0.077 & 2.238 & 120.951 & 0.199 & 85.428 & 0.372\\
\bottomrule
\end{tabular}
\caption{Exterior orientation parameters and corresponding RMS error for all Kinect sensors defined within the chessboard coordinate system.}
\label{tab:rigidParams}
\end{table}
\end{document}
showframe
添加包只是为了显示页面布局...
\addendum: 要考虑下面的注释,您需要将列标题放入\multicolumn{1}{c}{...}
。为了简化输入,我定义了新命令\newcommand\mc[1]{\multicolumn{1}{c}{#1}}
并相应地更改了表格的第一行。
另一个“简单”的解决方案:
将包添加makecell
到序言中,而不是 \stackon macro from stack engine use
\thead{...}`。在这种情况下,序言和带有列标题的行的代码是:
\documentclass{article}
\usepackage{graphicx}
\usepackage{array,booktabs,makecell,multirow}
\usepackage{showframe}
\newcommand\vph{\vphantom{y}}
\begin{document}
\begin{table}[htb]
\makegapedcells
\setcellgapes{-2pt}
\centering
\begin{tabular}{cc*{7}{>{$}r<{$}}}
\toprule
& \thead[b]{$\mathbf{T^{x\vph}_{EO}}$}
& \thead[b]{\mathbf{T^{x\vph}_{EO}}\\ \mathrm{[m]}}
& \thead[b]{\mathbf{T^y_{EO}}\\ \mathrm{[m]}}
& \thead[b]{\mathbf{T^{z\vph}_{EO}}\\ \mathrm{[m]}}
& \thead[b]{\mathbf{R^{x\vph}_{EO}}\\ \mathrm{[deg]}}
& \thead[b]{\mathbf{R^y_{EO}}\\ \mathrm{[deg]}}
& \thead[b]{\mathbf{R^{z\vph}_{EO}}\\ \mathrm{[deg]}}
& \thead[b]{\textbf{RMS}\\ \mathrm{[px]}} \\
\midrule
并得到表格: