为什么会出现“额外的对齐制表符已更改为 \cr”的错误?

为什么会出现“额外的对齐制表符已更改为 \cr”的错误?

我是 LaTeX 新手,但我之前使用下面的代码制作过表格...我使用旧模板编辑表格,但收到额外的对齐错误。有人能帮我找出我错在哪里或我需要做什么吗?

\begin{center}
\begin{minipage}{\linewidth}
\centering
\captionof{table}{\bf{Calculations for Proctor Compaction}} 
\label{tab:Calculations for Proctor Compaction} 
\begin{tabular}{ C{1.25in} C{0.85in} *4{C{0.75in}}}\toprule[1.5pt]
\bf Property & \bf Unit & \bf Test 1 & \bf Test 2 & \bf Test 3 & \bf Test 4 & \bf Test 5 \\\midrule
\bf Mass of Soil in Oven Can & grams & 43.67 & 67.93 & 52.98 & 38.87 & 66.38  \\\\
\bf Mass of Water in Oven Can & grams & 2.14 & 4.98 & 5.93 & 5.66 & 10.24 \\\\
\bf Moisture Content & [\%] & 4.90 & 7.33 & 11.19 & 14.56 & 15.43  \\\\
\bf Moist Density of Compacted Soil & $\frac{g}{cm^{3}}$ & 1.83 & 1.99 & 2.09 & 2.02 & 1.92 \\\\
\bf Dry Density of Compacted Soil & $\frac{g}{cm^3}$ & 1.74 & 1.85 & 1.88 & 1.76 & 1.66 \\
\bottomrule[1.25pt]
\end{tabular}\par
\bigskip

\end{minipage}
\end{center}

答案1

您的表格定义中有 6 列,但例如这一行:

\bf Dry Density of Compacted Soil & $\frac{g}{cm^3}$ & 1.74 & 1.85 & 1.88 & 1.76 & 1.66 \\

有七个。您可能应该在列定义中添加一列。

(并且请考虑\bf something将过时的改为\textbf{something})。

答案2

一些评论和意见:

  • 正如 Przemysław Scherwentke 所指出的他的回答,主要问题是您的表实际上包含 7 列,而您只定义了 6 列。

  • 请再考虑一下表格材料的组织方式。我建议你不要使用任何大胆的完全没有。相反,请提供五个数字列中的小数点对齐,例如,通过加载包siunitx并使用其S列类型。

  • 也请提供更多标准方法来排版科学单位。同样,如果您愿意加载该siunitx包,请使用该包的\si宏以符合国际标准的方式排版单位。

  • 我还建议您使用tabularx环境并允许在第一列换行。

在此处输入图片描述

\documentclass{article}
\usepackage{tabularx,booktabs,ragged2e,caption}
\captionsetup{textfont=bf} % only if needed
\usepackage[per-mode=symbol]{siunitx}

\begin{document}
\begin{table}[ht!]
\setlength\tabcolsep{5pt} % default: 6pt
\captionsetup{skip=0.333\baselineskip} % amount of whitespace below caption
\caption{Calculations for Proctor Compaction} 
\label{tab:Calculations for Proctor Compaction} 

\begin{tabularx}{\textwidth}{@{} 
    >{\RaggedRight\hangindent=1em\hangafter=1}X 
    c 
    *{5}{S[table-format=2.2]} @{}}
\toprule
Property & Unit & {Test 1} & {Test 2} & {Test 3} & {Test 4} & {Test 5} \\
\midrule
Mass of Soil in Oven Can & grams & 43.67 & 67.93 & 52.98 & 38.87 & 66.38  \\ \addlinespace
Mass of Water in Oven Can & grams & 2.14 & 4.98 & 5.93 & 5.66 & 10.24 \\ \addlinespace
Moisture Content & [\%] & 4.90 & 47.33 & 11.19 & 14.56 & 15.43  \\ \addlinespace
Moist Density of Compacted Soil & \si{\gram\per\cubic\centi\meter} & 1.83 & 1.99 & 2.09 & 2.02 & 1.92 \\ \addlinespace
Dry Density of Compacted Soil & \si{\gram\per\cubic\centi\meter} & 1.74 & 1.85 & 1.88 & 1.76 & 1.66 \\ 
\bottomrule
\end{tabularx}
\end{table}
\end{document}

相关内容