My question is similar to Scientific Notation Only For Large Numbers and Adjust the exponent to switch between notations using siunitx
I have a table which, for the most part, has numbers between .001 and 100. I'd like to use scientific notation for numbers outside that range. I use an "S column", which doesn't seem compatible with the solutions linked to above. If instead I use a regular column with the redefined \num command from above, I run into trouble aligning since I have post text (a \Star for statistical significance).
Below is an MWE that includes the code from above links.
How can I selectively use scientific notation and align my numbers correctly?
Thanks!
\documentclass[12pt]{article}
\usepackage{expl3,siunitx}
\sisetup{
scientific-notation=true,
detect-mode,
tight-spacing = true,
input-open-uncertainty = ,
input-close-uncertainty = ,
round-mode = places,
round-precision = 3,
table-space-text-pre = ( [,
table-space-text-post = ) ] \Star
}
\protected\def\Star{$\text{*}$}
\ExplSyntaxOn
\cs_new_eq:NN \fpcmpTF \fp_compare:nTF
\ExplSyntaxOff
\newcommand*{\ThresholdLow}{0.001}
\newcommand*{\ThresholdHigh}{100}
\renewcommand*{\num}[2][]{%
\fpcmpTF{abs(#2)<=\ThresholdLow}{%
\OldNum[scientific-notation=true,#1]{#2}%
}{%
\fpcmpTF{abs(#2)>=\ThresholdHigh}{%
\OldNum[scientific-notation=true,#1]{#2}%
}{%
\OldNum[scientific-notation=false,#1]{#2}%
}%
}%
}%
\begin{document}
\begin{tabular}{l*{4}{S}}
2006&\num{0.0004} &-0.0282\Star&0.0003 &-0.0015\\
&(0.0361) &(0.0229)&(0.1285) &(0.0539)\\
2011&-0.0002 &-0.0315&0.0083 &0.0037\\
\end{tabular}
\end{document}


siunitxcompare it to your boundaries. If they are inside, just let them pass. If not, calculate the desired mantissa and the missing powers of 10. Pass the desired mantissa tosiunitxand save the powers of 10 to a command\missingpowers. Invoke that command inside the tabular preamble after each row:\begin{tabular}{l*{4}{S@{\missingpowers\renewcommand{\missingpowers}{}}}}. – Toscho Oct 22 '13 at 18:17\numto indicate numbers within anScolumn." – Steven B. Segletes Apr 22 '14 at 02:17