我正在尝试改善下表的外观,以便:
- 集合并符号
\cup
与第二行和最后一行的逗号垂直对齐 - 中间列的角度值仍然居中,但与
\degree
符号垂直对齐
生成表的代码是:
\usepackage{siunitx}
\usepackage{gensymb}
\usepackage{dcolumn}
\usepackage{multirow}
\usepackage{booktabs}
\begin{document}
\begin{table}
\centering
\begin{tabular}{ccr}
\toprule
\rule[-0.6em]{0pt}{1.7em} Elevation range & Azimuth resolution & \multicolumn{1}{c}{$N$} \\ \hline
\rule{0pt}{1.4em} $[-40\degree,40\degree]$ & $5\degree$ & 1224 \\
$(-60\degree,-40\degree) \cup (40\degree,60\degree)$ & $8\degree$ & 270 \\
$(-70\degree,-60\degree] \cup [60\degree,70\degree)$ & $10\degree$ & 144 \\
$(-80\degree,-70\degree] \cup [70\degree,80\degree)$ & $15\degree$ & 96 \\
$(-90\degree,-80\degree] \cup [80\degree,90\degree)$ & $30\degree$ & 48 \\
\rule[-0.5em]{0pt}{0.5em} $-90\degree,90\degree$ & $360\degree$ & 2 \\
\bottomrule
\end{tabular}
\end{table}
\end{document}
该表如下所示:
我希望它看起来像:
答案1
您可以借助框来\cup
进行对齐:,
\documentclass{article}
\usepackage{siunitx}
\usepackage{gensymb}
\usepackage{dcolumn}
\usepackage{multirow}
\usepackage{booktabs}
\usepackage{calc} %% provides \widthof
\begin{document}
\begin{table}
\centering
\begin{tabular}{cS[table-format=3,table-space-text-post=\si{\degree}]r}
\toprule
\rule[-0.6em]{0pt}{1.7em} Elevation range & \multicolumn{1}{c}{Azimuth resolution} & \multicolumn{1}{c}{$N$} \\ \hline
\rule{0pt}{1.4em} \makebox[\widthof{$(-60\degree,-40\degree)$}][r]{$[-40\degree$}$,$
\makebox[\widthof{$(40\degree,60\degree)$}][l]{$40\degree]$} & 5\si{\degree} & 1224 \\
$(-60\degree,-40\degree) \cup (40\degree,60\degree)$ & 8\si{\degree} & 270 \\
$(-70\degree,-60\degree] \cup [60\degree,70\degree)$ & 10\si{\degree} & 144 \\
$(-80\degree,-70\degree] \cup [70\degree,80\degree)$ & 15\si{\degree} & 96 \\
$(-90\degree,-80\degree] \cup [80\degree,90\degree)$ & 30\si{\degree} & 48 \\
\rule[-0.5em]{0pt}{0.5em} \makebox[\widthof{$(-60\degree,-40\degree)$}][r]{$-90\degree$}$,$
\makebox[\widthof{$(40\degree,60\degree)$}][l]{$90\degree$} & 360\si{\degree} & 2 \\
\bottomrule
\end{tabular}
\end{table}
\end{document}
答案2
有了它siunitx
,您可以更轻松地输入;我更\si{\degree}
愿意\degree
。
\documentclass{article}
\usepackage{siunitx}
\usepackage{booktabs}
\begin{document}
\begin{tabular}{
c
S[table-format=3,
table-space-text-post=\si{\degree}
]<{\si{\degree}}
S[table-format=4]
}
\toprule
Elevation range & \multicolumn{1}{c}{Azimuth resolution} & {$N$} \\
\midrule
$[\SI{-40}{\degree},\SI{40}{\degree}]$ & 5 & 1224 \\
$(\SI{-60}{\degree},\SI{-40}{\degree}) \cup
(\SI{40}{\degree},\SI{60}{\degree})$ & 8 & 270 \\
$(\SI{-70}{\degree},\SI{-60}{\degree}] \cup
[\SI{60}{\degree},\SI{70}{\degree})$ & 10 & 144 \\
$(\SI{-80}{\degree},\SI{-70}{\degree}] \cup
[\SI{70}{\degree},\SI{80}{\degree})$ & 15 & 96 \\
$(\SI{-90}{\degree},\SI{-80}{\degree}] \cup
[\SI{80}{\degree},\SI{90}{\degree})$ & 30 & 48 \\
$\SI{-90}{\degree},\SI{90}{\degree}$ & 360 & 2 \\
\bottomrule
\end{tabular}
\end{document}
答案3
使用tabstackengine
在根据最宽的列编写具有等间距列的表格,你就能实现你的要求。
该包扩展了该stackengine
包以允许制表。
tabstackengine
我将从和 的制表符和对齐结束字符更改为&
和,以免与 冲突。\\
*
/
tabular
\documentclass{article}
\usepackage{siunitx}
\usepackage{gensymb}
\usepackage{dcolumn}
\usepackage{multirow}
\usepackage{booktabs}
\usepackage{tabstackengine}
\setstackEOL{/}
\setstackTAB{*}
\strutlongstacks{T}
\setstackgap{L}{12pt}
\stackMath
\begin{document}
\begin{table}
\centering
\begin{tabular}{ccr}
\toprule
\rule[-0.6em]{0pt}{1.7em} Elevation range & Azimuth resolution & \multicolumn{1}{c}{$N$} \\ \midrule
\alignLongstack{%
[-40\degree\!\!\!*\,\,,40\degree]/
(-60\degree,-40\degree) *\cup (40\degree,60\degree)/
(-70\degree,-60\degree] *\cup [60\degree,70\degree)/
(-80\degree,-70\degree] *\cup [70\degree,80\degree)/
(-80\degree,-70\degree] *\cup [70\degree,80\degree)/
-90\degree\!\!\!*\,\,,90\degree
}
&\Longstack[r]{5^\circ/8^\circ/10^\circ/15^\circ/30^\circ/360^\circ}%
&\Longstack[r]{1224/270/144/96/48/2}
\\
\bottomrule
\end{tabular}
\end{table}
\end{document}
答案4
S
您可以使用siunitx
。
\documentclass{article}
\usepackage{siunitx}
\usepackage{booktabs}
\newcommand*\mc[1]{\multicolumn{1}{c}{#1}}
\begin{document}
\begin{table}
\centering
\begin{tabular}{
c
S[table-format = 3]
S[table-format = 4]
}
\toprule
Elevation range & \mc{Azimuth resolution} & \mc{$N$} \\
\si{\degree} & \mc{\si{\degree}} & \mc{---} \\
\midrule
$[-40 ,40]$ & 5 & 1224 \\
$(-60,-40) \cup (40,60)$ & 8 & 270 \\
$(-70,-60] \cup [60,70)$ & 10 & 144 \\
$(-80,-70] \cup [70,80)$ & 15 & 96 \\
$(-90,-80] \cup [80,90)$ & 30 & 48 \\
$ -90, 90$ & 360 & 2 \\
\bottomrule
\end{tabular}
\end{table}
\end{document}
请注意,我在前两列的数字上方全局定义了单位(°);我认为这增加了可读性。