3

My code is as follows:

\usepackage{array}
\usepackage{multirow}
\usepackage{graphicx}
\begin{table}[h]
\centering
\begin{tabular}{>{\centering\arraybackslash}m{1in}|l|l|}
\cline{2-3}
                                                                & \textbf{Hypothesis Testing}   & \textbf{Comparison between}            \\ \hline
\multicolumn{1}{|l|}{\multirow{4}{*}{\textbf{Mean Comparison}}} & One Sample t-test             & a sample mean and known reference mean \\ \cline{2-3} 
\multicolumn{1}{|l|}{}                                          & Two Sample t-test             & means of two groups                    \\ \cline{2-3} 
\multicolumn{1}{|l|}{}                                          & Paired t-test                 & means of two groups for paired data    \\ \cline{2-3} 
\multicolumn{1}{|l|}{}                                          & ANOVA (F-test)                & means of more than two groups          \\ \hline
\multicolumn{1}{|l|}{\textbf{Variance Comparison}}              & Variance test                 & variances of at least two groups       \\ \hline
\multicolumn{1}{|l|}{\textbf{Proportion Comparison}}            & Chi\textsuperscript{2} test & proportions of at least two groups     \\ \hline
\end{tabular}
\end{table}

output is as follows:

Ouput table

But the desired output should be:

Desired output

I have tried the solutions here:

Wrap text and here wrap \multicolum

But nothing works so far. Could someone help me out please.

  • 1
    Use \multirow{4}{1in}{... – user11232 Apr 2 '15 at 15:38
  • It makes the first cell i.e "Mean comparison" wrapped but how can i wrap the cells with "Variance comparison" and "proportion comparison" ??? – walterhunk Apr 2 '15 at 15:43
  • 1
    Please see the answer below. – user11232 Apr 2 '15 at 15:44
4

To have a line break inside \multirow you have to use a length instead of * like

\multirow{4}{1in}{\centering\textbf{Mean Comparison}}

with a \centering. Further, since you are using >{\centering\arraybackslash}m{1in} for first column, all \multicolumn{1}{|l|}{}s are redundant. Removing them will allow the line break and make contents centered as wanted.

\documentclass{article}
\usepackage{array}
\usepackage{multirow}
\usepackage{graphicx}
\begin{document}
\begin{table}[h]
\centering
\begin{tabular}{|>{\centering\arraybackslash}m{1in}|l|l|}
\cline{2-3}
\multicolumn{1}{c|}{}                       & \textbf{Hypothesis Testing} & \textbf{Comparison between}            \\ \hline
\multirow{4}{1in}{\centering\textbf{Mean Comparison}} & One Sample t-test           & a sample mean and known reference mean \\ \cline{2-3}
                                            & Two Sample t-test           & means of two groups                    \\ \cline{2-3}
                                            & Paired t-test               & means of two groups for paired data    \\ \cline{2-3}
                                            & ANOVA (F-test)              & means of more than two groups          \\ \hline
\textbf{Variance Comparison}                & Variance test               & variances of at least two groups       \\ \hline
\textbf{Proportion Comparison}              & Chi\textsuperscript{2} test & proportions of at least two groups     \\ \hline
\end{tabular}
\end{table}
\end{document}

enter image description here

However, your tabular is wider to fit inside the text width. You make consider using p or m type column for the last column. I have not added it since the idea is to reproduce the table in the picture.

  • Works Works Works !!! Thanks for the suggestions as well. :) – walterhunk Apr 2 '15 at 15:51
  • @RahulBalmuri You are welcome :-) – user11232 Apr 2 '15 at 16:02

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.