我有一张长表,其中有很多重复的类似条目。
我尝试通过在行之间留出一些空间并对每个条目的公共部分进行分组来改善视觉效果。即,前四个观察到的变量应该是:
- 蓝杆旋转位置守门员
- 蓝棒旋转位置防御
- 蓝杆旋转位置中场
- 蓝棒旋转位置攻击
但是,我对视觉效果并不满意。我会尝试使用类似于案例环境的东西(即在每个组的第一列和第二列之间使用一个大“{”),但我不知道如何使用表格行来实现。
当然,如果您有关于如何更好地压缩数据的建议,或者关于如何获得更好的视觉效果而不涉及大“{”的建议,欢迎您提出。但是,请注意行的顺序很重要,所以我无法合并“蓝色杆”和“红色杆”。
这是我用来生成示例的代码:
\documentclass{book}
\usepackage[utf8]{inputenc}
\usepackage{booktabs}
\usepackage{multirow}
\usepackage{makecell}
\begin{document}
\begin{table}[htbp]
\centering
\begin{tabular}{@{}*{2}{l}*{2}{c}@{}}
\toprule
\multicolumn{2}{c}{Observed variable} &
\thead{Lowest \\ possible value} &
\thead{Highest \\ possible value} \\
\midrule
\multirow{4}{*}{\makecell[l]{Blue rods: \\ revolute position}}
& Goalkeeper &
$-\pi$ & $\pi$ \\
& Defense &
$-\pi$ & $\pi$ \\
& Midfield &
$-\pi$ & $\pi$ \\
& Attack &
$-\pi$ & $\pi$ \\
&&&\\
\multirow{4}{*}{\makecell[l]{Blue rods: \\ prismatic position}}
& Goalkeeper &
$-0.9451e-1$ & $0.9451e-1$ \\
& Defense &
$-1.82e-1$ & $1.82e-1$ \\
& Midfield &
$-0.665e-1$ & $0.665e-1$ \\
& Attack &
$-1.11e-1$ & $1.11e-1$ \\
&&&\\
\multirow{4}{*}{\makecell[l]{Blue rods: \\ revolute velocity}}
& Goalkeeper &
$-\infty$ & $\infty$ \\
& Defense &
$-\infty$ & $\infty$ \\
& Midfield &
$-\infty$ & $\infty$ \\
& Attack &
$-\infty$ & $\infty$ \\
&&&\\
\multirow{4}{*}{\makecell[l]{Blue rods: \\ prismatic velocity}}
& Goalkeeper &
$-\infty$ & $\infty$ \\
& Defense &
$-\infty$ & $\infty$ \\
& Midfield &
$-\infty$ & $\infty$ \\
& Attack &
$-\infty$ & $\infty$ \\
&&&\\
\multirow{4}{*}{\makecell[l]{Red rods: \\ revolute position}}
& Goalkeeper &
$-\pi$ & $\pi$ \\
& Defense &
$-\pi$ & $\pi$ \\
& Midfield &
$-\pi$ & $\pi$ \\
& Attack &
$-\pi$ & $\pi$ \\
&&&\\
\multirow{4}{*}{\makecell[l]{Red rods: \\ prismatic position}}
& Goalkeeper &
$-0.9451e-1$ & $0.9451e-1$ \\
& Defense &
$-1.82e-1$ & $1.82e-1$ \\
& Midfield &
$-0.665e-1$ & $0.665e-1$ \\
& Attack &
$-1.11e-1$ & $1.11e-1$ \\
&&&\\
\multirow{4}{*}{\makecell[l]{Red rods: \\ revolute velocity}}
& Goalkeeper &
$-\infty$ & $\infty$ \\
& Defense &
$-\infty$ & $\infty$ \\
& Midfield &
$-\infty$ & $\infty$ \\
& Attack &
$-\infty$ & $\infty$ \\
&&&\\
\multirow{4}{*}{\makecell[l]{Red rods: \\ prismatic velocity}}
& Goalkeeper &
$-\infty$ & $\infty$ \\
& Defense &
$-\infty$ & $\infty$ \\
& Midfield &
$-\infty$ & $\infty$ \\
& Attack &
$-\infty$ & $\infty$ \\
&&&\\
\multirow{3}{*}{\makecell[l]{Ball: \\ position}}
& x &
$-5.75e-1$ & $5.75e-1$ \\
& y &
$-3.55e-1$ & $3.55e-1$ \\
& z &
$-\infty$ & $\infty$ \\
\bottomrule
\end{tabular}
\caption{Observation space bounds}
\end{table}
\end{document}
答案1
这主要是风格上的,但答案也包含一些有用的建议。
我会避免使用括号,因为它们对理解没有任何帮助。标签应该与顶行对齐,而不是居中,因为这样会产生歧义。在表格中,空白位置意味着重复上面的值。这样,组之间的小空间足以清楚地表明标签指的是什么。
我还会将表格分成三个部分,在各部分的顶部添加“蓝杆”、“红杆”和“球”,并使用不同的字体来强调它们。
siunitx
对于数字表来说,使用基本上是强制性的。
\documentclass{book}
\usepackage[utf8]{inputenc}
\usepackage{booktabs}
\usepackage{siunitx}
\sisetup{output-exponent-marker=\ensuremath{\mathrm{e}}}
\begin{document}
\begin{table}[htbp]
\centering\small
\begin{tabular}{
@{}
l
l
S[table-format=-1.4e1]
S[table-format=1.4e1]
@{}c@{}
}
\toprule
\multicolumn{2}{@{}c}{Observed variable} & \multicolumn{2}{c@{}}{Possible value} \\
\cmidrule(l){3-4}
&& {Lowest} & {Highest} \\
\midrule
\multicolumn{4}{@{}l@{}}{\itshape Blue rods} \\
revolute position
& Goalkeeper &
{$-\pi$} & {$\pi$} \\
& Defense &
{$-\pi$} & {$\pi$} \\
& Midfield &
{$-\pi$} & {$\pi$} \\
& Attack &
{$-\pi$} & {$\pi$} \\
\addlinespace
prismatic position
& Goalkeeper &
-0.9451e-1 & 0.9451e-1 \\
& Defense &
-1.82e-1 & 1.82e-1 \\
& Midfield &
-0.665e-1 & 0.665e-1 \\
& Attack &
-1.11e-1 & 1.11e-1 \\
\addlinespace
revolute velocity
& Goalkeeper &
{$-\infty$} & {$\infty$} \\
& Defense &
{$-\infty$} & {$\infty$} \\
& Midfield &
{$-\infty$} & {$\infty$} \\
& Attack &
{$-\infty$} & {$\infty$} \\
\addlinespace
prismatic velocity
& Goalkeeper &
{$-\infty$} & {$\infty$} \\
& Defense &
{$-\infty$} & {$\infty$} \\
& Midfield &
{$-\infty$} & {$\infty$} \\
& Attack &
{$-\infty$} & {$\infty$} \\
\midrule
\multicolumn{4}{@{}l@{}}{\itshape Red rods} \\
revolute position
& Goalkeeper &
{$-\pi$} & {$\pi$} \\
& Defense &
{$-\pi$} & {$\pi$} \\
& Midfield &
{$-\pi$} & {$\pi$} \\
& Attack &
{$-\pi$} & {$\pi$} \\
\addlinespace
prismatic position
& Goalkeeper &
-0.9451e-1 & 0.9451e-1 \\
& Defense &
-1.82e-1 & 1.82e-1 \\
& Midfield &
-0.665e-1 & 0.665e-1 \\
& Attack &
-1.11e-1 & 1.11e-1 \\
\addlinespace
revolute velocity
& Goalkeeper &
{$-\infty$} & {$\infty$} \\
& Defense &
{$-\infty$} & {$\infty$} \\
& Midfield &
{$-\infty$} & {$\infty$} \\
& Attack &
{$-\infty$} & {$\infty$} \\
\addlinespace
prismatic velocity
& Goalkeeper &
{$-\infty$} & {$\infty$} \\
& Defense &
{$-\infty$} & {$\infty$} \\
& Midfield &
{$-\infty$} & {$\infty$} \\
& Attack &
{$-\infty$} & {$\infty$} \\
\midrule
\multicolumn{4}{@{}l@{}}{\itshape Ball} \\
position
& x &
-5.75e-1 & 5.75e-1 \\
& y &
-3.55e-1 & 3.55e-1 \\
& z &
{$-\infty$} & {$\infty$} \\
\bottomrule
\end{tabular}
\caption{Observation space bounds}
\end{table}
\end{document}
答案2
編輯修正列标题中的错误并更新命令的定义case
像这样?
\documentclass{book}
\usepackage[utf8]{inputenc}
\usepackage{booktabs, multirow, makecell}
\renewcommand\theadgape{}
\usepackage{amsmath}
\newcommand{\case}[1]%
{$\displaystyle
\text{\makecell[l]{#1}}\quad
\left\{\begin{tabular}{l}
Goalkeeper \\
Defense \\
Midfield \\
Attack
\end{tabular}\right.
$}
\begin{document}
\begin{table}[htbp]
\centering
\begin{tabular}{ @{} l *{2}{>{$} c < {$} } @{} }
\toprule
\thead{Observed variable}
& \text{\thead{Lowest \\ possible value}}
& \text{\thead{Highest \\ possible value}} \\
\midrule
\case{Blue rods: \\ prismatic position}
& \makecell{-\pi \\
-\pi \\
-\pi \\
-\pi}
& \makecell{-\pi \\
-\pi \\
-\pi \\
-\pi} \\
\addlinespace
\case{Blue rods: \\ prismatic position}
& \makecell[r]{-0.9451e-1 \\
-1.82e-1 \\
-0.665e-1 \\
-1.11e-1}
& \makecell[r]{0.9451e-1 \\
1.82e-1 \\
0.665e-1 \\
1.11e-1} \\
\addlinespace
\case{Red rods: \\ prismatic velocity}
& \makecell{-\infty \\
-\infty \\
-\infty \\
-\infty}
& \makecell{\infty \\
\infty \\
\infty \\
\infty} \\
\bottomrule
\end{tabular}
\caption{Observation space bounds}
\label{tab:...}
\end{table}
\end{document}
答案3
一种具有更简单代码的解决方案,基于bigdelim
:
\documentclass{book}
\usepackage[utf8]{inputenc}
\usepackage{booktabs}
\usepackage{multirow, bigdelim}
\usepackage{makecell}
\newcommand{\e}[1]{\,\mathrm{e}{#1}}
\begin{document}
\begin{table}[htbp]
\centering
\renewcommand{\theadfont}{\normalsize}
\begin{tabular}{@{}l@{ \,}cl*{2}{c}@{}}
\toprule
\multicolumn{3}{c}{Observed variable} &
\thead{Lowest \\ possible value} &
\thead{Highest \\ possible value} \\
\midrule
\addlinespace[1.5ex]
& \ldelim\{{4}{0pt} & Goalkeeper &
$-\pi$ & $\pi$ \\
Blue rods: & & Defense &
$-\pi$ & $\pi$ \\
revolute position & & Midfield &
$-\pi$ & $\pi$ \\
& & Attack &
$-\pi$ & $\pi$ \\
\addlinespace[2ex]
& \ldelim\{{4}{0pt} & Goalkeeper &
$-0.9451\e{-1}$ & $ 0.9451\e{-1}$ \\
Blue rods: & & Defense &
$-1.82\e{-1}$ & $1.82\e{-1}$ \\
prismatic position & & Midfield &
$-0.665\e{-1}$ & $0.665\e{-1}$ \\
& & Attack &
$-1.11\e{-1}$ & $1.11\e{-1}$ \\
\addlinespace[2ex]
\multirow{4}{*}{\makecell[l]{Blue rods: \\ revolute velocity}}
& \ldelim\{{4}{0pt} & Goalkeeper &
$-\infty$ & $\infty$ \\
Blue rods: & & Defense &
$-\infty$ & $\infty$ \\
revolute velocity & & Midfield &
$-\infty$ & $\infty$ \\
& & Attack &
$-\infty$ & $\infty$ \\
\addlinespace[2ex]
& \ldelim\{{4}{0pt} & Goalkeeper &
$-\infty$ & $\infty$ \\
Blue rods: & & Defense &
$-\infty$ & $\infty$ \\
prismatic velocity & & Midfield &
$-\infty$ & $\infty$ \\
& & Attack &
$-\infty$ & $\infty$ \\
\addlinespace[2ex]
& \ldelim\{{4}{0pt} & Goalkeeper &
$-\pi$ & $\pi$ \\
Red rods: & & Defense &
$-\pi$ & $\pi$ \\
revolute position & & Midfield &
$-\pi$ & $\pi$ \\
& & Attack &
$-\pi$ & $\pi$ \\
\addlinespace[2ex]
& \ldelim\{{4}{0pt} & Goalkeeper &
$-0.9451\e{-1}$ & $0.9451\e{-1}$ \\
Red rods: & & Defense &
$-1.82\e{-1}$ & $1.82\e{-1}$ \\
prismatic position & & Midfield &
$-0.665\e{-1}$ & $0.665\e{-1}$ \\
& & Attack &
$-1.11\e{-1}$ & $1.11\e{-1}$ \\
\addlinespace[2ex]
& \ldelim\{{4}{0pt} & Goalkeeper &
$-\infty$ & $\infty$ \\
Red rods: & & Defense &
$-\infty$ & $\infty$ \\
revolute velocity & & Midfield &
$-\infty$ & $\infty$ \\
& & Attack &
$-\infty$ & $\infty$ \\
\addlinespace[2ex]
& \ldelim\{{4}{0pt} & Goalkeeper &
$-\infty$ & $\infty$ \\
Red rods: & & Defense &
$-\infty$ & $\infty$ \\
prismatic velocity & & Midfield &
$-\infty$ & $\infty$ \\
& & Attack &
$-\infty$ & $\infty$ \\
\addlinespace[2ex]
\multirow{3}{*}{\makecell[l]{Ball: \\ position}}
& \ldelim\{{3}{0pt} & x &
$-5.75\e{-1}$ & $5.75\e{-1}$ \\
& & y &
$-3.55\e{-1}$ & $3.55\e{-1}$ \\
& & z &
$-\infty$ & $\infty$ \\
\addlinespace[1ex]
\bottomrule
\end{tabular}
\caption{Observation space bounds}
\end{table}
\end{document}