有没有办法让这个表格适合我的文档?此外,我如何才能像下面第二张图片那样调整表格第一行的间距

有没有办法让这个表格适合我的文档?此外,我如何才能像下面第二张图片那样调整表格第一行的间距
\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}

我尝试使用该\makecell包,但无法使其看起来美观。任何帮助都将不胜感激。

我的当前表

第一行参考表

答案1

您可以使用命令减小字体\scriptsize。此外,您还可以将表头分成更多行。

在此处输入图片描述

\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}

它仍然超出了文本宽度。

笔记:[!h]尝试仅通过或来影响浮动的位置[H]并不是一个好的做法。您可以在以下位置找到与此相关的详细答案这个 TEX.SE 问题

答案2

这是另一个解决方案,使用 的值tabcolsep\rothead来自 的命令。我还使用来自 的命令makecell简化了代码:\rowcolorsxcolor

\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} 

在此处输入图片描述

相关内容