我有以下代码:
\documentclass{article}
\usepackage{booktabs}
\begin{document}
\begin{table}
\begin{tabular}{SSSS}
1& small copper ring & small aluminum ring & large aluminum ring \\ \midrule
$T$ [s]& $0.567\pm0.014$ & $0.570\pm0.004$ &$0.558\pm0.008$ \\
$M$ [g]& 27.5 & 8.5 & 25.0 \\ \bottomrule
\end{tabular}
\caption{$T$ denotes for the average period, written together with the sample standard deviation. $M$ denotes for the mass of the ring.
\end{table}
\end{document}
然后它会抛出一些错误,例如:缺少 $ 插入。$T$ [s]& $0.567\pm0.014$ & 等。问题是什么?
答案1
您忘记了后面的右括号mass of the ring.
,并且S
不是预定义的列类型booktabs
。这里有两种可能的方法来获得编译的表。
- 如果您使用例如则
\begin{tabular}{cccc}
没有错误。 siunitx
定义一个S
列,但将其用于文本条目没有多大意义,因此您可能还想使用\multicolumn
s 作为相关标题。
例子:
\documentclass{article}
\usepackage{booktabs}
\usepackage{siunitx} %<- defines an S column type but it may not make too
% much sense to use it here for all cells.
\begin{document}
\begin{table}
\begin{tabular}{cccc}
1& small copper ring & small aluminum ring & large aluminum ring \\ \midrule
$T$ [s]& $0.567\pm0.014$ & $0.570\pm0.004$ &$0.558\pm0.008$ \\
$M$ [g]& 27.5 & 8.5 & 25.0 \\ \bottomrule
\end{tabular}
\caption{$T$ denotes for the average period, written together with the
sample standard deviation. $M$ denotes for the mass of the ring.}
\end{table}
\begin{table}
\begin{tabular}{cSSS}
1& \multicolumn{1}{c}{small copper ring} &
\multicolumn{1}{c}{small aluminum ring} &
\multicolumn{1}{c}{large aluminum ring} \\ \midrule
$T$ [s]& 0.567\pm0.014 & 0.570\pm0.004 &0.558\pm0.008 \\
$M$ [g]& 27.5 & 8.5 & 25.0 \\ \bottomrule
\end{tabular}
\caption{$T$ denotes for the average period, written together with the
sample standard deviation. $M$ denotes for the mass of the ring.}
\end{table}
\end{document}
附录: 作为Torbjørn T. 指出。,可以将第二个表的代码简化为
\begin{table}
\begin{tabular}{cSSS}
1& {small copper ring} &
{small aluminum ring} &
{large aluminum ring} \\ \midrule
$T$ [s]& 0.567\pm0.014 & 0.570\pm0.004 &0.558\pm0.008 \\
$M$ [g]& 27.5 & 8.5 & 25.0 \\ \bottomrule
\end{tabular}
\caption{$T$ denotes for the average period, written together with the
sample standard deviation. $M$ denotes for the mass of the ring.}
\end{table}