表格错误:缺少项目。抑制还是修复?

表格错误:缺少项目。抑制还是修复?

我在第 8 行收到此代码的错误“可能缺少一个项目”:

\begin{table}[ht]
\centering
\caption{My caption}
\label{table:proberesults}
\begin{tabular}{@{}cccccccc@{}}
    \toprule
    \textbf{} & \multicolumn{1}{l}{} & \multicolumn{1}{l}{} & \multicolumn{5}{c}{False positives} \\ \cmidrule(l){4-8} 
    \textbf{Participant} & \multicolumn{1}{l}{\textbf{Hours of use}} & \multicolumn{1}{l}{\textbf{Positives}} & \textbf{\begin{tabular}[c]{@{}c@{}}Physical\\ movement\end{tabular}} & \textbf{\begin{tabular}[c]{@{}c@{}}Concentrated \\ work\end{tabular}} & \textbf{\begin{tabular}[c]{@{}c@{}}Unknown\\ cause\end{tabular}} & \textbf{\begin{tabular}[c]{@{}c@{}}Social \\ interaction\end{tabular}} & \textbf{\begin{tabular}[c]{@{}c@{}}Incorrect\\ use\end{tabular}} \\ \midrule
    \#1 & 6 & 3 & 1 & 2 & 1 &  &  \\
    \#2 & 8 & 6 & 8 & 1 & 1 & 3 &  \\
    \#3 & 12 & 6 & 1 &  & 1 &  & 5 \\
    \#4 & 12 & 0* &  &  & 2 & 1 &  \\
    \#5 & 5 & 2 &  &  & 2 &  &  \\
    \#6 & 2 & 0 & 2 &  & 2 & 2 &  \\ \bottomrule
\end{tabular}
\end{table}

我不太在意其中是否存在错误,只要打印出来表格看起来就没问题。

有没有办法可以抑制这个文件“table.tex”的所有警告/错误报告?此外,如果有人对如何修复错误有建议,那就太好了。

编辑:这是我的序言:

\documentclass[12pt, twoside]{book}
\usepackage[parfill]{parskip}
\usepackage{graphicx}
\usepackage{natbib}
\usepackage{apalike}
\usepackage[autostyle, threshold=40, thresholdtype=words]{csquotes}
\usepackage{booktabs}
\usepackage{pbox}
\usepackage{caption}
\usepackage{subcaption}
\usepackage[textlf]{MinionPro}
\usepackage[onehalfspacing]{setspace}
\usepackage[a4paper,width=150mm,top=25mm,bottom=25mm]{geometry}
\usepackage{fancyhdr}
\usepackage{pdfpages}
\usepackage[titletoc]{appendix}
\usepackage[USenglish]{babel}
\usepackage{enumitem}
\usepackage{titlesec}
\usepackage{siunitx}
\usepackage{algorithm}
\usepackage{algorithmicx}
\usepackage[noend]{algpseudocode}

\titlespacing{\subsubsection}{0pt}{6pt plus 4pt minus 2pt}{0pt plus 2pt minus 2pt}
\titlespacing*{\paragraph}{0pt}{0.5\baselineskip}{1\baselineskip}
\setlist{noitemsep}

\usepackage{hyperref}
\hypersetup{
    colorlinks,
    citecolor=black,
    filecolor=black,
    linkcolor=black,
    urlcolor=black
}

\fancyhead{}
\fancyhead[LE,RO]{\thepage}
\fancyhead[LO,RE]{\nouppercase{\leftmark}}

\pagestyle{fancy}

\BeforeBeginEnvironment{tabular}{\begin{center}\small}
    \AfterEndEnvironment{tabular}{\end{center}}

答案1

(评论太长,因此作为答案发布)

仅使用您提供的信息,我也无法复制您所说的问题。

无论如何,我想质疑你所说的“表格在打印时看起来不错”。例如,除非文档的文本块通常很宽,否则表格会突出到右侧边距。我建议你使用tabularx来确保表格材料适合文本块。另一个建议:不要使用粗体对于标题单元格中的材料:没有必要。确实如此。

以下屏幕截图显示了建议的布局和您的代码生成的布局。

在此处输入图片描述

\documentclass{article}
\usepackage[letterpaper,margin=1in]{geometry} % set text block parameters
\usepackage[skip=0.333\baselineskip]{caption}
\usepackage{booktabs,tabularx,ragged2e,mathtools,siunitx}
\newcolumntype{C}{>{\Centering\arraybackslash\hspace{0pt}}X}
\newcommand\mC[1]{\multicolumn{1}{@{}C@{}}{#1}} % handy shortcut macro
\begin{document}

\begin{table}[ht]
\caption{My caption}
\label{table:proberesults}
\begin{tabularx}{\textwidth}{@{}
      c S[table-format=2.0] *6{c} @{}}
\toprule
&&& \multicolumn{5}{c}{False positives} \\ 
\cmidrule(l){4-8} 
Participant & {Hours of use} & Positives & 
\mC{Physical movement} & \mC{Concentrated work} & 
\mC{Unknown cause} & \mC{Social interaction} & 
\mC{Incorrect use} \\ 
\midrule
    \#1 & 6 & 3 & 1 & 2 & 1 &  &  \\
    \#2 & 8 & 6 & 8 & 1 & 1 & 3 &  \\
    \#3 & 12 & 6 & 1 &  & 1 &  & 5 \\
    \#4 & 12 & 0$\mathrlap{^*}$ &  &  & 2 & 1 &  \\
    \#5 & 5 & 2 &  &  & 2 &  &  \\
    \#6 & 2 & 0 & 2 &  & 2 & 2 &  \\ 
\bottomrule
\end{tabularx}
\end{table}

\begin{table}[ht]
\centering
\caption{For comparison: Original form of table}
\label{table:proberesults}
\begin{tabular}{@{}cccccccc@{}}
    \toprule
    \textbf{} & \multicolumn{1}{l}{} & \multicolumn{1}{l}{} & \multicolumn{5}{c}{False positives} \\ \cmidrule(l){4-8} 
    \textbf{Participant} & \multicolumn{1}{l}{\textbf{Hours of use}} & \multicolumn{1}{l}{\textbf{Positives}} & \textbf{\begin{tabular}[c]{@{}c@{}}Physical\\ movement\end{tabular}} & \textbf{\begin{tabular}[c]{@{}c@{}}Concentrated \\ work\end{tabular}} & \textbf{\begin{tabular}[c]{@{}c@{}}Unknown\\ cause\end{tabular}} & \textbf{\begin{tabular}[c]{@{}c@{}}Social \\ interaction\end{tabular}} & \textbf{\begin{tabular}[c]{@{}c@{}}Incorrect\\ use\end{tabular}} \\ \midrule
    \#1 & 6 & 3 & 1 & 2 & 1 &  &  \\
    \#2 & 8 & 6 & 8 & 1 & 1 & 3 &  \\
    \#3 & 12 & 6 & 1 &  & 1 &  & 5 \\
    \#4 & 12 & 0* &  &  & 2 & 1 &  \\
    \#5 & 5 & 2 &  &  & 2 &  &  \\
    \#6 & 2 & 0 & 2 &  & 2 & 2 &  \\ \bottomrule
\end{tabular}
\end{table}

\end{document}

相关内容