将行放入表格中

将行放入表格中

我有创建表的代码,但遇到了一个问题:

\documentclass[11pt, a4paper, twoside]{Thesis} % Paper size, default font size and one-sided paper
\graphicspath{{./Pictures/}} % Specifies the directory where pictures are stored
\usepackage[square, numbers,rotating, comma, fancyhdr,here,longtable ,sort&compress,caption, booktabs,pifont,epsfig,subfig ,enumitem,array,subcaption, cleveref,subfigure ,tabularx, textcomp, placeins,graphicx, url, blindtext,verbose{placeins}]
\begin{document}

    \begin{table}[htp]
    \caption{The correlation between wireless sensor nodes [25--28--29--31--32] }
        \label{tab: cor}
                \centering
                    \footnotesize\setlength{\tabcolsep}{2.5pt}
                        \begin{tabular}{l@{\hspace{6pt}} *{5}{c}}
                            \toprule
                            \bfseries Node Name & \multicolumn{5}{c}{\bfseries Node name} \\
                            \cmidrule(l){3-5}
                            & 25 & 28 & 29 & 31 & 32                 \\
                            \midrule
                            \bfseries Node 25
                            & 1.00 &    0.96    & 0.92  & 0.97 &    0.97    \\
                            \bfseries Node 28
                            & 0.96& 1.00 &  0.93 &  0.97 &  0.96             \\
                            \bfseries Node 29
                            & 0.92 &    0.93 &  1.00 &  0.92 &  0.94                           \\
                            \bfseries Node 31
                            & 0.97 &    0.97 &  0.92 &  1.00 &  0.96    \\
                            \bfseries Node 32                                      \\
                            & 0.97 &    0.96 &  0.94 &  0.96 &  1.00                  \\
                        \bottomrule
                    \addlinespace
        \end{tabular}
    \end{table}

\end{document}

当行没有放置在适当的位置时,问题就凸显出来了。 在此处输入图片描述

答案1

在“Node 32”之后,您似乎有一个额外的新行命令\\,这将导致 LaTeX 在您的表中插入一个额外的行。

\end此外,您的代码底部附近似乎有一个虚假命令,这在我尝试编译时导致了错误。

最小工作示例:

\documentclass[11pt, a4paper, twoside]{article} % Paper size, default font size and one-sided paper
\usepackage{booktabs}
\begin{document}

\begin{table}[htp]
  \caption{The correlation between wireless sensor nodes [25--28--29--31--32] }
  \label{tab: cor}
  \centering
  \footnotesize\setlength{\tabcolsep}{2.5pt}
  \begin{tabular}{l@{\hspace{6pt}} *{5}{c}}
    \toprule
    \bfseries Node Name & \multicolumn{5}{c}{\bfseries Node name} \\
    \cmidrule(l){3-5}
    & 25 & 28 & 29 & 31 & 32\\
    \midrule
    \bfseries Node 25
    & 1.00 &    0.96    & 0.92  & 0.97 &    0.97\\
    \bfseries Node 28
    & 0.96& 1.00 &  0.93 &  0.97 &  0.9\\
    \bfseries Node 29
    & 0.92 &    0.93 &  1.00 &  0.92 &  0.9\\
    \bfseries Node 31
    & 0.97 &    0.97 &  0.92 &  1.00 &  0.96\\
    \bfseries Node 32 
    & 0.97 &    0.96 &  0.94 &  0.96 &  1.00\\
    \bottomrule
    \addlinespace
  \end{tabular}
\end{table}
\end{document}

相关内容