0
\documentclass[a4paper, 12pt]{article}
\usepackage{booktabs,array}
\usepackage[table]{xcolor}
\usepackage{colortbl}
\usepackage{float}
\usepackage{makecell}
   \begin{document}
      \begin{table}[H]
          \renewcommand\arraystretch{1.5}
            \centering
            \begin{tabular}{ccccccc}
            \toprule
            String Tension & \makecell{Mean \\ Rebound Height} & Uncertainty in $\overline{h_{r}}$ & \makecell{Percentage uncertainty\\ in $\overline{h_{r}}$} & \makecell{Coefficient \\of Restitution} & \makecell{Percentage uncertainty \\in $e$} & Uncertainty in $e$\\
            (T) $\pm$ 5 N & ($\overline{h_{r}}$) / m & $e$ \\
            \midrule
        \rowcolor[rgb]{0.902,0.902,0.902} 
            147 & 1.345 & 2.345 & 2.345& 2.345& 2.345& 2.345\\
           \rowcolor[rgb]{0.949,0.949,0.949}
            196 & 1.345 & 2.345 & 2.345& 2.345& 2.345& 2.345\\
        \rowcolor[rgb]{0.902,0.902,0.902} 
            245 & 1.345 & 2.345 & 2.345& 2.345& 2.345& 2.345 \\
        \rowcolor[rgb]{0.949,0.949,0.949}
            294& 1.345 & 2.345 & 2.345& 2.345& 2.345& 2.345\\
        \rowcolor[rgb]{0.902,0.902,0.902} 
            343& 1.345 & 2.345 & 2.345& 2.345& 2.345& 2.345\\
            \bottomrule
            \end{tabular}
            \caption{Processed Data}
            \label{tab:Raw Data}
        \end{table}
    \end{document}

I tried using the \makecell package, but I could not make it look presentable. Any help would be greatly appreciated.

My Table Currently

Reference Table for first Row

2 Answers2

3

Here is another solution, playing with the value of tabcolsep and the \rothead command from makecell. I also simplified a bit the code with the \rowcolors command from xcolor:

\documentclass[a4paper, 12pt]{article}
\usepackage{geometry}
\usepackage{booktabs,array, rotating}
\usepackage[table, svgnames]{xcolor}
\usepackage{colortbl}
\usepackage{float}
\usepackage{makecell}

\begin{document}

\begin{table} \renewcommand\arraystretch{1.5}\setlength{\tabcolsep}{0pt} \renewcommand{\theadfont}{\small\bfseries\boldmath} \setlength{\rotheadsize}{3.2cm} \renewcommand{\cellrotangle}{64} \centering \rowcolors{3}{Gainsboro!60}{WhiteSmoke} \begin{tabular}{ccccccc} \toprule \rothead{\rlap{String Tension}} & \rothead{Mean \ Rebound Height} & \rothead{\rlap{Uncertainty in $\overline{h_{r}}$}} & \rothead{Percentage\ \rlap{uncertainty in $\overline{h_{r}}$}} & \rothead{\rlap{Coefficient of} \ \rlap{Restitution}} & \rothead{Percentage\ uncertainty in $e$} & \rothead{Uncertainty in $e$}\ (T) $\pm$ 5 N & ($\overline{h_{r}}$) / m & $e$ \ \midrule 147 & 1.345 & 2.345 & 2.345& 2.345& 2.345& 2.345\ 196 & 1.345 & 2.345 & 2.345& 2.345& 2.345& 2.345\ 245 & 1.345 & 2.345 & 2.345& 2.345& 2.345& 2.345 \ 294& 1.345 & 2.345 & 2.345& 2.345& 2.345& 2.345\ 343& 1.345 & 2.345 & 2.345& 2.345& 2.345& 2.345\ \bottomrule \end{tabular} \caption{Processed Data} \label{tab:Raw Data} \end{table}

\end{document}

enter image description here

Bernard
  • 271,350
2

You can decrease the font using the \scriptsize command. Also, you can divide your table head into more lines.

enter image description here

\documentclass[a4paper, 12pt]{article}

\usepackage[table]{xcolor} \usepackage{makecell} \usepackage{array, booktabs}

\begin{document} \begin{table}%[H] \scriptsize \renewcommand\arraystretch{1.5} \centering \begin{tabular}{ccccccc} \toprule \thead{String \Tension} & \thead{Mean \ Rebound\ Height} & \thead{Uncertainty\ in $\overline{h_{r}}$} & \thead{Percentage \uncertainty\ in $\overline{h_{r}}$} & \thead{Coefficient \of Restitution} & \thead{Percentage \uncertainty \in $e$} & \thead{Uncertainty\ in $e$}\ (T) $\pm$ 5 N & ($\overline{h_{r}}$) / m & $e$ \ \midrule \rowcolor[rgb]{0.902,0.902,0.902} 147 & 1.345 & 2.345 & 2.345& 2.345& 2.345& 2.345\ \rowcolor[rgb]{0.949,0.949,0.949} 196 & 1.345 & 2.345 & 2.345& 2.345& 2.345& 2.345\ \rowcolor[rgb]{0.902,0.902,0.902} 245 & 1.345 & 2.345 & 2.345& 2.345& 2.345& 2.345 \ \rowcolor[rgb]{0.949,0.949,0.949} 294& 1.345 & 2.345 & 2.345& 2.345& 2.345& 2.345\ \rowcolor[rgb]{0.902,0.902,0.902} 343& 1.345 & 2.345 & 2.345& 2.345& 2.345& 2.345\ \bottomrule \end{tabular} \caption{Processed Data} \label{tab:Raw Data} \end{table} \end{document}

It still exceeds textwidth.

Note: Trying to influence the position of a float by only [!h] or [H] is not a good practice. You may find a detailed answer related to this in this TEX.SE question.

Imran
  • 3,096