2

Hi stackexchange community,

I have some results of a questionnaire survey that I want to sum up on a table. The problem is that some cells are confused. Please can someone fix it for me? The code is :

\begin{table}[h]
\centering
\caption{Sample descriptive statistics}
\label{Sample descriptive statistics}
\resizebox{\textwidth}{!}{%
\def\arraystretch{1.5}
\begin{tabular}{l{4cm}p{2cm}p{2cm}p{2cm}p{2cm}p{2cm}p{2cm}}
\toprule
Current/former member of a RoSCA & {(53,9\%) Yes} & {(46,1\%) No} \\ \midrule
Number of members of joined RoSCA & \begin{tabular}[c]{@{}c@{}}\textless 5\\ (27.7 \%)\end{tabular} & \begin{tabular}[c]{@{}c@{}}6-10\\ (51.1 \%)\end{tabular} & \begin{tabular}[c]{@{}c@{}}11-15\\ (10.9 \%)\end{tabular}                               & & \begin{tabular}[c]{@{}c@{}}16-20\\ (3.6 \%)\end{tabular}  & \begin{tabular}[c]{@{}c@{}}21-25\\ (1.5\%)\end{tabular} & \begin{tabular}[c]{@{}c@{}}26 or more\\ (0.0\%)\end{tabular} \\ \midrule
Contribution's frequency & \begin{tabular}[c]{@{}c@{}}Daily\\ (3.7\%)\end{tabular} & & \begin{tabular}[c]{@{}c@{}}Weekly\\ (10.4\%)\end{tabular} & & \begin{tabular}[c]{@{}c@{}}Monthly\\ (85.7\%)\end{tabular} & & \begin{tabular}[c]{@{}c@{}}Other\\ (0.2\%)\end{tabular} \\ \midrule
Subscription amount (in MAD) & \begin{tabular}[c]{@{}c@{}}\textless 500\\ (32.6 \%)\end{tabular} & \begin{tabular}[c]{@{}c@{}}500-999\\ (24.2 \%)\end{tabular} & \begin{tabular}[c]{@{}c@{}}1000-1999\\ (28\%)\end{tabular}                              & \begin{tabular}[c]{@{}c@{}}2000-2999\\ (8.3\%)\end{tabular} & \begin{tabular}[c]{@{}c@{}}3000-3999\\ (3.8\%)\end{tabular} & \begin{tabular}[c]{@{}c@{}}4000-4999\\ (1.5 \%)\end{tabular} & \begin{tabular}[c]{@{}c@{}}5000 or more\\ (1.5\%)\end{tabular}  \\ \midrule
Joining motivations                                                           & \begin{tabular}[c]{@{}c@{}}Spontaneously\\ (35.3\%)\end{tabular} & \begin{tabular}[c]{@{}c@{}}Buy a home\\ (8.9\%)\end{tabular} & \begin{tabular}[c]{@{}c@{}}Buy durable goods\\ (22.5 \%)\end{tabular}& \begin{tabular}[c]{@{}c@{\centering}}Children education\\ (9.3\%)\end{tabular} & \begin{tabular}[c]{@{}c@{}}Vacation travel\\ (18.9)\end{tabular} & \begin{tabular}[c]{@{}c@{}}Pilgrimage\\ (2\%)\end{tabular} & \begin{tabular}[c]{@{}c@{}}Other reasons\\ (3.1)\end{tabular}   \\ \midrule
Tolerate a new proposed entrance & \multicolumn{3}{c}{(75.9\%) Yes}                                                                                                                                                                                                                                & \multicolumn{1}{l}{} & \multicolumn{3}{c}{(24.1\%) No} \\ \midrule
Order determining criteria & \begin{tabular}[c]{@{}c@{}}Drawing of lots\\ (26.2\%)\end{tabular} & \begin{tabular}[c]{@{}c@{}}Agreement of participants\\ (41.8\%)\end{tabular} &  & \begin{tabular}[c]{@{}c@{}}Social criteria (age, sexe...)\\ (6\%)\end{tabular} &  & \begin{tabular}[c]{@{}c@{}}Financial criteria\\ (21.3\%)\end{tabular} & \begin{tabular}[c]{@{}c@{}}Others\\(4.7\%)\end{tabular} \\ \midrule
Tolerate a urgent beneficiary & \multicolumn{3}{c}{(91.9\%) Yes} & \multicolumn{1}{l}{} & \multicolumn{3}{c}{(8.1\%) No} \\ \midrule
RoSCA or low interest rate bank loan ? & \multicolumn{3}{c}{\begin{tabular}[c]{@{}c@{}}RoSCA\\ (74.1\%)\end{tabular}} & \multicolumn{1}{l}{} & \multicolumn{3}{c}{\begin{tabular}[c]{@{}c@{}}Low interest rate bank loan\\ (25.9\%)\end{tabular}}                                                                                                                                           \\ \midrule
Respondents prefering RoSCA are motivated by & Administrative procedures (28.3\%) & Interest free \& no fees (47.3\%) & Religious conviction (19.1\%) & Other reasons (5.3\%) & \\ \bottomrule
\end{tabular}
}
\end{table}

