I've created this table using a table converter website online and then tweaking it until I got what I wanted. I am using overleaf to compile everything.
\begin{table}[h!]
\caption{Composition of the study sample in the pre-Black Death period by site.}\label{Table5.2}
\begin{tabular}{@{}llccccc@{}}
\toprule
\textbf{Region}& \textbf{Site}& \multicolumn{2}{c}{\textbf{Early pre-}}& \multicolumn{2}{c}{\textbf{Late pre-}}& \textbf{Total}\\
\textbf{}& \textbf{}& \multicolumn{2}{c}{\textbf{Black Death}}& \multicolumn{2}{c}{\textbf{Black Death}}& \textbf{}\\
\textbf{}& \textbf{}& \textbf{n}& \textbf{\%}& \textbf{n}& \textbf{\%}& \textbf{N}\\ \hline
\textbf{Extra-London} & \cellcolor[HTML]{E7E6E6}\textbf{Wharram Percy}& \cellcolor[HTML]{E7E6E6}7& \cellcolor[HTML]{E7E6E6}12.07 & \cellcolor[HTML]{E7E6E6}51& \cellcolor[HTML]{E7E6E6}87.93 & \cellcolor[HTML]{E7E6E6}58\\
\textbf{}& \textbf{St Oswald's}& 44& 29.33 & 106 & 70.67 & 150 \\
\textbf{}& \cellcolor[HTML]{E7E6E6}\textbf{St Anne's Charterhouse} & \cellcolor[HTML]{E7E6E6}0& \cellcolor[HTML]{E7E6E6}& \cellcolor[HTML]{E7E6E6}0& \cellcolor[HTML]{E7E6E6}& \cellcolor[HTML]{E7E6E6}0\\
\textbf{}& \textbf{Barton Upon Humber}& 197 & 66.33 & 100 & 33.67 & 297 \\
\textbf{}& \cellcolor[HTML]{E7E6E6}\textbf{Stoke Quay}& \cellcolor[HTML]{E7E6E6}191 & \cellcolor[HTML]{E7E6E6}35.97 & \cellcolor[HTML]{E7E6E6}340 & \cellcolor[HTML]{E7E6E6}64.03 & \cellcolor[HTML]{E7E6E6}531 \\ \cline{2-7}
\textbf{}& \textbf{Subtotal}& 439 & 42.37 & 597 & 57.63 & 1036 \\
\midrule
\textbf{London}& \cellcolor[HTML]{E7E6E6}\textbf{Guildhall Yard}& \cellcolor[HTML]{E7E6E6}10& \cellcolor[HTML]{E7E6E6}27.03 & \cellcolor[HTML]{E7E6E6}27& \cellcolor[HTML]{E7E6E6}72.97 & \cellcolor[HTML]{E7E6E6}37\\
\textbf{}& \textbf{East Smithfield}& 0&& 0&& 0\\
\textbf{}& \cellcolor[HTML]{E7E6E6}\textbf{Merton Priory}& \cellcolor[HTML]{E7E6E6}0& \cellcolor[HTML]{E7E6E6}0& \cellcolor[HTML]{E7E6E6}37& \cellcolor[HTML]{E7E6E6}100& \cellcolor[HTML]{E7E6E6}37\\
\textbf{}& \textbf{St Mary Graces}& 0&& 0&& 0\\
\textbf{}& \cellcolor[HTML]{E7E6E6}\textbf{Spital Square} & \cellcolor[HTML]{E7E6E6}0 & \cellcolor[HTML]{E7E6E6}& \cellcolor[HTML]{E7E6E6}40& \cellcolor[HTML]{E7E6E6} 100 & \cellcolor[HTML]{E7E6E6}40\\ \cline{2-7}
\textbf{}& \textbf{Subtotal}& 10& 8.77& 104 & 91.23 & 114 \\ \hline
\textbf{Total} & & 449 & 39.04 & 701 & 60.96 & 1150\\
\bottomrule
\end{tabular}
\end{table}
The table looks messy, but it compiles. The issue that I have is that after compiling, the table looks like this:
It has all the information I want, but I have a few issues:
- All lines came out right except the second one on top of Extra-London. It should go across the whole graph, but it only covers one cell.
- There is a small white gap under the midline )the one that starts with London). I have seen this a lot and don't know how to remove it.
- The colored cells extend further than the lines and margin. I want the lines and cells to have the same limit at the end of the page's margins.
- I can't be sure but it looks like all the cells don't have the same height, The second subtotal looks shorter than the first one (I may be wrong).
How can I fix these issues? Any advice will be welcomed.
Thank you, Sincerely,
\textbf{}
does nothing, you could simply delete them all, mak your source look a lot more reasonable please see thecolortbl
documentation,\cline
is explicitly not supported. There are things you coud do (usehhline
, or use different table markup such astabularray
But are you sure you want rules and coloured panels, I'd just not use the rules\hline
with\toprule
,\midrule
and\bottomrule
because the latter three (which are defined by thebooktabs
package) have a different spacing. In the case of colored cells, this spacing may look odd.[h!]
unless you really need an exceptional over-ride (!
)