I don't really know how to make tables with booktabs
and other posts on this don't seem to help me too much.
I have to make a table similar to the one with the image below. How would I get on with something like this?
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It only takes a minute to sign up.
Sign up to join this communityHere's an implementation using also siunitx
. You should adjust the settings for table-format
according to the real data.
\documentclass{article}
\usepackage[margin=1in,landscape]{geometry}
\usepackage[table]{xcolor}
\usepackage{booktabs,siunitx}
\usepackage{caption}
\newcommand{\splitcell}[1]{%
\begingroup
\renewcommand{\arraystretch}{1}%
\begin{tabular}{@{}c@{}}#1\end{tabular}%
\endgroup
}
\captionsetup{font=bf}
\begin{document}
\begin{table}[htp]
\caption{Processed Data}
\renewcommand{\arraystretch}{1.2}
\rowcolors{1}{gray!30}{white}
\begin{tabular}{
S[table-format=2.0]
*{3}{% fix here the values
S[table-format=1.0]
S[table-format=1.0]
S[table-format=1.0]
}
}
\toprule
\rowcolor{white}
{\splitcell{Number of sheets of \\ Dielectric Material}} &
\multicolumn{3}{c}{Dry Paper (C)/\si{pF} \SI{\pm 0.01}{\percent}} &
\multicolumn{3}{c}{Waxed Paper (C)/\si{pF} \SI{\pm 0.01}{\percent}} &
\multicolumn{3}{c}{Impregnated Paper (C)/\si{pF} \SI{\pm 0.01}{\percent}} \\
\cmidrule(lr){2-4}\cmidrule(lr){5-7}\cmidrule(lr){8-10}
\rowcolor{white}
& {Average} & {\splitcell{Standard \\ Deviation}} & {\splitcell{Absolute \\ Uncertainty}}
& {Average} & {\splitcell{Standard \\ Deviation}} & {\splitcell{Absolute \\ Uncertainty}}
& {Average} & {\splitcell{Standard \\ Deviation}} & {\splitcell{Absolute \\ Uncertainty}} \\
\midrule
8 & 1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9 \\
16 & 1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9 \\
24 & 1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9 \\
32 & 1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9 \\
\specialrule{\lightrulewidth}{0pt}{0pt}
40 & 1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9 \\
48 & 1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9 \\
56 & 1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9 \\
64 & 1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9 \\
\specialrule{\lightrulewidth}{0pt}{0pt}
72 & 1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9 \\
80 & 1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9 \\
88 & 1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9 \\
96 & 1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9 \\
\specialrule{\heavyrulewidth}{0pt}{0pt}
\end{tabular}
\end{table}
\end{document}
I don't think that the stripes are good, though, so I also add the “stripe free” version (removing \rowcolors
and \rowcolor
commands).
The wiki for LaTeX/Tables is a great resource: https://en.wikibooks.org/wiki/LaTeX/Tables
To create the above table you need to combine a few different packages for tables. Below is a small working example that you should be able to expand to cover your case.
\documentclass{article}
\usepackage[margin=1in,landscape]{geometry}
\usepackage{tabu}
\usepackage{booktabs}
\usepackage{longtable}
\usepackage{varwidth}
\usepackage[table]{xcolor}
\usepackage{siunitx}
\newcolumntype{M}[1]{>{\begin{varwidth}{#1}\centering}c<{\end{varwidth}}}
\newcolumntype{x}{>{\centering\arraybackslash}X}
\colorlet{rowColorBase}{white}
\colorlet{rowColorAlternate}{gray!20}
\begin{document}
\begin{center}
\textbf{Table 1: Processed Data}
\rowcolors{1}{rowColorAlternate}{rowColorBase}
\begin{longtabu} to \linewidth {@{}M{3.1cm}*{3}{xxx}@{}}
% Table header, repeated at every page
\toprule
Number of sheets of Dielectric Material & \multicolumn{3}{c}{Dry Paper (C)\si{pF} \SI{\pm 0.01}{\percent}} & \multicolumn{3}{c}{Waxed Paper (C)\si{pF} \SI{\pm 0.01}{\percent}} & \multicolumn{3}{c}{Impregnated Paper (C)\si{pF} \SI{\pm 0.01}{\percent}} \\
\midrule
\rowcolor{rowColorBase} & Average & Standard Deviation & Absolute Uncertainty & Average & Standard Deviation & Absolute Uncertainty & Average & Standard Deviation & Absolute Uncertainty\\
\endhead
% Table footer, repeated at every page except last
\multicolumn{10}{r}{Table continues on next page} \\
\endfoot
% Final table footer on last page
\specialrule{\heavyrulewidth}{0pt}{0pt}
\endlastfoot
% Table content
\specialrule{\lightrulewidth}{0pt}{0pt}
8 & 1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9 \\
16 & 1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9 \\
24 & 1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9 \\
32 & 1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9 \\
\specialrule{\lightrulewidth}{0pt}{0pt}
40 & 1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9 \\
48 & 1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9 \\
56 & 1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9 \\
64 & 1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9 \\
\specialrule{\lightrulewidth}{0pt}{0pt}
72 & 1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9 \\
80 & 1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9 \\
88 & 1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9 \\
96 & 1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9 \\
\end{longtabu}
\end{center}
\end{document}
\specialrule
command to eliminate the white strips below \midrule
s (they use custom values for \aboveryulesep
and \belowrulesep
.
longtable
? What about the coloured rows? (Thebooktabs
'parts' here look to me like\toprule
,\midrule
, and\bottomrule
.)