Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I want my table to look like the one below: enter image description here

But this is what is turning out: enter image description here

Here’s an MWE:

\documentclass{article}

\usepackage{multirow}

\begin{document}

\begin{tabular}{|c|c|c|}
\cline{1-3}
\multicolumn{1}{c}{} & \multicolumn{2}{c}{Treatment Received}\\ \cline{2-3}
& All Respondents & Prejudiced Respondents\\ \hline
Culturally Foreign &    25.6 & 44.4\\ 
Culturally Familiar & 20.0 & 19.0\\
Difference & 5.6 & 25.4*\\
(95\% Confidence Interval) & (-1.1 to 12.4) & (6.6 to 44.1)\\
p-value & 0.101  & 0.009\\ \hline
\end{tabular}

\end{document}
share|improve this question

2 Answers 2

up vote 5 down vote accepted

You're forgetting a | in the argument to \multicolumn and have a useless \multicolumn{1}{c}{}; when a cell is empty, just place nothing in it.

The first column should be left aligned. I also propose a different way to format the table, without any vertical rule (this second way requires booktabs). Also I wouldn't use \doublespace, you just lose in readability.

\documentclass{article}
\usepackage{booktabs}

\begin{document}
\begin{tabular}{|l|c|c|}
\hline
  & \multicolumn{2}{c|}{Treatment Received}\\
\cline{2-3}
  & All Respondents & Prejudiced Respondents\\
\hline
  Culturally Foreign  & $25.6$ & $44.4$\\ 
  Culturally Familiar & $20.0$ & $19.0$\\
  Difference          &  $5.6$ & $25.4$\makebox[0pt][l]{*}\\
  ($95$\% Confidence Interval) & ($-1.1$ to $12.4$) & ($6.6$ to $44.1$)\\
  $p$-value           & $0.101$  & $0.009$\\
\hline
\end{tabular}

\bigskip

\begin{tabular}{lcc}
\toprule
  & \multicolumn{2}{c}{Treatment Received}\\
\cmidrule{2-3}
  & All Respondents & Prejudiced Respondents\\
\midrule
  Culturally Foreign  & $25.6$ & $44.4$\\ 
  Culturally Familiar & $20.0$ & $19.0$\\
  Difference          &  $5.6$ & $25.4$\makebox[0pt][l]{*}\\
  ($95$\% Confidence Interval) & ($-1.1$ to $12.4$) & ($6.6$ to $44.1$)\\
  $p$-value           & $0.101$  & $0.009$\\
\bottomrule
\end{tabular}


\end{document}

enter image description here

Note also how I typed the asterisk, so that it doesn't participate in the alignment. Also, numbers should be typed in math mode, particularly if they are negative.

share|improve this answer
1  
+1 for using booktabs –  alexwlchan Mar 21 at 16:56
1  
@alexwlchan I always use it and never use \multirow. ;-) –  egreg Mar 21 at 16:57
    
Well well, enjoy...! :) –  Werner Mar 21 at 16:58

When you define the alignment for the uses of \multicolumn (this is the {c}), you need to tell it what vertical borders you want around them (just like when you write {|c|c|c|} at the begin of the table).

So replace the line

\multicolumn{1}{c}{} & \multicolumn{2}{c}{Treatment Received}\\ \cline{2-3}

with

\multicolumn{1}{|c}{} & \multicolumn{2}{c|}{Treatment Received}\\ \cline{2-3}

Notice that {c} has become {|c} and {c|}.

This is what the result looks like:

enter image description here

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.