我已经写了下面的代码
\documentclass{article}
\usepackage{tabularx}
\setlength{\tabcolsep}{15pt}
\usepackage{array}
\usepackage{multirow}
\usepackage[table]{xcolor}
\begin{document}
\begin{table}[h]
\begin{tabular}{ l@{\hspace{1in}}| l | l | r | }
\hline\noalign{\smallskip}
\multicolumn{2}{c}{Item}
& Other things
\\
\hline
Animal & Description & Price (\$) \\
\noalign{\smallskip}\hline\noalign{\smallskip}
Gnat & per gram & 13.65 \\
& each & 0.01 \\
Gnu & stuffed & 92.50 \\
Emu & stuffed & 33.33 \\
Armadillo & frozen & 8.99 \\
\noalign{\smallskip}\hline
\end{tabular}
\end{table}
\begin{table}[h]
\rowcolors{1}{red}
\begin{tabular}{| l | l | c | c |}
\hline
1 & 2 & \multicolumn{2}{c|}{Content 3 and 4} \\[20pt] \hline
5 & 6 & 7 & 8 \\ \cline{2-4}
9 & 10 & \multirow{2}{*}{Rows 3 and 4} & 12 \\
\cline{1-2} \cline{4-4}
13 & 14 & & 16 \\ \hline
\end{tabular}
\end{table}
\begin{table}
\begin{tabular}{p c}
\hline
\begin{verbatim}
code
\end{verbatim}
& description
\\ \hline
\end{tabular}
\end{table}
\end{document}
我收到错误
line 31: Misplaced \noalign. \hline
line 32: Misplaced alignment tab character &. 1 &
line 32: Misplaced alignment tab character &. 1 & 2 &
line 32: Misplaced \omit. ...& 2 & \multicolumn{2}{c|}{Content 3 and 4}
line 32: Misplaced \span. ...& 2 & \multicolumn{2}{c|}{Content 3 and 4}
line 32: Misplaced \omit. ...& 2 & \multicolumn{2}{c|}{Content 3 and 4}
line 32: Misplaced \noalign. ...n{2}{c|}{Content 3 and 4} \\[20pt] \hline
line 33: Misplaced alignment tab character &. 5 &
line 33: Misplaced alignment tab character &. 5 & 6 &
line 33: Misplaced alignment tab character &. 5 & 6 & 7 &
line 33: Misplaced \omit. 5 & 6 & 7 & 8 \\ \cline{2-4}
line 33: Misplaced alignment tab character &. 5 & 6 & 7 & 8 \\ \cline{2-4}
line 33: Misplaced \omit. 5 & 6 & 7 & 8 \\ \cline{2-4}
line 33: Misplaced \span. 5 & 6 & 7 & 8 \\ \cline{2-4}
line 33: Misplaced \omit. 5 & 6 & 7 & 8 \\ \cline{2-4}
line 33: Misplaced \span. 5 & 6 & 7 & 8 \\ \cline{2-4}
line 33: Misplaced \omit. 5 & 6 & 7 & 8 \\ \cline{2-4}
line 33: Misplaced \cr. 5 & 6 & 7 & 8 \\ \cline{2-4}
line 33: Misplaced \noalign. 5 & 6 & 7 & 8 \\ \cline{2-4}
line 34: Misplaced alignment tab character &. 9 &
line 34: Misplaced alignment tab character &. 9 & 10 &
line 34: Misplaced alignment tab character &. 9 & 10 & \multirow{2}{*}{Rows 3 and 4} &
line 35: Misplaced \omit. \cline{1-2}
line 35: Misplaced \span. \cline{1-2}
line 35: Misplaced \omit. \cline{1-2}
line 35: Misplaced \cr. \cline{1-2}
line 35: Misplaced \noalign. \cline{1-2}
line 35: Misplaced \omit. \cline{1-2} \cline{4-4}
line 35: Misplaced \span. \cline{1-2} \cline{4-4}
line 35: Misplaced \omit. \cline{1-2} \cline{4-4}
line 35: Misplaced \span. \cline{1-2} \cline{4-4}
line 35: Misplaced \omit. \cline{1-2} \cline{4-4}
line 35: Misplaced alignment tab character &. \cline{1-2} \cline{4-4}
line 35: Misplaced \omit. \cline{1-2} \cline{4-4}
line 35: Leaders not followed by proper glue. \cline{1-2} \cline{4-4}
line 35: Misplaced \cr. \cline{1-2} \cline{4-4}
line 35: Misplaced \noalign. \cline{1-2} \cline{4-4}
line 36: Misplaced alignment tab character &. 13 &
line 36: Misplaced alignment tab character &. 13 & 14 &
line 36: Misplaced alignment tab character &. 13 & 14 & &
line 36: Misplaced \noalign. 13 & 14 & & 16 \\ \hline
line 37: Misplaced \crcr. \end{tabular}
line 37: Extra }, or forgotten \endgroup. \end{tabular}
line 37: Extra }, or forgotten $. \end{tabular}
line 37: \begin{table} on input line 28 ended by \end{tabular}. \end{tabular}
line 37: Missing $ inserted. \end{tabular}
line 38: Too many }'s. \end{table}
line 38: \begin{document} ended by \end{table}. \end{table}
line 38: Extra \endgroup. \end{table}
line 42: Undefined control sequence. \hline
line 43: Missing number, treated as zero. \begin
line 43: Illegal unit of measure (pt inserted). \begin
line 46: Extra alignment tab has been changed to \cr. &
line 46: Missing number, treated as zero. & d
line 46: Illegal unit of measure (pt inserted). & d
line 47: Undefined control sequence. \\ \hline
line 32: Underfull \hbox (badness 10000) in paragraph
line 33: Underfull \hbox (badness 10000) in paragraph
line 34: Overfull \vbox (12.0pt too high) detected
line 34: Underfull \hbox (badness 10000) in paragraph
line 36: Underfull \hbox (badness 10000) in paragraph
line 43: Overfull \hbox (4.44444pt too wide) in paragraph
line 45: Overfull \hbox (20.99982pt too wide) in paragraph
line 46: Overfull \hbox (52.30565pt too wide) in paragraph
那么上表中的错误是什么?我的代码编辑器 Tex Studio 不显示行号。我只在错误消息中看到行号。
答案1
你缺少一个论点\rowcolors
\rowcolors{1}{red}{blue}