3

I would like to simplify to generate the following table in a more simplified way, without using the siunitx package. The following table gives me a \hbox overfull and don’t know why:

\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}
4
  • Why do you want to get rid of siunitx? You've made an error: S[table-format= 3.3] should be S[table-format= -2.3], -76,261 is wider than say 666.666 because of the -
    – daleif
    Mar 8, 2016 at 8:36
  • @daleif yes but then each column has a different width. How can I equally distribute the column width in my table?
    – Kostas
    Mar 8, 2016 at 8:42
  • Usually by making sure all columns use the same formatting. You are basically reserving space for each column. But I'd say it is not worth fiddling with
    – daleif
    Mar 8, 2016 at 9:05
  • 4
    I'm curious, why don't you want to use siunitx? I think it's one of the most useful packages out there.
    – pipe
    Mar 8, 2016 at 9:40

2 Answers 2

6

The alignment here needs no significant work, so you could use siunitx with the 'dcolumn strategy' or more simply just use 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
  • Personally I'd re-format the header and drop the multirow stuff but that's not in the question ...
    – Joseph Wright
    Mar 8, 2016 at 9:06
  • @DavidCarlisle I did think of a package-free approach (or at least just using array), but it seemed a bit daft.
    – Joseph Wright
    Mar 8, 2016 at 9:35
3

Well, usually the siuntx is used for seting beautiful tables ... Since all number have the same number of decimals, you can replace S column type by 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}

enter image description here

Package showframe is added only to show page layout ...

\addendum: To consider the comments below you need to put column header in \multicolumn{1}{c}{...}. For simpler typing, I define new command \newcommand\mc[1]{\multicolumn{1}{c}{#1}} and accordingly change first row of table.

Another "simple" solution:

Add makecell package to preamble and instead of \stackonmacro from stack engine use\thead{...}`. IN this case the code of preamble and row with column heads is:

\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

and obtained table:

enter image description here

3
  • @Zarko, dont you think that the headers should be centralized somehow?
    – Kostas
    Mar 8, 2016 at 9:07
  • I'm sure for this. However, you don't like to use siunitx which provide this .... See next answer with preposition of use dcolum package ...
    – Zarko
    Mar 8, 2016 at 9:12
  • Now headers are centered ... on the two eays, as you can see from recent edit of my answer.
    – Zarko
    Mar 8, 2016 at 10:08

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .