0

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

  • 4
    It would help if, in addition to saying which parts you don't know, you explained which parts you know how to do already. This is best demonstrated through the addition of some basic code in the form of an MWE. But: Do you know how to make a longtable? What about the coloured rows? (The booktabs 'parts' here look to me like \toprule, \midrule, and \bottomrule.) – jon Nov 16 '17 at 4:08
2

Here'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}

enter image description here

I don't think that the stripes are good, though, so I also add the “stripe free” version (removing \rowcolors and \rowcolor commands).

enter image description here

0

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} 

The resulting table looks like this: enter image description here

  • 1
    You should use the \specialrule command to eliminate the white strips below \midrules (they use custom values for \aboveryulesep and \belowrulesep. – Bernard Nov 16 '17 at 10:23
  • Thanks! I have updated the example. I have also incorporated the nice add-ons of @egreg – dafrick Nov 16 '17 at 15:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.