Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

OK, first off, this table is horrendous looking and desperately needs help.

But what I'd really like to know is how to eliminate some of the extra white space between the columns set with S in the tabular environment.

\documentclass{article}
\usepackage{amsmath,amssymb}
\usepackage{array}
\usepackage{siunitx}
\begin{document}

Areas:\par
\sisetup{table-figures-decimal=4,table-auto-round,table-number-alignment=center}
\renewcommand{\arraystretch}{1.5}%%
\begin{tabular}{l
                >{$}r<{=$}
                S[table-figures-decimal=1,table-space-text-pre=]
                >{$}r<{=$}
                S}%'
   Area of region I:   & 4                    & 4    & \dfrac{1}{2}\cdot 2\cdot 4=         & 4           \\
   Area of region II:  & 8                    & 8    & 1\times 8                           & 8           \\
   Area of region III: & 6-3.5                & 2.5  & 2 \times 3 - \dfrac{1}{2}(1.5)^2\pi & 2.465708265 \\
   Area of region IV   & 35                   & 35   & 5\times 7                           & 35          \\
   Area of region V:   & 6.5                  & 6.5  & \dfrac{1}{2} (2)^2\pi               & 6.283185307 \\\hline
   Total               & \multicolumn{1}{c}{} & 56.0 &                                     & 55.78990357
\end{tabular}

\end{document}

enter image description here

Incidentally, I'm using \multicolumn in the last row to prevent the equal sign from showing up there. Is there a better hack to eliminating, temporarily, material set for between the columns? Since this is really a second question I could post it separately if that's better.

share|improve this question

2 Answers 2

up vote 5 down vote accepted

You can use table-alignment=<choice> with some small kerning in between like

@{\!}S[table-figures-decimal=1,table-space-text-pre=,table-alignment=left]

Code:

\documentclass{article}
\usepackage{amsmath,amssymb}
\usepackage{array}
\usepackage{siunitx}
\begin{document}

Areas:\par
\sisetup{table-figures-decimal=4,table-auto-round,table-number-alignment=center}
\renewcommand{\arraystretch}{1.5}%%
\begin{tabular}{l
                >{$}r<{=$}
                @{\!}S[table-figures-decimal=1,table-space-text-pre=,table-alignment=left]
                >{$}r<{=$}
                @{\!}S[table-alignment=left]}%'
   Area of region I:   & 4                    & 4    & \dfrac{1}{2}\cdot 2\cdot 4         & 4           \\
   Area of region II:  & 8                    & 8    & 1\times 8                           & 8           \\
   Area of region III: & 6-3.5                & 2.5  & 2 \times 3 - \dfrac{1}{2}(1.5)^2\pi & 2.465708265 \\
   Area of region IV   & 35                   & 35   & 5\times 7                           & 35          \\
   Area of region V:   & 6.5                  & 6.5  & \dfrac{1}{2} (2)^2\pi               & 6.283185307 \\\hline
   Total               & \multicolumn{1}{c}{} & 56.0 &                                     & 55.78990357
\end{tabular}

\end{document}

enter image description here

Adjust the kerning to your liking in @{\!}.

For your second question, I feel that \multicolumn is the best answer IMO. But Somebody may have a better hack.

share|improve this answer

I'm not really sure you want to align the numbers to the decimal point. But here's how you can improve the table:

\documentclass{article}
\usepackage{amsmath,amssymb}
\usepackage{array,booktabs}
\usepackage{siunitx}
\begin{document}

Areas:\par
\renewcommand{\arraystretch}{1.5}
\sisetup{table-figures-decimal=4,table-auto-round}
\begin{tabular}{
  @{}
  l
  >{$}r<{={}$}
  @{}
  S[table-format=2.1]
  @{\hspace{3em}}
  >{$}r<{={}$}
  @{}
  S[table-format=2.4]
  @{}
}%'
Area of region I:   & 4     & 4    & \dfrac{1}{2}\cdot 2\cdot 4          & 4           \\
Area of region II:  & 8     & 8    & 1\times 8                           & 8           \\
Area of region III: & 6-3.5 & 2.5  & 2 \times 3 - \dfrac{1}{2}(1.5)^2\pi & 2.465708265 \\
Area of region IV   & 35    & 35   & 5\times 7                           & 35          \\
Area of region V:   & 6.5   & 6.5  & \dfrac{1}{2} (2)^2\pi               & 6.283185307 \\
\midrule
Total               &       & 56.0 &                                     & 55.78990357
\end{tabular}

\end{document}

enter image description here


Here's a different version without alignment on the decimal point; note that it needs the collcell package:

%% add in the preamble
\usepackage{collcell}
\newcommand{\bnum}[1]{\num[round-mode=places,round-precision=4]{#1}}

%% the table
\begin{tabular}{
  @{}
  l
  >{$}r<{={}$}
  @{}
  >{\collectcell\num}l<{\endcollectcell}
  @{\hspace{3em}}
  >{$}r<{={}$}
  @{}
  >{\collectcell\bnum}l<{\endcollectcell}
  @{}
}%'
Area of region I:   & 4     & 4    & \dfrac{1}{2}\cdot 2\cdot 4         & 4           \\
Area of region II:  & 8     & 8    & 1\cdot 8                           & 8           \\
Area of region III: & 6-3.5 & 2.5  & 2 \cdot 3 - \dfrac{1}{2}(1.5)^2\pi & 2.465708265 \\
Area of region IV   & 35    & 35   & 5\cdot 7                           & 35          \\
Area of region V:   & 6.5   & 6.5  & \dfrac{1}{2} (2)^2\pi              & 6.283185307 \\
\midrule
Total               &       & 56.0 &                                    & 55.78990357
\end{tabular}

enter image description here

share|improve this answer
    
Ah! I'm not quite yet in the habit of using booktabs. –  A.Ellett Apr 13 at 22:25
    
Care to elaborate why you wouldn't align on the decimal? –  A.Ellett Apr 13 at 22:25
    
@A.Ellett It makes the whole thing very unbalanced. –  egreg Apr 13 at 22:33
    
Yeah. I'm really not happy at all with the way this table looks. It's very ugly. :( –  A.Ellett Apr 13 at 22:37
    
@A.Ellett I added a different version for comparison –  egreg Apr 13 at 22:54

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.