3

I have this table of data:

\begin{table}[h]
    \centering
    \begin{tabular}{l r l}
    \multicolumn{2}{l}{Example} & Value \\
    \midrule
    32 petabyte & \SI{32}{\peta\byte} & \SI{32E15}{\byte} \\
    166 terabecquerel & \SI{166}{\tera\becquerel} & \SI{166E12}{\becquerel} \\
    83 gigapascal & \SI{83}{\giga\pascal} & \SI{83E9}{\pascal} \\
    3.6 megajoule & \SI{3.6}{\mega\joule} & \SI{3.6E6}{\joule} \\
    10 kilowatt & \SI{10}{\kilo\watt} &  \SI{10E3}{\watt} \\
    \addlinespace
    100 milliamp & \SI{100}{\milli\amp} & \SI{100E-3}{\amp} \\
    50 microvolt & \SI{50}{\micro\volt} & \SI{50E-6}{\volt} \\
    1.02 nanosecond & \SI{1.02}{\nano\second} & \SI{1.02E-9}{\second} \\
    62 picometre & \SI{62}{\pico\metre} & \SI{62E-12}{\metre} \\
    4.7 femtogram & \SI{4.7}{\femto\gram} & \SI{4.7E-15}{\gram}
    \end{tabular}
    \caption{Examples of SI prefixes in use.}\label{tbl:prefixesexamples}
\end{table}

I would like the first column to be aligned on the space between the number and its unit, the second table aligned on the space between the number and its unit symbol, and the third table to be aligned on the multiplication symbol before the 10. Is this possible? I have tried using r@{...}, siunitx and the S column type, but this does not produce the desired result. It seems that at least part of the problem is that the mantissa sometimes does, and sometimes does not, include a decimal point.

  • Please complete your code sniped in small document, with all your units definition and used packages relevant to your problem. Help us to help you! – Zarko Oct 8 '16 at 20:13
5

For example, the three columns can be divided into six columns:

\documentclass{article}
\usepackage{booktabs}
\usepackage{caption}
\usepackage{siunitx}
\DeclareSIUnit\byte{B}
\DeclareSIUnit\amp{A}
\begin{document}
\begin{table}[h]
    \centering
    \caption{Examples of SI prefixes in use.}\label{tbl:prefixesexamples}
    \begin{tabular}{
      r@{ }l r@{ }l r@{$\,\times$}l}
    \multicolumn{4}{l}{Example} & \multicolumn{2}{l}{Value} \\
    \midrule
    32 & petabyte       & \num{32} & \si{\peta\byte}       & \num{32} & \SI{E15}{\byte} \\
    166 & terabecquerel & \num{166} & \si{\tera\becquerel} & \num{166} & \SI{E12}{\becquerel} \\
    83 & gigapascal     & \num{83} & \si{\giga\pascal}     & \num{83} & \SI{E9}{\pascal} \\
    3.6 & megajoule     & \num{3.6} & \si{\mega\joule}     & \num{3.6} & \SI{E6}{\joule} \\
    10 & kilowatt       & \num{10} & \si{\kilo\watt}       & \num{10} & \SI{E3}{\watt} \\
    \addlinespace
    100 & milliamp      & \num{100} & \si{\milli\amp}      & \num{100} & \SI{E-3}{\amp} \\
    50 & microvolt      & \num{50} & \si{\micro\volt}      & \num{50} & \SI{E-6}{\volt} \\
    1.02 & nanosecond   & \num{1.02} & \si{\nano\second}   & \num{1.02} & \SI{E-9}{\second} \\
    62 & picometre      & \num{62} & \si{\pico\metre}      & \num{62} & \SI{E-12}{\metre} \\
    4.7 & femtogram     & \num{4.7} & \si{\femto\gram}     & \num{4.7} & \SI{E-15}{\gram}
    \end{tabular}
\end{table}
\end{document}

Result

1

With some stretching:

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

\DeclareSIUnit{\byte}{b}

\begin{document}

\begin{table}[htp]
\centering

\begin{tabular}{
  r
  @{ }% a space between the columns
  l
  r
  @{\,}% a thin space between the columns
  l
  r
  @{${}\times{}$}% \times between the columns
  l
}
\toprule
\multicolumn{2}{c}{Example} & \multicolumn{4}{c}{Value} \\
\midrule
  \num{32} & petabyte      &   \num{32} & \si{\peta\byte}      & \num{32}&\SI[parse-numbers=false]{10^{15}}{\byte} \\
 \num{166} & terabecquerel &  \num{166} & \si{\tera\becquerel} & \num{166}&\SI[parse-numbers=false]{10^{12}}{\becquerel} \\
  \num{83} & gigapascal    &   \num{83} & \si{\giga\pascal}    & \num{83}&\SI[parse-numbers=false]{10^{9}}{\pascal} \\
 \num{3.6} & megajoule     &  \num{3.6} & \si{\mega\joule}     & \num{3.6}&\SI[parse-numbers=false]{10^{6}}{\joule} \\
  \num{10} & kilowatt      &   \num{10} & \si{\kilo\watt}      &  \num{10}&\SI[parse-numbers=false]{10^{3}}{\watt} \\
\addlinespace
 \num{100} & milliamp      &  \num{100} & \si{\milli\ampere}   & \num{100}&\SI[parse-numbers=false]{10^{-3}}{\ampere} \\
  \num{50} & microvolt     &   \num{50} & \si{\micro\volt}     & \num{50}&\SI[parse-numbers=false]{10^{-6}}{\volt} \\
\num{1.02} & nanosecond    & \num{1.02} & \si{\nano\second}    & \num{1.02}&\SI[parse-numbers=false]{10^{-9}}{\second} \\
  \num{62} & picometre     &   \num{62} & \si{\pico\metre}     & \num{62}&\SI[parse-numbers=false]{10^{-12}}{\metre} \\
 \num{4.7} & femtogram     &  \num{4.7} & \si{\femto\gram}     & \num{4.7}&\SI[parse-numbers=false]{10^{-15}}{\gram}\\
\bottomrule
\end{tabular}

\caption{Examples of SI prefixes in use.}\label{tbl:prefixesexamples}

\end{table}

\end{document}

enter image description here

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.