# Latex table subdivided columns and rows

I'm new to Latex and am working TexShop on a MAC OS.

I wanted to create a table with subdivided columns and rows to describe my data, but I seem to have no luck trying to do it with the help of booktabs or array. Basically creating the column where i divide Group A into two more columns, and group B into two more columns is where I'm stuck.

EDIT: I want to make the titles bold and colour the table, like we can in Word or Powerpoint. Also, I want to get rid of the horizontal line on the two ends of the top row.

    \documentclass{article}
\usepackage{tabularx}
\usepackage{array}
\usepackage{multirow}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[english,italian]{babel}
\usepackage{booktabs}
\usepackage{caption}
\usepackage[bindingoffset=1.5cm, left=3cm, right=3cm, top=3cm, bottom=3cm]{geometry}
\newlength\Colwd
\setlength\Colwd{1.2cm}

\begin{document}

\begin{tabular}{|c|c|c|c|c|c|}
\hline
& \multicolumn{2}{|l|}{Affected} & \multicolumn{2}{|l|}{Unaffected} & Total\\
\hline
\hline
Male & 144&15&34&89&282\\
Female & 37&6&66&109&218\\
Total&181&21&99&198&500\\
\hline
\end{tabular}
\end{document}


I would do something like the following:

• use booktabs (toprule, midrule, cmidrule, bottomrule)
• do not center-align numbers (mostly they should be right-aligned)
• remove unnecessary boundaries (lines, horizontally and vertically)
• put a headline above every column

Code:

\documentclass{article}
\usepackage[english,italian]{babel}
\usepackage{tabularx}
\usepackage{array}
\usepackage{multirow}
\usepackage{booktabs}
\usepackage{caption}
\usepackage[bindingoffset=1.5cm, left=3cm, right=3cm, top=3cm, bottom=3cm]{geometry}

\begin{document}

\begingroup
\renewcommand{\arraystretch}{1.1}
\begin{tabular}{lrrrrr}
\toprule
Gender& \multicolumn{2}{c}{Affected} & \multicolumn{2}{c}{Unaffected} & Total\\
\cmidrule(lr){2-3}\cmidrule(lr){4-5}

• @Ar1229 No, it does not show up, because you do not use the table environment around tabular and do not have a caption. – TeXnician Aug 14 '17 at 17:27
• Okay thats why my \caption{Demogrpahics} didnt work. Any tips on how I can get it to come up? – Ar1229 Aug 14 '17 at 17:30
• @Ar1229 (1) Use the table environment around tabular and caption. or (2) use the caption package and add \captionof{figure}{Demographics}. – TeXnician Aug 14 '17 at 17:32