8

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.

  • 3
    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 – David Carlisle Jan 4 at 15:59
  • How would I format it then? Sorry, I've never used siunitx before. The max amount of digits is 9, so would I put 3.9? – Aiden Kenny Jan 4 at 16:03
  • 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. – Aiden Kenny Jan 4 at 16:07
  • 1
    Slightly off-topic: The shortened form of \deca (\deka works too...) is da, not D. – Mico Jan 4 at 16:15
  • Good point... I was not aware of this – Aiden Kenny Jan 4 at 16:41
9

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 write e9 thru e-9 instead of $10^9$ thru $10^{-9}$?

A separate observation: the standard short form of deca (or deka) is da, not D. For sure, \si{\deca} (\si{\deka} works too...) produces 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{\deka} & 10         & e1 \\
\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}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.