2

I want to create a similar table as in image. I don't know how to customize table border thickness and color scheme as in picture to achieve the desired output.enter image description here

Code: How many rows should i span 4 or 5? For "Age", I have given {5} as parameter to \multirow. Is it correct?

    \newcolumntype{y}{>{\bfseries\arraybackslash}m{4cm}}
\newcolumntype{L}{>{\centering\arraybackslash}m{3.5cm}}
\begin {table}
\caption{Demographic Profiles of Participants} 
\begin{center}
\begin{tabular}{ |y | L | L | L | >{$} Sr <{$}}
\hline
Socio Demographic Factors & \textbf{Ranges} & \textbf{Frequency} & \textbf{Responses (\%)} \\ \hline
\multirow{5}{3em}{\textbf{AGE}} & 18-25 YEARS  &    84  & 57 \\ 
    & 26-35 YEARS   & 32    & 22 \\
    & 36-45 YEARS   & 11    & 7 \\
    & 46-55YEARS    & 14    & 9 \\
    & 56-ABOVE      & 7         & 5 \\ \hline
\multirow{1}{7em}{GENDER}   & MALE  & 87 & 59\\
    & FEMALE    & 61    & 41 \\ \hline
\multirow{5}{7em}{COMPUTER PROFICIENCY LEVEL}   & LESS THAN 1 YEAR &    5   & 3 \\
    & 1 TO 3 YEARS  & 37    & 25 \\
    & 4 TO 6 YEARS  & 43    & 29 \\
    & 7 TO 9YEARS   & 25    & 17 \\
    & MORE THAN 9 YEARS & 42    &28 \\ \hline
\multirow{4}{7em}{EDUCATION}    &UNDER GRADUATE STUDENT (HONS)  & 5  &  3 \\
    & GRADUATE STUDENT (HONS)   & 67    & 45 \\ 
    & POST GRADUATE STUDENT & 37    & 25 \\
    & DOCTORATE STUDENTS    & 18    & 12 \\ \hline
\multirow{2}{3em}{COMPUTER  EXPERIENCE} & YES   & 101   & 68 \\
    & NO    & 47    & 32 \\ \hline
\multirow{2}{7em}{MAJOR DISCIPLINE} & IT STUDENTS   & 42    & 48 \\
    & NON-IT STUDENTS    & 59   & 42 \\ \hline

\end{tabular}
\end{center}
\end{table}
  • Hi and welcome, if you want to, you can have a look at the documentation of package booktabs. There are some hints and tips in there to produce nice looking tables. For example, you don't have to put the percent sign (which you can print as \%) in every single cell of a column. Once is enough. – Johannes_B Oct 3 '14 at 22:20
  • For column padding, see Column and row padding in tables. – Werner Oct 3 '14 at 22:46
1

Package multirow expect that you declare number of lines (not rows) which followed multirow cell. In your case: for AGE: 5, for GENDER: 2, for COMPUTER ... 5, for Education: 7, etc. Generally this mean, that you should count lines after table is generated and than correct number of spanned lines. For example as I do here:

\documentclass{article}
    \usepackage{array,multirow}
\begin{document}
    \newcolumntype{y}{>{\bfseries\arraybackslash}m{4cm}}
    \begin {table}
\caption{Demographic Profiles of Participants}
    \centering
\begin{tabular}{ |y|>{\raggedright}p{4cm}|c|c<{\%}|}
    \hline
\centering
Socio Demographic Factors
    &   \multicolumn{1}{c|}{\textbf{Ranges}}
                            & \textbf{Frequency}
                                    & \textbf{Responses (\%)} \\ \hline
\multirow{5}{4cm}{\textbf{AGE}}
    & 18-25 YEARS           & 84    & 57    \\
    & 26-35 YEARS           & 32    & 22    \\
    & 36-45 YEARS           & 11    & 7     \\
    & 46-55YEARS            & 14    & 9     \\
    & 56-ABOVE              & 7     & 5     \\  \hline
\multirow{1}{4cm}[-1.5ex]{GENDER}
    & MALE                  & 87    & 59    \\
    & FEMALE                & 61    & 41    \\  \hline
\multirow{5}{4cm}{COMPUTER PROFICIENCY LEVEL}
    & LESS THAN 1 YEAR      & 5     & 3     \\
    & 1 TO 3 YEARS          & 37    & 25    \\
    & 4 TO 6 YEARS          & 43    & 29    \\
    & 7 TO 9YEARS           & 25    & 17    \\
    & MORE THAN 9 YEARS     & 42    & 28    \\  \hline
