16

I am trying to make a table with four columns: three of the columns are to be center aligned, and one is to be aligned by decimal places ( using S[table-format=3.2]). Here is my code:

\documentclass{article}
\usepackage{siunitx}
\usepackage{booktabs}

\begin{document}

\begin{tabular}{c c S[table-format=3.2] c}
\toprule
\multicolumn{4}{c}{SI Prefixes} \\
%\hline \hline
\midrule \midrule
Prefix & Symbol & Multiplication Factor & $\ldots$ in Scientific Notation \\
\midrule
giga & G & 1000000000 & $10^9$ \\
mega & M & 1000000 & $10^6$ \\ 
kilo & k & 1000 & $10^3$ \\
deca & D & 10 & $10^1$ \\
\rowcolor{gray!20} - & - & 1 & $10^0$ \\
deci & d & 0.1 & $10^{-1}$ \\
centi & c & 0.01 & $10^{-2}$ \\
milli & m & 0.001 & $10^{-3}$ \\
micro & $\mu$ & 0.000001 & $10^{-6}$ \\
nano & n & 0.000000001 & $10^{-9}$ \\
\bottomrule
\end{tabular}

\end{document}

However, here is my result:

enter image description here

The columns are overlapping, and I cannot figure out how to fix it. I can't think of a way to set the width of the third column, as that would fix the issue, but to my understanding, you can only fix the width by doing something like p{5cm}; the S type will not allow that.

8
  • 4
    you need {...} around the heading so it isn't parsed as a number but main issue is you have specified a format of 3.2 so 2 decimal places but your numbers are 0.000000001 which have rather more than 2 digits after the point. Use a format that matches your data Jan 4, 2019 at 15:59
  • 1
    It just hit me, the number left of . is the number of digits left of the decimal and same with the right. So I should put 10.9.
    – akenny430
    Jan 4, 2019 at 16:07
  • 3
    Slightly off-topic: The shortened form of \deca (\deka works too...) is da, not D.
    – Mico
    Jan 4, 2019 at 16:15
  • 1
    Two years late and slightly off-topic but I think you might want to include hecto- (h) 100 Jan 16, 2021 at 3:53
  • 2
    Still later: I think, in the line concerning the "micro" Prefix: the \mu should be printed in upright font, I guess? At least, it looks strange to see an italic \mu while the rest of the prefix symbols are upright.
    – Jan
    May 12, 2021 at 7:30

1 Answer 1

18

Update, March 2022: I wrote the answer shown below in early 2019, when version 2.xx of the siunitx package still roamed the earth. If you wish to compile the answer code under version 3.xx of the siunitx package, I suggest you load the siunitx package with the option v2=, i.e., as \usepackage{siunitx}[=v2]. Please see How to convert the macro \si in the new version 3 of siunitx for additional details.


As David Carlisle has already pointed out in a comment, you must (a) change S[table-format=3.2] to S[table-format=10.9] and (b) encase the string Multiplication Factor in curly braces, to keep it from being interpreted by siunitx.

In addition, you may want to (c) write \si{\micro} instead of $\mu$ in the second column. The text-mu and math-mu glyphs look quite different in most fonts. Finally, since you're using the siunitx package, why not (d) use the S column type for the final column as well and input e9 thru e-9 instead of the more cumbersome $10^9$ thru $10^{-9}$?

A separate observation: the standard short form of deca (or deka) is da, not D. For sure, both \si{\deca} and \si{\deka} produce da.

enter image description here

\documentclass{article}
\usepackage{siunitx}
\usepackage{booktabs}
\usepackage[table]{xcolor}
\begin{document}
\noindent
\begin{tabular}{l c S[table-format=10.9] S[retain-zero-exponent=true]}
\toprule
\multicolumn{4}{c}{SI Prefixes} \\
\addlinespace %\midrule
Prefix & Symbol & {Multiplication Factor} & {\dots\ in Scientific Notation} \\
\midrule
giga  & \si{\giga} & 1000000000 & e9 \\
mega  & \si{\mega} & 1000000    & e6 \\ 
kilo  & \si{\kilo} & 1000       & e3 \\
deca  & \si{\deca} & 10         & e1 \\ % "\deka" works too
\rowcolor{gray!20}  -- & -- & 1 & e0 \\
deci  & \si{\deci} & 0.1        & e-1 \\
centi & \si{\centi}& 0.01       & e-2 \\
milli & \si{\milli}& 0.001      & e-3 \\
micro & \si{\micro}& 0.000001   & e-6 \\
nano  & \si{\nano} & 0.000000001& e-9 \\
\bottomrule
\end{tabular}
\end{document}
2
  • 1
    This code does not seem to work any longer on TeXLive 21. It produces the error Package siunitx Error: Found prefix part with no unit.. Mar 4, 2022 at 2:23
  • @TeXApprentice - Thanks for bringing this issue to my attention. Please see the update I posted at the start of the answer.
    – Mico
    Mar 4, 2022 at 2:38

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .