TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
1  
don't use \centerline it is not really a latex command, just a left-over from plain tex, just use \centering – David Carlisle 11 hours ago
    
@David Carlisle: Ok, thanks for pointing that out. – user001 11 hours ago

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

share|improve this answer
    
Thank you. The repetition operator is helpful as well. What is meaning of the asterisk? – user001 11 hours ago
2  
Two further suggestions: (a) use c instead of S for the very first column, and (b) set the option tight-spacing=true. – Mico 11 hours ago
1  
@user001 Concerning the *, this is part of the repetition *{N}{String} – samcarter 11 hours ago
1  
@user001 the asterisk is the repetition function taking two arguments. – daleif 11 hours ago
1  
@Mico Thanks! (your name is too short :) – samcarter 11 hours ago

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

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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