4

I'm very unhappy with the alignment of the headers in the following table. I've even tried using \multicolumn, but it has no effect. (And if someone knows what the table is about... Yes, I'm unhappy with the content also, LoL!)

\documentclass{article}
\usepackage{siunitx}
\usepackage{rotating}
\sisetup{round-mode=figures, round-precision=3, scientific-notation=false}
\begin{sidewaystable}
    \centering
    \begin{tabular}{rrr@{}S[scientific-notation=true]@{}S[scientific-notation=true]rSS}
        \toprule
        $N$ & $P$ & $P^3$ & \multicolumn{1}{c}{$\Delta x$} & {$\Delta t$} & $n_t$ & {w.c.t. (\si{\minute})} & {Speed-up \si{\percent}}\\
        \midrule
        16 & 1 & 1 & 0.393 & 0.196078431 & 102 & 4.069515 &  \\
        32 & 2 & 8 & 0.196 & 0.0980392157 & 204 & 8.13903 & 1 \\
        48 & 3 & 27 & 0.131 & 0.0653594771 & 306 & 13.1286 & 0.929919793428088 \\
        64 & 4 & 64 & 0.0982 & 0.0490196078 & 408 & 28.5765 & 0.569630990499186 \\
        80 & 5 & 125 & 0.0785 & 0.0392156863 & 510 & 48.5749 & 0.418890723398298 \\
        96 & 6 & 216 & 0.0654 & 0.0326797386 & 612 & 87.7083 & 0.278389730504411 \\
        112 & 7 & 343 & 0.0561 & 0.0280112045 & 714 & 96.3564 & 0.295637912997995 \\
        128 & 8 & 512 & 0.0491 & 0.0245398773 & 815 & 197.87 & 0.164532875120028 \\
        \midrule
        32 & 1 & 1 & 0.196 & 0.0980392157 & 204 & 55.5835 &  \\
        64 & 2 & 8 & 0.0982 & 0.0490196078 & 408 & 111.167 & 1 \\
        96 & 3 & 27 & 0.0654 & 0.0326797386 & 612 & 197.713 & 0.843396741741818 \\
        128 & 4 & 64 & 0.0491 & 0.0245398773 & 815 & 415.779 & 0.534740811825513 \\
        160 & 5 & 125 & 0.0393 & 0.0196270854 & 1019 & 1076.27 & 0.258222843710221 \\
        192 & 6 & 216 & 0.0327 & 0.0163532298 & 1223 & 1867.37831666667 & 0.178593162951207 \\
        224 & 7 & 343 & 0.0280 & 0.0140154170 & 1427 & 2435.0328 & 0.159786143332443 \\
        256 & 8 & 512 & 0.0245 & 0.0122699387 & 1630 & 3343.32016666667 & 0.133001919598786 \\
        \bottomrule
    \end{tabular}
\end{sidewaystable}

enter image description here

6

Specify the format of each column.

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

\sisetup{
  round-mode=figures,
  round-precision=3,
  scientific-notation=false
}

\begin{document}

\begin{table}
\centering

\begin{tabular}{
 S[table-format=3.0]
 S[table-format=1.0]
 S[table-format=3.0]
 S[scientific-notation=true,table-format=1.2e-1]
 S[scientific-notation=true,table-format=1.2e-1]
 S[table-format=4.0]
 S[table-format=4.2]
 S[table-format=1.3]
}
\toprule
{$N$} &
{$P$} &
{$P^3$} &
{$\Delta x$} &
{$\Delta t$} &
{$n_t$} &
{w.c.t.} &
{Speed-up} \\
&&&&&& {\si{\minute}} & {\si{\percent}} \\
\midrule
16 & 1 & 1 & 0.393 & 0.196078431 & 102 & 4.069515 &  \\
32 & 2 & 8 & 0.196 & 0.0980392157 & 204 & 8.13903 & 1 \\
48 & 3 & 27 & 0.131 & 0.0653594771 & 306 & 13.1286 & 0.929919793428088 \\
64 & 4 & 64 & 0.0982 & 0.0490196078 & 408 & 28.5765 & 0.569630990499186 \\
80 & 5 & 125 & 0.0785 & 0.0392156863 & 510 & 48.5749 & 0.418890723398298 \\
96 & 6 & 216 & 0.0654 & 0.0326797386 & 612 & 87.7083 & 0.278389730504411 \\
112 & 7 & 343 & 0.0561 & 0.0280112045 & 714 & 96.3564 & 0.295637912997995 \\
128 & 8 & 512 & 0.0491 & 0.0245398773 & 815 & 197.87 & 0.164532875120028 \\
\midrule
32 & 1 & 1 & 0.196 & 0.0980392157 & 204 & 55.5835 &  \\
64 & 2 & 8 & 0.0982 & 0.0490196078 & 408 & 111.167 & 1 \\
96 & 3 & 27 & 0.0654 & 0.0326797386 & 612 & 197.713 & 0.843396741741818 \\
128 & 4 & 64 & 0.0491 & 0.0245398773 & 815 & 415.779 & 0.534740811825513 \\
160 & 5 & 125 & 0.0393 & 0.0196270854 & 1019 & 1076.27 & 0.258222843710221 \\
192 & 6 & 216 & 0.0327 & 0.0163532298 & 1223 & 1867.37831666667 & 0.178593162951207 \\
224 & 7 & 343 & 0.0280 & 0.0140154170 & 1427 & 2435.0328 & 0.159786143332443 \\
256 & 8 & 512 & 0.0245 & 0.0122699387 & 1630 & 3343.32016666667 & 0.133001919598786 \\
\bottomrule
\end{tabular}

\end{table}

\end{document}

enter image description here

| improve this answer | |
  • Is there some reason why siunitx cannot detect the format by itself? – Enrico Oct 12 '18 at 18:59
  • 1
    @EnricoMariaDeAngelis Yes: it should read each entry in the table and then decide. This would mean several seconds for a not so big table. – egreg Oct 12 '18 at 20:01

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.