[Tex/LaTex] Align number ranges in table

horizontal alignmenttables

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}

Best Answer

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}