Screenshot of my compilated table

  • Welcome to TeX.SX! The nested tabular is perhaps the cause of the problem – user31729 Oct 13 '15 at 16:01
3

A quick solution: Change the c column type to C[2cm] -- a better solution requires some time.

\documentclass{article}


\usepackage{graphicx}
\usepackage{booktabs}
\usepackage{array}
\usepackage{multirow}

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

\begin{document}

\begin{table}[h]
\centering
\caption{Sample descriptive statistics}
\label{Sample descriptive statistics}
\resizebox{\textwidth}{!}{%
  \def\arraystretch{1.5}
\begin{tabular}{L{4cm}*{7}{p{2cm}}}
\toprule
Current/former member of a RoSCA & {(53,9\%) Yes} & {(46,1\%) No} \\ \midrule
Number of members of joined RoSCA & \begin{tabular}[c]{C{2cm}}\textless 5\\ (27.7 \%)\end{tabular} & \begin{tabular}[c]{C{2cm}}6-10\\ (51.1 \%)\end{tabular} & \begin{tabular}[c]{C{2cm}}11-15\\ (10.9 \%)\end{tabular}                               & & \begin{tabular}[c]{C{2cm}}16-20\\ (3.6 \%)\end{tabular}  & \begin{tabular}[c]{C{2cm}}21-25\\ (1.5\%)\end{tabular} & \begin{tabular}[c]{C{2cm}}26 or more\\ (0.0\%)\end{tabular} \\ \midrule
Contribution's frequency & \begin{tabular}[c]{C{2cm}}Daily\\ (3.7\%)\end{tabular} & & \begin{tabular}[c]{C{2cm}}Weekly\\ (10.4\%)\end{tabular} & & \begin{tabular}[c]{C{2cm}}Monthly\\ (85.7\%)\end{tabular} & & \begin{tabular}[c]{C{2cm}}Other\\ (0.2\%)\end{tabular} \\ \midrule
Subscription amount (in MAD) & \begin{tabular}[c]{C{2cm}}\textless 500\\ (32.6 \%)\end{tabular} & \begin{tabular}[c]{C{2cm}}500-999\\ (24.2 \%)\end{tabular} & \begin{tabular}[c]{C{2cm}}1000-1999\\ (28\%)\end{tabular}                              & \begin{tabular}[c]{C{2cm}}2000-2999\\ (8.3\%)\end{tabular} & \begin{tabular}[c]{C{2cm}}3000-3999\\ (3.8\%)\end{tabular} & \begin{tabular}[c]{C{2cm}}4000-4999\\ (1.5 \%)\end{tabular} & \begin{tabular}[c]{C{2cm}}5000 or more\\ (1.5\%)\end{tabular}  \\ \midrule
Joining motivations                                                           & \begin{tabular}[c]{C{2cm}}Spontaneously\\ (35.3\%)\end{tabular} & \begin{tabular}[c]{C{2cm}}Buy a home\\ (8.9\%)\end{tabular} & \begin{tabular}[c]{C{2cm}}Buy durable goods\\ (22.5 \%)\end{tabular}& \begin{tabular}[c]{@{}c@{\centering}}Children education\\ (9.3\%)\end{tabular} & \begin{tabular}[c]{C{2cm}}Vacation travel\\ (18.9)\end{tabular} & \begin{tabular}[c]{C{2cm}}Pilgrimage\\ (2\%)\end{tabular} & \begin{tabular}[c]{C{2cm}}Other reasons\\ (3.1)\end{tabular}   \\ \midrule
Tolerate a new proposed entrance & \multicolumn{3}{c}{(75.9\%) Yes}                                                                                                                                                                                                                                & \multicolumn{1}{l}{} & \multicolumn{3}{c}{(24.1\%) No} \\ \midrule
Order determining criteria & \begin{tabular}[c]{C{2cm}}Drawing of lots\\ (26.2\%)\end{tabular} & \begin{tabular}[c]{C{2cm}}Agreement of participants\\ (41.8\%)\end{tabular} &  & \begin{tabular}[c]{C{2cm}}Social criteria (age, sexe...)\\ (6\%)\end{tabular} &  & \begin{tabular}[c]{C{2cm}}Financial criteria\\ (21.3\%)\end{tabular} & \begin{tabular}[c]{C{2cm}}Others\\(4.7\%)\end{tabular} \\ \midrule
Tolerate a urgent beneficiary & \multicolumn{3}{c}{(91.9\%) Yes} & \multicolumn{1}{l}{} & \multicolumn{3}{c}{(8.1\%) No} \\ \midrule
RoSCA or low interest rate bank loan ? & \multicolumn{3}{c}{\begin{tabular}[c]{C{2cm}}RoSCA\\ (74.1\%)\end{tabular}} & \multicolumn{1}{l}{} & \multicolumn{3}{c}{\begin{tabular}[c]{C{2cm}}Low interest rate bank loan\\ (25.9\%)\end{tabular}}                                                                                                                                           \\ \midrule
Respondents prefering RoSCA are motivated by & Administrative procedures (28.3\%) & Interest free \& no fees (47.3\%) & Religious conviction (19.1\%) & Other reasons (5.3\%) & \\ \bottomrule
\end{tabular}
}
\end{table}

