2

I have a table with 7 columns. The first one with long characters and other 6 that must have the same width. I wrote this code but its impossible to get the last 6 columns with the SAME columns width. This is my code:

\begin{table}[h]
\begin{adjustbox}{width=1\textwidth}
\begin{threeparttable}
\caption{Tax-Benefit Structure\tnote{a}}
\centering
\caption{Social Expenditure}
\begin{tabular}{l*{6}{c}r}
\hline
                                & \multicolumn{3}{c}{Social Expenditure Percentage (\%)} & \multicolumn{3}{c}{GDP Percentage (\%)} \\[-0.5ex]
Type of Social Expenditure      & 2005  & 2010  & 2015  & 2005  & 2010  & 2015 \\[0.5ex]
\hline
Health                          & 17,8   & 3    & 21,9  & 1,2   & 1,9   & 2,7 \\
Promotion of Social Actions     & 1,7    & 14,1 & 20,3  & 0,1   & 1,2   & 2,5 \\
Social Welfare                  & 30,1   & 18,4 & 20,4  & 2,1   & 6     & 2,5 \\
Education                       & 8,4    & 43   & 35,8  & 3,4   & 3,7   & 4,3 \\
Science \& Technology           & 0,1    & 0,3  & 0,7   & 0     & 0     & 0,1 \\
Others                          & 0,1    & 1,8  & 0,9   & 0     & 0,2   & 0,1 \\
Total                           & 100    & 100  & 100   & 6,9   & 8,7   & 2,1 \\
\hline
\end{tabular}%
\label{tab:addlabel}%
\end{threeparttable}
\end{adjustbox}
\end{table}%
  • You have seven columns and you giving 8 options in the tabular! You have to correct this first – koleygr Jun 23 '17 at 22:28
  • Welcome to TeX.SX! A full a minimal working example (MWE), that illustrates your problem starts with \documentclass and ends with \end{document}(like in the answer). – Bobyandbob Jun 23 '17 at 23:10
2

There's no way to get equal columns with such a wide header for columns 2-4; on the other hand “(\%)” already states you are using percentages, so you can omit the word.

With siunitx it's now easy to get equal columns.

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

\sisetup{output-decimal-marker={,}}

\begin{document}

\begin{table}[htp]

\begin{threeparttable}
\caption{Tax-Benefit Structure\tnote{a}}\label{tab:addlabel}%
\centering
\caption{Social Expenditure}

\begin{tabular}{
  @{}
  l
  *{6}{S[table-format=3.1]}
  @{}
}
\toprule
Type of Social Expenditure  & \multicolumn{3}{c}{Social Expenditure} & \multicolumn{3}{c}{GDP} \\
                            & \multicolumn{3}{c}{(\%)} & \multicolumn{3}{c}{(\%)} \\
\cmidrule(lr){2-4}\cmidrule(l){5-7}
                            & {2005} & {2010} & {2015} & {2005} & {2010} & {2015} \\
\midrule
Health                      & 17,8   &  3     & 21,9   & 1,2    & 1,9    & 2,7 \\
Promotion of Social Actions &  1,7   & 14,1   & 20,3   & 0,1    & 1,2    & 2,5 \\
Social Welfare              & 30,1   & 18,4   & 20,4   & 2,1    & 6      & 2,5 \\
Education                   &  8,4   & 43     & 35,8   & 3,4    & 3,7    & 4,3 \\
Science \& Technology       &  0,1   &  0,3   &  0,7   & 0      & 0      & 0,1 \\
Others                      &  0,1   &  1,8   &  0,9   & 0      & 0,2    & 0,1 \\
\midrule
Total                       & 100    & 100    & 100    & 6,9    & 8,7    & 2,1 \\
\bottomrule
\end{tabular}

\end{threeparttable}
\end{table}

\end{document}

enter image description here

  • Thank you so much! Excellent. I will follow your sugestion. Thanks! – Rodriguetti Carambulini Jun 24 '17 at 5:06
1

try the next command on your preamble:

\newcolumntype{C}[1]{>{\centering\arraybackslash}p{#1}}

and then use:

\begin{tabular}{l*{6}{C{1.85cm}}}

You can change the length as you wish and of course you can use \resizebox{\textwidth}{!}{ %Your tabular 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.