I have some very large and very small numbers being displayed in decimal notation (for a non-scientific audience). Normally—for small magnitude ranges—I would align on the decimal point with {r@{.}l}
, but in this case I have to deal with about 20 orders of magnitude in the same table, so that becomes impractical. My real table has over twenty rows.
Currently all numbers can be right-aligned or left-aligned en-masse. I would like to right-align the positive powers (whole numbers), but left-align the negative powers (fractional numbers).
\begin{tabularx}{\textwidth}{>{\bfseries}clrX}
Name & Sci & Decimal & Notes \\
\hline
foo & $10^{12}$ & 1 000 000 000 000 & Big number \\
bar & $10^{5}$ & 100 000 & Fair size \\
\hline
baz & $10^{-6}$ & 0.000 001 & Left-align these \\
qux & $10^{-8}$ & 0.000 000 01 & numbers, please! \\
\end{tabularx}
I could do \multicolumn{1}{l}{0.000 0001}
for each fractional number (or vice-versa for whole numbers)—and could perhaps even automate that I suppose—but as I haven't been at LaTeX very long[1], I'd like to learn the best practices before I start hacking.
The question, restated
1 000 000 Whole numbers align right
10 000
100
0.01
0.000 1
0.000 001 Fractional (decimal) numbers align left
As I admit this might be an X-Y problem, I'll accept any elegant answer that can produce the desired output. I'll also accept edits to the question to clear up anything confusing.
- Only about 20 years. Funny this never came up.
0
before decimal dot?0.
.