%%%%%%%%%%%%%%%%%




\end{document}

Edit A improved solution: All other stuff is left to the OP

Such tables are really error-prone!

\documentclass{article}


\usepackage{graphicx}
\usepackage{booktabs}
\usepackage{array}
\usepackage{siunitx}
\usepackage{multirow}

\newcommand{\permarkup}[1]{(\SI{#1}{\percent})}

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

\begin{document}

\begin{table}[h]
\centering
\caption{Sample descriptive statistics}
\label{Sample descriptive statistics}
\resizebox{\textwidth}{!}{%
  \def\arraystretch{1.5}
\begin{tabular}{L{4cm}*{7}{p{2cm}}}
\toprule
Current/former member of a RoSCA & {\permarkup{53,9} Yes} & {\permarkup{46,1} No} \tabularnewline \midrule
\multirow{2}{4cm}{Number of members of joined RoSCA} & \textless 5  & 6-10 & 11-15     & & 16-20  & 21-25 & 26 or more \tabularnewline
& \permarkup{ 27.7 }  &  \permarkup{51.1 } &  \permarkup{10.9 } & & \permarkup{ 3.6 } & \permarkup{ 1.5} &  \permarkup{0.0} \tabularnewline
\midrule
\multirow{2}{4cm}{Contribution's frequency} & Daily  & & Weekly  & & Monthly  & & Other \tabularnewline 
& \permarkup{ 3.7} & & \permarkup{ 10.4} & & \permarkup{ 85.7} & &  \permarkup{0.2} \tabularnewline
\midrule
\multirow{2}{4cm}{Subscription amount (in MAD)} & \textless 500 & 500-999 & 1000-1999 & 2000-2999 & 3000-3999  & 4000-4999  & 5000 or more  \tabularnewline 
& \permarkup{ 32.6 } & \permarkup{ 24.2 } & \permarkup{ 28} & \permarkup{8.3}& \permarkup{3.8} & \permarkup{1.5} & \permarkup{1.5} \tabularnewline
\midrule
\multirow{2}{4cm}{Joining motivations} & Spontaneously & Buy a home & Buy durable goods & Children education & Vacation travel & Pilgrimage & Other reasons\tabularnewline
& \permarkup{35.3} & \permarkup{8.9} & \permarkup{22.5} & \permarkup{9.3} & \permarkup{18.9} & \permarkup{2} & \permarkup{3.1} \tabularnewline
\midrule
%\multicolumn{8}{c}{} \tabularnewline
Tolerate a new proposed entrance & \multicolumn{3}{c}{\permarkup{75.9}  Yes} & \multicolumn{1}{l}{} & \multicolumn{3}{c}{\permarkup{24.1}  No} \tabularnewline

\midrule
\multirow{3}{4cm}{Order determining criteria} & Drawing of lots & \multicolumn{2}{L{4cm}}{Agreement of participants} &   \multicolumn{2}{L{4cm}}{Social criteria (age, sexe...)}   & Financial criteria & Others  \tabularnewline
& \permarkup{26.2} & \permarkup{41.8} &  & \permarkup{6} &  & \permarkup{21.3} & \permarkup{4.7}  \tabularnewline \midrule
Tolerate a urgent beneficiary & \multicolumn{3}{c}{\permarkup{91.9}  Yes} & \multicolumn{1}{l}{} & \multicolumn{3}{c}{\permarkup{8.1}  No} \tabularnewline 
\midrule
RoSCA or low interest rate bank loan ? & \multicolumn{3}{c}{RoSCA\permarkup{74.1} } & \multicolumn{1}{l}{} & \multicolumn{3}{c}{Low interest rate bank loan\permarkup{25.9}} \tabularnewline 
\midrule
\multirow{2}{4cm}{Respondents prefering RoSCA are motivated by} & \multicolumn{2}{C{4cm}}{Administrative procedures} & \multicolumn{2}{C{4cm}}{Interest free \& no fees } & \multicolumn{2}{C{4cm}}{Religious conviction}  & Other reasons   \tabularnewline
& \multicolumn{2}{C{4cm}}{\permarkup{28.3}}  & \multicolumn{2}{C{4cm}}{\permarkup{47.3}} & \multicolumn{2}{C{4cm}}{\permarkup{19.1}} & \permarkup{5.3}  \tabularnewline
\bottomrule
\end{tabular}
}
\end{table}
\end{document}

enter image description here

2

This suggestion is based on use of makecell, multirow and tabu packages. The first two are used to compose multi row cells in the first table column, package tabu simplify determination of column width as well vertical placing of cell's content. I all other cells the content is write directly, with excaption of multi column cells:

\documentclass{article}
    \usepackage[margin=20mm]{geometry}
    \usepackage{caption}

    \usepackage{amsmath}

    \usepackage{makecell,multirow,tabu}
\newcommand\mrc[2]{\multirowcell{#1}[0pt][l]{#2}}
    \usepackage{stackengine}

    \begin{document}
%---------------------------------------------------------------%
    \footnotesize\sffamily
    \renewcommand{\arraystretch}{1.6}
    \setlength{\tabcolsep}{3pt}
    \abovetabulinesep=2mm
    \belowtabulinesep=2mm
    \tabulinestyle{0.2pt on 4pt off 1pt}
%\begin{tabu}to \textwidth{|X[1.5,l,m]|X[1,c,m]|X[3.5,l,m]|}
\begin{tabu}to \linewidth{@{}|
                 >{\bfseries}X[1.95,l,m]|
                             X[1.05,c]
                             X[1.00,c]X[1.00,c]X[1.00,c]X[1.00,c]X[1.00,c]
                             X[1.00,c]|@{}}
    \tabucline[1.5pt]{-}
Current/former member of a RoSCA
& (53,9\;\%) Yes    & (46,1\;\%) No &       &       &           &           &   \\  
    \tabucline{-}    
\mrc{2}{Number of members\\ of joined RoSCA }
& \textless 5       & 6-10          & 11-15 &       & 16-20     & 21-25     & 26 or more    \\
& (27.7\;\%)        & (51.1\;\%)    & (10.9\;\%)
                                            &       & (3.6\;\%) & (1.5\;\%)  & (0.0\%)
    \\  \tabucline{-}
\mrc{2}{Contribution's\\ frequency}
& Daily         &           & Weekly    &           & Monthly   &           & Other         \\
& (3.7\;\%)     &           & (10.4\;\%)&           & (85.7\;\%)&           & (0.2\;\%)
    \\ \tabucline{-}
\mrc{2}{Subscription\\ amount (in MAD)}
& \textless 500 & 500-999   & 1000-1999 & 2000-2999 & 3000-3999 & 4000-4999 & 5000 or more  \\
& (32.6\;\%)    & (24.2\;\%)&  (28\;\%) & (8.3\;\%) & (3.8\;\%) & (1.5\;\%) & (1.5\;\%)
    \\  \tabucline{-}
\mrc{2}{Joining motivations}
& Spontaneously & Buy a home& Buy durable goods
                                        & Children education
                                                    & Vacation travel
                                                                & Pilgrimage & Other reasons \\
& (35.3\%)      & (8.9\;\%) & (22.5\;\%)& (9.3\;\%) & (18.9\;\%)& (2\;\%)    & (3.1\;\%)
    \\ \tabucline -
Tolerate a urgent beneficiary
& \multicolumn{3}{c|}{Yes}              &(8.1\;\%) No&(91.96\;\%)&           &
    \\  \tabucline{-}
\mrc{2}{RoSCA or low interest\\ rate bank loan ?}
& \multicolumn{3}{c|}{RoSCA}
                &           & \multicolumn{3}{|c|}{Low interest rate bank loan} \\
& \multicolumn{3}{c|}{(74.16\;\%)}
                &           & \multicolumn{3}{|c|}{(25.96\;\%)}
    \\  \tabucline{-}
\mrc{1}{Respondents preferring\\ RoSCA are motivated by}
& Administrative procedures (28.36\;\%)             
                & Interest free \& no fees (47.36\;\%) 
                            & Religious conviction (19.16\;\%) 
                                        & Other reasons (5.36\;\%)
                                                    &   &   &    
    \\  \tabucline[1.5pt]{-}
    \end{tabu}
%---------------------------------------------------------------%
        \end{document}

I didn't put table in table float environment (this should be trivial task).

Since your table is huge, I reduce font size to \footnotesize and select sffamily fonts which is slightly narrower than serif fonts.

For seeing multi column cells range, I introduce shadow vertically lines. If they are disturbing, just erase them

enter image description here

In table I missing column heads (what is in particular column). They cab be put in \thead{..} macro from makecell package.

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.