0

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. enter image description here

campa
  • 31,130
pan xia
  • 91
  • You should include a minimal working example (https://tex.meta.stackexchange.com/questions/228/ive-just-been-asked-to-write-a-minimal-working-example-mwe-what-is-that) with your question. What have you tried? Take a look at \multicolumn and \multirow – bp99 Nov 30 '20 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. – Skillmon Nov 30 '20 at 16:20
  • 3
    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. – Skillmon Nov 30 '20 at 16:22
  • Thank you so much for your reply. However, I am newer to LaTex, could you please give a detailed explanation? – pan xia Nov 30 '20 at 16:24

1 Answers1

0

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}

\newcommand\myhead[1]{\myheadset\begin{tabular}[c]{@{}c@{}}#1\end{tabular}} \newcommand\myheadset{\bfseries}

\begin{document} \begin{tabular}{cccS[table-format=3]*{4}{S[table-format=1]}} \toprule \myhead{Type} & & & {\myhead{DF}} & {\myhead{Sum of\Squares}} & {\myhead{Mean\Squares}} & {\myhead{F Value}} & {\myhead{Prob$\boldsymbol{>}$F}} \ \midrule \myhead{City} & \myhead{Overall} & \myhead{Model} & 9 & 1 & 1 & 1 & 1 \ \myhead{Group} & \myhead{ANOVA} & \myhead{Error} & 180 & 1 & 1 & & \ &&\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{Year} & \myhead{Overall} & \myhead{Model} & 18 & 1 & 1 & 1 & 1 \ \myhead{Group} & \myhead{ANOVA} & \myhead{Error} & 171 & 7 & 1 & & \ &&\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}

enter image description here

Skillmon
  • 60,462