# Merge Cells in LaTex [duplicate]

How to make a table like this? I have tried many ways to do it but all are failed. I am so confused. Thank you so much for any reply.

• You should include a minimal working example (tex.meta.stackexchange.com/questions/228/…) with your question. What have you tried? Take a look at \multicolumn and \multirow
– bp99
Nov 30, 2020 at 16:15
• For the rules: \usepackage{booktabs} the first rule is \toprule, the second \midrule, then \cmidrule{2-8}, \midrule, \cmidrule{2-8} and \bottomrule. Nov 30, 2020 at 16:20
• Also, while \multirow is an option, most of the time it only makes things more complicated. In your header, you can use \makecell (from the eponymous package) for those which need two rows. The things from columns 1 and 2 I'd just top align. Nov 30, 2020 at 16:22
• Thank you so much for your reply. However, I am newer to LaTex, could you please give a detailed explanation? Nov 30, 2020 at 16:24

The following is how I'd recreate your table (but with top-aligned contents for the columns 1 and 2).

I use booktabs for the rules, siunitx for the S-type columns which nicely align numbers, amsmath is just loaded for \boldsymbol to get a bold >, and I defined a macro for the table headers myself, to format all of them the same way (you could've used makecell and its \thead here as well).

\documentclass[border=3.14]{standalone}

\usepackage{booktabs}
\usepackage{siunitx}
\usepackage[]{amsmath}

\begin{document}
\begin{tabular}{cccS[table-format=3]*{4}{S[table-format=1]}}
\toprule
& {\myhead{Prob$\boldsymbol{>}$F}} \\
\midrule
&&\myhead{Total} & 189 & 1 & & & \\
\cmidrule{2-8}
&\myhead{Levene's Test} & \myhead{Model} & 9 & 1 & 1 & 1 & 1 \\
&&\myhead{Error} & 180 & 1 & 1 & & \\
\midrule[\heavyrulewidth]
&&\myhead{Total} & 189 & 1 & & & \\
\cmidrule{2-8}
&\myhead{Levene's Test} & \myhead{Model} & 18 & 1 & 1 & 1 & 1 \\
&&\myhead{Error} & 171 & 1 & 1 & & \\
\bottomrule
\end{tabular}
\end{document}