# Align number ranges in table

I have a table column that contains ranges of numbers (e.g. 7--12) as well as numbers that are formatted differently (e.g. < 4). These numbers don't align vertically, no matter what kind of alignment I choose (l / c / r). That gives the table an inconsistent look-and-feel.

With phantom numbers (\phantom{}) I could get alignment of the number ranges, but that still leaves out the other numbers.

So, my questions are:

• What's the typographically correct way to do this? I guess all the symbols (--, < , >) should be aligned. But where should the numbers be placed, when there is only one number. Especially the 30 in the MWE below. Should it be placed left of the symbol (and the > be turned into an <), because all lower bounds are placed on the left? Or should it be placed on the right, because it's better to read ("larger than 30" is nicer than "30 is smaller than [the rest]"). Both look kind of strange. :-(
• And how to achieve it in LaTeX? As Jukka pointed out in the comments, it could be achieved using 3 columns instead of one.

MWE:

\documentclass{article}
\usepackage[utf8x]{inputenc}
\usepackage{mathtools, amsfonts}
\usepackage{booktabs}

\begin{document}

\begin{tabular}{c}
\toprule
Frequency (Hz)\\
\midrule
$< 4$\\
$4 \text{ -- } 7$\\
$8 \text{ -- } 12$\\
$12 \text{ -- } 30$\\
$> 30$\\
\bottomrule
\end{tabular}

\end{document}

-
What about creating 3 columns, one for the first number, one for the symbol (--, >), one for the third number? –  Jukka Suomela Nov 17 '10 at 15:54
@Jukka: the problem is that the widest row is the heading, which would be a multicolumn. That looks... not so good. Otherwise, I agree. –  Ulrich Schwarz Nov 17 '10 at 17:14
@Jukka: Thanks. That takes care of the LaTeX part of the question. Now, on to the typography (or readability or something) part of question...I updated it with a little bit more detail. :-) –  HenningJ Nov 17 '10 at 17:28
Since your data is integral, maybe write -- 3 instead of < 4 and 31 -- instead of > 30? –  Ulrich Schwarz Nov 17 '10 at 17:45
@Ulrich: Yeah...that'd be possible. But it kind of looks like I just forgot to put the numbers there. Any other ideas? –  HenningJ Nov 17 '10 at 17:53

Usually I would recommend the siunitx package for this task due to its capability to typeset ranges of numbers and align numbers in tables but I didn't find appropriate options for a combination (perhaps worth a feature suggestion). So this solution with dcolumn might serve as a first approach. It translates the suggestion of Ulrich.

\documentclass[11pt]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{booktabs,dcolumn}

\newcolumntype{R}[1]{D{-}{\text{--}}{#1}}

\begin{document}
\begin{tabular}{R{2.2}}\toprule
\multicolumn{1}{c}{Frequency (Hz)}\\ \midrule
-4 \\
4-7 \\
8-12 \\
12-30 \\
30- \\ \bottomrule
\end{tabular}
\end{document}

-
I've never tried this with siunitx, as it is really a bit odd. The appropriate settings to achieve the same output would be: parse-numbers = false,input-decimal-markers={-},output-decimal-marker = \text{--}. (This works by using exactly the same method as dcolumn implements.) –  Joseph Wright Nov 17 '10 at 19:35
Ah, I see. Thanks for briefing me. –  Thorsten Donig Nov 17 '10 at 19:52
Cool. That's way better than using three columns. –  HenningJ Nov 18 '10 at 12:26