# Vertical alignment of degree unit and other elements in table

I am trying to improve the appearance of the below table such that:

1. The set union symbols \cup align vertically with the commas from the 2nd and last rows
2. The middle column angle values are still centered, but vertically aligned to the \degree sign

The code that generates the table is:

\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}


The table looks like:

I would like it to look like:

-
none of the answers so far address the fact that the degree signs do not exactly line up (because a square bracket is slightly narrower than the corresponding parenthesis). i'm unable to undertake a solution for this at the moment (computer problems; i'll try to test it later) but thought the point worth mentioning. –  barbara beeton Dec 10 '13 at 15:51

You can make \cup to align with , with the help of boxes:

\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}


-

With siunitx you can have an easier input; I'd prefer \si{\degree} to \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}


-
Why not use, say, \SI{40}{\degree} instead of 40\si{\degree}? –  Svend Tveskæg Dec 10 '13 at 0:31
@SvendTveskæg Just because I was lazy and that edit was simpler. ;-) –  egreg Dec 10 '13 at 0:32

Using the experimental tabstackengine package introduced at Writing a table with equally spaced columns, based on the widest column, you can achieve what you requested.

The package extends the stackengine package to allow tabbing.

I changed the tab and end-of-align characters for tabstackengine from & and \\ to * and /, so as not to conflict with 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}


-

You can use the S column from 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}


Notice that I have defined the unit (°) globally above the numbers in each of the first two columns; this increases the readability, I think.

-