1

Is there a way in which I could stretch the width of these tables? I do not need it to be necessarily the page's width.

I have read the forums saying I should change to tabular* and put extracolsp{\fill}, but everything lost its formatting once I have done that.

\documentclass[12pt]{article}
\usepackage{booktabs}
\usepackage[utf8]{inputenc}
\usepackage[skip=0.333\baselineskip]{caption} 
\usepackage{newtxtext,newtxmath} 
\usepackage[vmargin=3cm, hmargin=2.5cm]{geometry}
\usepackage[group-separator={.},
            group-four-digits,
            output-decimal-marker={,}]{siunitx}

\newcommand{\M}[1]{\multicolumn{2}{c}{#1}}
\usepackage[flushleft]{threeparttable}
\newcommand\mc{\multicolumn{1}{c}}


\makeatletter
\setlength{\@fptop}{0pt}
\setlength{\@fpbot}{0pt plus 1fil}
\makeatother

\begin{document}
\begin{table}
\centering\setlength\extrarowheight{2pt}
\caption{Estatísticas Descritivas - Distribuição por UF} 
\setlength\extrarowheight{2pt}
\begin{tabular}{@{\extracolsep{4pt}}l*{3}{S[table-format=2.2]}}
  \toprule

UF & {Controle (\%)} & {Tratado (\%)} & {Total (\%)} \\ 
  \midrule
MG & 16.06 & 12.09 & 15.30 \\ 
  SP & 11.20 & 16.62 & 12.23 \\ 
  BA & 8.39 & 9.17 & 8.54 \\ 
  RS & 8.38 & 5.93 & 7.91 \\ 
  PR & 6.72 & 6.41 & 6.66 \\ 
  GO & 4.33 & 4.01 & 4.27 \\ 
  SC & 3.97 & 4.85 & 4.14 \\ 
  PB & 4.44 & 2.02 & 3.98 \\ 
  MA & 4.06 & 3.54 & 3.96 \\ 
  PE & 3.91 & 3.21 & 3.78 \\ 
  CE & 3.84 & 3.41 & 3.76 \\ 
  PI & 3.87 & 2.94 & 3.69 \\ 
  PA & 2.62 & 4.51 & 2.98 \\ 
  RN & 2.76 & 3.08 & 2.82 \\ 
  MT & 2.38 & 2.53 & 2.41 \\ 
  RJ & 1.94 & 3.36 & 2.21 \\ 
  TO & 2.15 & 2.11 & 2.15 \\ 
  AL & 2.06 & 1.23 & 1.90 \\ 
  ES & 1.38 & 1.95 & 1.49 \\ 
  SE & 1.55 & 1.09 & 1.46 \\ 
  MS & 1.31 & 1.88 & 1.42 \\ 
  AM & 1.03 & 2.22 & 1.26 \\ 
  RO & 0.84 & 0.97 & 0.87 \\ 
  AC & 0.36 & 0.22 & 0.33 \\ 
  AP & 0.25 & 0.33 & 0.27 \\ 
  RR & 0.19 & 0.29 & 0.21 \\ 
   \bottomrule
\end{tabular}
\end{table}
\end{document}
  • Please elaborate on "everything lost its formatting". Really everything, including the material outside the tabular* env. Please be specific. – Mico Aug 9 '17 at 21:48
  • Arthur, you forgot \begin{document / \end{document} in your code. – gusbrs Aug 9 '17 at 21:53
1

You can use \setlength{\tabcolsep}{16pt} right before \begin{tabular}. Of course, adjust the parameter according to what you want.

The result for 16pt is:

enter image description here

2

Here's a solution that uses a tabular* environment. As you noted, it's not necessary to set the overall width to 1\textwidth. Something like 0.55\textwidth may be more appropriate.

Observe that it's possible to enliven the "look" of the table a bit by (a) giving more structure to the header and (b) adding a bit of whitespace after every fifth row.

enter image description here

\documentclass[12pt]{article}
\usepackage{booktabs,array}
\usepackage[utf8]{inputenc}
\usepackage[skip=0.333\baselineskip]{caption} 
\usepackage{newtxtext,newtxmath} 
\usepackage[vmargin=3cm, hmargin=2.5cm]{geometry}
\usepackage[group-separator={.},
            group-four-digits,
            output-decimal-marker={,}]{siunitx}

\begin{document}
\begin{table}
\centering
\setlength\extrarowheight{0.75pt}
\setlength\tabcolsep{0pt}
\caption{Estatísticas Descritivas -- Distribuição por UF} 
\begin{tabular*}{0.55\textwidth}{@{\extracolsep{\fill}} 
    l *{3}{S[table-format=2.2]} }
\toprule
  UF & {Controle} & {Tratado} & {Total} \\ 
     & {(\%)} & {(\%)} & {(\%)} \\
\midrule
  MG & 16.06 & 12.09 & 15.30 \\ 
  SP & 11.20 & 16.62 & 12.23 \\ 
  BA & 8.39 & 9.17 & 8.54 \\ 
  RS & 8.38 & 5.93 & 7.91 \\ 
  PR & 6.72 & 6.41 & 6.66 \\ \addlinespace % every 5th row
  GO & 4.33 & 4.01 & 4.27 \\ 
  SC & 3.97 & 4.85 & 4.14 \\ 
  PB & 4.44 & 2.02 & 3.98 \\ 
  MA & 4.06 & 3.54 & 3.96 \\ 
  PE & 3.91 & 3.21 & 3.78 \\ \addlinespace
  CE & 3.84 & 3.41 & 3.76 \\ 
  PI & 3.87 & 2.94 & 3.69 \\ 
  PA & 2.62 & 4.51 & 2.98 \\ 
  RN & 2.76 & 3.08 & 2.82 \\ 
  MT & 2.38 & 2.53 & 2.41 \\ \addlinespace
  RJ & 1.94 & 3.36 & 2.21 \\ 
  TO & 2.15 & 2.11 & 2.15 \\ 
  AL & 2.06 & 1.23 & 1.90 \\ 
  ES & 1.38 & 1.95 & 1.49 \\ 
  SE & 1.55 & 1.09 & 1.46 \\ \addlinespace
  MS & 1.31 & 1.88 & 1.42 \\ 
  AM & 1.03 & 2.22 & 1.26 \\ 
  RO & 0.84 & 0.97 & 0.87 \\ 
  AC & 0.36 & 0.22 & 0.33 \\ 
  AP & 0.25 & 0.33 & 0.27 \\ \addlinespace
  RR & 0.19 & 0.29 & 0.21 \\ 
\bottomrule
\end{tabular*}
\end{table}
\end{document}
1

You can set the width of the S columns:

\documentclass[12pt]{article}
\usepackage{booktabs}
\usepackage[utf8]{inputenc}
\usepackage[skip=0.333\baselineskip]{caption}
\usepackage{newtxtext,newtxmath}
\usepackage[vmargin=3cm, hmargin=2.5cm]{geometry}
\usepackage[group-separator={.},
            group-four-digits,
            output-decimal-marker={,}]{siunitx}

\newcommand{\M}[1]{\multicolumn{2}{c}{#1}}
\usepackage[flushleft]{threeparttable}
\newcommand\mc{\multicolumn{1}{c}}


\makeatletter
\setlength{\@fptop}{0pt}
\setlength{\@fpbot}{0pt plus 1fil}
\makeatother

\begin{document}

\begin{table}
\centering\setlength\extrarowheight{2pt}
\caption{Estatísticas Descritivas - Distribuição por UF}
\setlength\extrarowheight{2pt}
\begin{tabular}{l*{3}{S[table-format=2.2, table-column-width=28mm]}@{}}
  \toprule

UF & {Controle (\%)} & {Tratado (\%)} & {Total (\%)} \\
  \midrule
MG & 16.06 & 12.09 & 15.30 \\
  SP & 11.20 & 16.62 & 12.23 \\
  BA & 8.39 & 9.17 & 8.54 \\
  RS & 8.38 & 5.93 & 7.91 \\
  PR & 6.72 & 6.41 & 6.66 \\
  GO & 4.33 & 4.01 & 4.27 \\
  SC & 3.97 & 4.85 & 4.14 \\
  PB & 4.44 & 2.02 & 3.98 \\
  MA & 4.06 & 3.54 & 3.96 \\
  PE & 3.91 & 3.21 & 3.78 \\
  CE & 3.84 & 3.41 & 3.76 \\
  PI & 3.87 & 2.94 & 3.69 \\
  PA & 2.62 & 4.51 & 2.98 \\
  RN & 2.76 & 3.08 & 2.82 \\
  MT & 2.38 & 2.53 & 2.41 \\
  RJ & 1.94 & 3.36 & 2.21 \\
  TO & 2.15 & 2.11 & 2.15 \\
  AL & 2.06 & 1.23 & 1.90 \\
  ES & 1.38 & 1.95 & 1.49 \\
  SE & 1.55 & 1.09 & 1.46 \\
  MS & 1.31 & 1.88 & 1.42 \\
  AM & 1.03 & 2.22 & 1.26 \\
  RO & 0.84 & 0.97 & 0.87 \\
  AC & 0.36 & 0.22 & 0.33 \\
  AP & 0.25 & 0.33 & 0.27 \\
  RR & 0.19 & 0.29 & 0.21 \\
   \bottomrule
\end{tabular}
\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.