8

I am trying to make a table using the siunitx package. However, each column is padded with a large amount of whitespace.By changing tabcolsep, I can reduce the amount of whitespace on the right of each column but I cannot change the amount of whitespace on the left. Changing table-column-width only causes hbox overflow, while preserving the excess whitespace.

Here is a MWE:

\documentclass{article}
\usepackage{siunitx}
\usepackage{lscape}

\begin{document}
  \setlength{\tabcolsep}{0.2em}
  \begin{landscape}
    \centerline{
      \begin{tabular}{
          S |
          S |
          S |
          S |
          S |
          S |
          S |
          S |
          S |
          S |
          S
        }
3 & 3.20E+01 & 3.13E-02 & 1.25E-01 & 3.75E+08 & 5.07E+05 & 1.50E+01 & 6.67E-02 & 1.25E-01 & 3.75E+08 & 5.07E+05 \\
      \end{tabular}
    }%//centerline
  \end{landscape}
\end{document}

And here is the version with table-column-width explicitly set:

\documentclass{article}
\usepackage{siunitx}
\usepackage{lscape}

\begin{document}
  \setlength{\tabcolsep}{0.2em}
  \begin{landscape}
    \centerline{
      \begin{tabular}{
          S[table-column-width=8em] |
          S[table-column-width=8em] |
          S[table-column-width=8em] |
          S[table-column-width=8em] |
          S[table-column-width=8em] |
          S[table-column-width=8em] |
          S[table-column-width=8em] |
          S[table-column-width=8em] |
          S[table-column-width=8em] |
          S[table-column-width=8em] |
          S[table-column-width=8em]
        }
3 & 3.20E+01 & 3.13E-02 & 1.25E-01 & 3.75E+08 & 5.07E+05 & 1.50E+01 & 6.67E-02 & 1.25E-01 & 3.75E+08 & 5.07E+05 \\
      \end{tabular}
    }%//centerline
  \end{landscape}
\end{document}

Please advise how to remove the whitespace to the left of each number so that the table may fit on a single page. Thank you.

7

In the following I used the same format for all columns, which means that there is superfluous around shorter numbers like the 3. If you want them even closer, adjust the format for each column individually.

The current format 1.2e-1 means

  • 1 digit in front of the decimal sign
  • 2 digits behind the decimal sign
  • e needs space
  • - needs space
  • 1 digit in the exponent

As Mico suggested in comments: To get even tighter spacing you can use tight-spacing=true either as option of the siunitx package or in the S column.

\documentclass{article}
\usepackage[tight-spacing=true]{siunitx}
\usepackage{lscape}

\begin{document}
  \setlength{\tabcolsep}{0.2em}
  \begin{landscape}
    \centering
      \begin{tabular}{
            c|
          *{10}{S[table-format=1.2e-1]|}
        }
3 & 3.20E+01 & 3.13E-02 & 1.25E-01 & 3.75E+08 & 5.07E+05 & 1.50E+01 & 6.67E-02 & 1.25E-01 & 3.75E+08 & 5.07E+05 \\
      \end{tabular}
  \end{landscape}
\end{document}

enter image description here

  • Thank you. The repetition operator is helpful as well. What is meaning of the asterisk? – user001 Jan 25 '17 at 20:11
  • 2
    Two further suggestions: (a) use c instead of S for the very first column, and (b) set the option tight-spacing=true. – Mico Jan 25 '17 at 20:18
  • 1
    @user001 Concerning the *, this is part of the repetition *{N}{String} – user36296 Jan 25 '17 at 20:21
  • 1
    @user001 the asterisk is the repetition function taking two arguments. – daleif Jan 25 '17 at 20:22
4

We also can play with the different numbers format: some have a negative exponent, others don't. If each cell content is representative of its column, this leads to the second tabular:

\documentclass{article}

\usepackage{siunitx}
\usepackage{lscape}

\begin{document}

\begin{landscape}
  \centering
  \setlength{\tabcolsep}{4pt}
  \sisetup{table-format=1.2e-1,table-number-alignment=center}
  \begin{tabular}{|l |*{10}{S|}}
    3 & 3.20E+01 & 3.13E-02 & 1.25E-01 & 3.75E+08 & 5.07E+05 & 1.50E+01 & 6.67E-02 & 1.25E-01 & 3.75E+08 & 5.07E+05 \\
  \end{tabular}
  \vspace*{1cm}

  \begin{tabular}{|l|S[table-format =1.2e1]|*{2}{S|}*{3}{S[table-format =1.2e1]|}*{2}{S|}*{2}{S[table-format =1.2e1]|}}
    3 & 3.20E+01 & 3.13E-02 & 1.25E-01 & 3.75E+08 & 5.07E+05 & 1.50E+01 & 6.67E-02 & 1.25E-01 & 3.75E+08 & 5.07E+05 \\
  \end{tabular}
\end{landscape}

\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.