\multirow{7}{4cm}{EDUCATION}
    &UNDER GRADUATE STUDENT (HONS)
                            & 5     &  3    \\
    & GRADUATE STUDENT (HONS)
                            & 67    & 45    \\
    & POST GRADUATE STUDENT & 37    & 25    \\
    & DOCTORATE STUDENTS    & 18    & 12    \\  \hline
\multirow{2}{4cm}{COMPUTER EXPERIENCE}
    & YES                   & 101   & 68    \\
    & NO                    & 47    & 32    \\  \hline
\multirow{2}{4cm}{MAJOR DISCIPLINE}
    & IT STUDENTS           & 42    & 48    \\
    & NON-IT STUDENTS       & 59    & 42    \\  \hline
\end{tabular}
    \end{table}
\end{document} 

Simpler task you have, if all rows after multirow cell has only one line. IN this case you should for second column use l instead p type of column. For other possibility follow link provided by Johannes_B.

I also little bit simplified table construction.

0
  1. For the color rules of the tables, some like this in the preamble:

    \usepackage{colortbl} \arrayrulecolor{blue!70}

  2. For customize the thickness of the rules and vertical padding around, you can use the package booktabs and the command \specialrule{}{}{} with three arguments: thickness, space above and space below.

  3. Yes, five is correct. You have 5 levels (rowas) for he factor "age" and the first argument of \multirow must be the number of these rows.

  4. About the padding, the Werner's link is more than enough. I I would emphasize here the tabularx and tabulary packages.

Solved this, well ... there's no accounting for taste, but your table for me is the example of what should not do (I am afraid that for other people too). Therefore, some suggestions:

  1. Avoid the vertical lines (ideal number: 0. When? always)

  2. Avoid most horizontal lines (ideal number: 3) one \toprule, one \bottomrule, and one \midrule is enough for simple tables. Complex tables could have more \midrules or \cmidrules, but less (lines) is more (clear) in most cases.

  3. Avoid tick rules in the middle of the table, a \midrule is enough .

  4. Avoid uppercase or small caps in normal cells (well, in headers cells too..). Left capital letters only for a very strong emphasis (TITLE), acronyms, etc.

  5. Make the table as simple and clear as possible. For example: If all the cells of the column have the same unit of measurement, this can be showed in the header of the column and not overshadow the cells numbers. "< 9 years" is as informative as "MORE THAN 9 YEARS" but take less space. Use -- instead of a single - for ranges. "Socio Demographic Factors" is too long for a single row, and a multrow her is ugly, but you can omit this header with a more informative caption.

The results this these rules in mind could be some like this:

MWE

\documentclass{article}
\usepackage{array,multirow,booktabs,mathtools,tabulary,xcolor}
%\usepackage[table]{xcolor}
\usepackage{colortbl}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\let\belowcaptionskip\abovecaptionskip
\let\oldmidrule\midrule

\arrayrulecolor{blue!70} 

\begin{document}

\begin {table}
\caption{Demographic profiles of participants according to the socio demographic factors.} 
\centering
\begin{tabulary}{\textwidth}{>{\bfseries}LlRR} 
\toprule  & \textbf{Ranges} & \mbox{\textbf{Frequency}} & \mbox{\textbf{Responses (\%)}}\\
\midrule \multirow{5}{.2\textwidth}{Age} & 18-25 years & 84 & 57 \\
  & 26--35 years & 32 & 22 \\
  & 36--45 years & 11 & 7 \\
  & 46--55 years & 14 & 9 \\
  &  < 56 years  & 7 & 5 \\
  \midrule \multirow{2}{.2\textwidth}{Gender} & Male & 87 & 59\\
  & Female & 61 & 41 \\
 \midrule \multirow{5}{.2\textwidth}{Computer\newline proficiency\newline level} & < 1 year & 5 & 3 \\
  & 1 to 3 years & 37 & 25 \\
  & 4 to 6 years & 43 & 29 \\
  & 7 to 9years & 25 & 17 \\
  & $>$ 9 years & 42 &28 \\
  \midrule \multirow{4}{.2\textwidth}{Education} & Under graduate (hons) & 5 & 3 \\
  & Graduate  (hons) & 67 & 45 \\
  & Post graduate  & 37 & 25 \\
  & Doctorate & 18 & 12 \\
  \midrule \multirow{2}{.2\textwidth}{Computer experience} & Yes & 101 & 68 \\
  & No & 47 & 32 \\
  \midrule \multirow{2}{.2\textwidth}{Major discipline} & IT students & 42 & 48 \\
  & Non-IT students & 59 & 42 \\
  \bottomrule
\end{tabulary}
\end{table}

\end{document}

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.